Add AI planning for airlifts.

Downside to the current implementation is that whether or not transports
that were purchased last turn will be available for airlift this turn is
arbitrary. This is because transfers are created at the same time as
units are delivered, and units are delivered in an arbitrary order per
CP. If the helicopters are delivered before the ground units they'll
have access to the transports, otherwise they'll be refunded. This will
be fixed later when I rework the transfer requests to not require
immediate fulfillment.

https://github.com/Khopa/dcs_liberation/issues/825
This commit is contained in:
Dan Albert
2021-04-23 01:00:33 -07:00
parent 26cd2d3fef
commit c258409a8d
9 changed files with 244 additions and 164 deletions

View File

@@ -154,6 +154,11 @@ class Game:
# Regenerate any state that was not persisted.
self.on_load()
def ato_for(self, player: bool) -> AirTaskingOrder:
if player:
return self.blue_ato
return self.red_ato
def generate_conditions(self) -> Conditions:
return Conditions.generate(
self.theater, self.current_day, self.current_turn_time_of_day, self.settings
@@ -257,6 +262,10 @@ class Game:
self.compute_conflicts_position()
self.compute_threat_zones()
def reset_ato(self) -> None:
self.blue_ato.clear()
self.red_ato.clear()
def pass_turn(self, no_action: bool = False) -> None:
logging.info("Pass turn")
self.informations.append(
@@ -268,11 +277,13 @@ class Game:
# one hop ahead. ControlPoint.process_turn handles unit deliveries.
self.transfers.perform_transfers()
# Needs to happen *before* planning transfers so we don't cancel the
self.reset_ato()
for control_point in self.theater.controlpoints:
control_point.process_turn(self)
self.process_enemy_income()
self.process_player_income()
if not no_action and self.turn > 1:
@@ -325,8 +336,6 @@ class Game:
self.compute_conflicts_position()
self.compute_threat_zones()
self.ground_planners = {}
self.blue_ato.clear()
self.red_ato.clear()
blue_planner = CoalitionMissionPlanner(self, is_player=True)
blue_planner.plan_missions()