mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
debriefing log parsing
This commit is contained in:
@@ -42,19 +42,20 @@ PRICES = {
|
||||
Armor.APC_BTR_80: 6,
|
||||
|
||||
AirDefence.AAA_ZU_23_on_Ural_375: 4,
|
||||
AirDefence.SAM_Avenger_M1097: 10,
|
||||
}
|
||||
|
||||
UNIT_BY_TASK = {
|
||||
FighterSweep: [Su_27, Su_33, Su_25, F_15C, MiG_15bis, MiG_21Bis, MiG_29A, F_A_18C, AV8BNA],
|
||||
CAS: [Su_25T, A_10A, A_10C, ],
|
||||
CAP: [Armor.MBT_T_90, Armor.MBT_T_80U, Armor.MBT_T_55, Armor.MBT_M1A2_Abrams, Armor.MBT_M60A3_Patton, Armor.ATGM_M1134_Stryker, Armor.APC_BTR_80, ],
|
||||
AirDefence: [AirDefence.AAA_ZU_23_on_Ural_375, ],
|
||||
AirDefence: [AirDefence.AAA_ZU_23_on_Ural_375, AirDefence.SAM_Avenger_M1097 ],
|
||||
Transport: [IL_76MD, S_3B_Tanker, ],
|
||||
}
|
||||
|
||||
UNIT_BY_COUNTRY = {
|
||||
"Russia": [Su_25T, Su_27, Su_33, Su_25, MiG_15bis, MiG_21Bis, MiG_29A, AirDefence.AAA_ZU_23_on_Ural_375, Armor.APC_BTR_80, Armor.MBT_T_90, Armor.MBT_T_80U, Armor.MBT_T_55, IL_76MD, ],
|
||||
"USA": [F_15C, A_10C, F_A_18C, AV8BNA, Armor.MBT_M1A2_Abrams, Armor.MBT_M60A3_Patton, Armor.ATGM_M1134_Stryker, S_3B_Tanker],
|
||||
"USA": [F_15C, A_10C, F_A_18C, AV8BNA, Armor.MBT_M1A2_Abrams, Armor.MBT_M60A3_Patton, Armor.ATGM_M1134_Stryker, S_3B_Tanker, AirDefence.SAM_Avenger_M1097],
|
||||
}
|
||||
|
||||
UnitsDict = typing.Dict[UnitType, int]
|
||||
|
||||
@@ -56,12 +56,12 @@ class GroundInterceptEvent(Event):
|
||||
targets = None # type: db.ArmorDict
|
||||
|
||||
def __str__(self):
|
||||
return "Ground intercept from {} at {} ({})".format(self.from_cp, self.to_cp, "*" * self.difficulty)
|
||||
return "Ground intercept from {} at {}".format(self.from_cp, self.to_cp)
|
||||
|
||||
def is_successfull(self, debriefing: Debriefing):
|
||||
total_targets = sum(self.targets.values())
|
||||
destroyed_targets = 0
|
||||
for unit, count in debriefing.destroyed_units[self.defender.name].items():
|
||||
for unit, count in debriefing.destroyed_units[self.defender_name].items():
|
||||
if unit in self.targets:
|
||||
destroyed_targets += count
|
||||
|
||||
@@ -113,10 +113,10 @@ class InterceptEvent(Event):
|
||||
transport_unit = None # type: FlyingType
|
||||
|
||||
def __str__(self):
|
||||
return "Intercept from {} at {} ({})".format(self.from_cp, self.to_cp, "*" * self.difficulty)
|
||||
return "Intercept from {} at {}".format(self.from_cp, self.to_cp)
|
||||
|
||||
def is_successfull(self, debriefing: Debriefing):
|
||||
intercepted = self.transport_unit in debriefing.destroyed_units[self.defender.name].keys()
|
||||
intercepted = self.transport_unit in debriefing.destroyed_units[self.defender_name].keys()
|
||||
if self.from_cp.captured:
|
||||
return intercepted
|
||||
else:
|
||||
@@ -185,10 +185,10 @@ class CaptureEvent(Event):
|
||||
STRENGTH_RECOVERY = 0.35
|
||||
|
||||
def __str__(self):
|
||||
return "Attack from {} to {} ({})".format(self.from_cp, self.to_cp, "*" * self.difficulty)
|
||||
return "Attack from {} to {}".format(self.from_cp, self.to_cp)
|
||||
|
||||
def is_successfull(self, debriefing: Debriefing):
|
||||
attackers_success = len(debriefing.destroyed_units[self.defender.name]) > len(debriefing.destroyed_units[self.attacker.name])
|
||||
attackers_success = len(debriefing.destroyed_units[self.defender_name]) > len(debriefing.destroyed_units[self.attacker_name])
|
||||
if self.from_cp.captured:
|
||||
return attackers_success
|
||||
else:
|
||||
|
||||
19
game/game.py
19
game/game.py
@@ -21,8 +21,8 @@ ENEMY_INTERCEPT_PROBABILITY_BASE = 10
|
||||
ENEMY_INTERCEPT_GLOBAL_PROBABILITY_BASE = 1
|
||||
ENEMY_CAPTURE_PROBABILITY_BASE = 3
|
||||
|
||||
PLAYER_INTERCEPT_PROBABILITY_BASE = 30
|
||||
PLAYER_GROUNDINTERCEPT_PROBABILITY_BASE = 30
|
||||
PLAYER_INTERCEPT_PROBABILITY_BASE = 100
|
||||
PLAYER_GROUNDINTERCEPT_PROBABILITY_BASE = 100
|
||||
PLAYER_GLOBALINTERCEPT_PROBABILITY_BASE = 100
|
||||
|
||||
PLAYER_INTERCEPT_GLOBAL_PROBABILITY_BASE = 50
|
||||
@@ -40,8 +40,8 @@ class Game:
|
||||
def __init__(self, theater: ConflictTheater):
|
||||
self.events = []
|
||||
self.theater = theater
|
||||
self.player = "USA"
|
||||
self.enemy = "Russia"
|
||||
self.player = "Russia"
|
||||
self.enemy = "USA"
|
||||
|
||||
def _roll(self, prob, mult):
|
||||
return random.randint(0, 100) <= prob * mult
|
||||
@@ -132,16 +132,6 @@ class Game:
|
||||
theater=self.theater))
|
||||
break
|
||||
|
||||
def _generate_global(self):
|
||||
for cp in self.theater.player_points():
|
||||
if cp.is_global:
|
||||
if self._roll(PLAYER_GLOBALINTERCEPT_PROBABILITY_BASE, cp.base.strength):
|
||||
enemy_points = list(set(self.theater.enemy_bases()) - set(self.theater.conflicts(False)))
|
||||
self.events.append(InterceptEvent(attacker_name=self.player,
|
||||
defender_name=self.enemy,
|
||||
from_cp=cp,
|
||||
to_cp=random.choice(enemy_points)))
|
||||
|
||||
def _commision_units(self, cp: ControlPoint):
|
||||
for for_task in [CAP, CAS, FighterSweep, AirDefence]:
|
||||
limit = COMMISION_LIMITS_FACTORS[for_task] * math.pow(cp.importance, COMMISION_LIMITS_SCALE)
|
||||
@@ -207,5 +197,4 @@ class Game:
|
||||
self._generate_interceptions()
|
||||
self._generate_globalinterceptions()
|
||||
self._generate_groundinterceptions()
|
||||
self._generate_global()
|
||||
|
||||
|
||||
@@ -159,7 +159,8 @@ class GroundInterceptOperation(Operation):
|
||||
radials=ALL_RADIALS
|
||||
)
|
||||
|
||||
super(GroundInterceptOperation, self).__init__(mission, conflict)
|
||||
self.initialize(mission=mission,
|
||||
conflict=conflict)
|
||||
|
||||
def generate(self):
|
||||
self.airgen.generate_cas(self.strikegroup, clients=self.attacker_clients, at=self.starting_position)
|
||||
|
||||
Reference in New Issue
Block a user