From d35962b784e0bb08934c49e10d877d3ad1229aa2 Mon Sep 17 00:00:00 2001 From: Raffson Date: Sun, 15 Sep 2024 20:40:03 +0200 Subject: [PATCH] AirAssault autoplanner support for non-frontline CPs Aims to solve the issue where AirAssault won't plan against CPs that don't have an active frontline, including isolated CPs. --- game/commander/tasks/compound/capturebase.py | 2 -- game/commander/tasks/compound/capturebases.py | 3 +++ game/commander/tasks/primitive/airassault.py | 3 +-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/game/commander/tasks/compound/capturebase.py b/game/commander/tasks/compound/capturebase.py index 1c2d102b..378cb13e 100644 --- a/game/commander/tasks/compound/capturebase.py +++ b/game/commander/tasks/compound/capturebase.py @@ -7,7 +7,6 @@ from game.commander.tasks.compound.destroyenemygroundunits import ( from game.commander.tasks.compound.reduceenemyfrontlinecapacity import ( ReduceEnemyFrontLineCapacity, ) -from game.commander.tasks.primitive.airassault import PlanAirAssault from game.commander.tasks.primitive.breakthroughattack import BreakthroughAttack from game.commander.theaterstate import TheaterState from game.htn import CompoundTask, Method @@ -23,7 +22,6 @@ class CaptureBase(CompoundTask[TheaterState]): yield [DestroyEnemyGroundUnits(self.front_line)] if self.worth_destroying_ammo_depots(state): yield [ReduceEnemyFrontLineCapacity(self.enemy_cp(state))] - yield [PlanAirAssault(self.enemy_cp(state))] def enemy_cp(self, state: TheaterState) -> ControlPoint: return self.front_line.control_point_hostile_to(state.context.coalition.player) diff --git a/game/commander/tasks/compound/capturebases.py b/game/commander/tasks/compound/capturebases.py index db9068ca..149092c6 100644 --- a/game/commander/tasks/compound/capturebases.py +++ b/game/commander/tasks/compound/capturebases.py @@ -2,6 +2,7 @@ from collections.abc import Iterator from dataclasses import dataclass from game.commander.tasks.compound.capturebase import CaptureBase +from game.commander.tasks.primitive.airassault import PlanAirAssault from game.commander.theaterstate import TheaterState from game.htn import CompoundTask, Method @@ -11,3 +12,5 @@ class CaptureBases(CompoundTask[TheaterState]): def each_valid_method(self, state: TheaterState) -> Iterator[Method[TheaterState]]: for front in state.active_front_lines: yield [CaptureBase(front)] + for cp in state.vulnerable_control_points: + yield [PlanAirAssault(cp)] diff --git a/game/commander/tasks/primitive/airassault.py b/game/commander/tasks/primitive/airassault.py index 2130b7e2..27fad824 100644 --- a/game/commander/tasks/primitive/airassault.py +++ b/game/commander/tasks/primitive/airassault.py @@ -21,6 +21,5 @@ class PlanAirAssault(PackagePlanningTask[ControlPoint]): state.vulnerable_control_points.remove(self.target) def propose_flights(self) -> None: - size = self.get_flight_size() - self.propose_flight(FlightType.AIR_ASSAULT, size) + self.propose_flight(FlightType.AIR_ASSAULT, self.get_flight_size()) self.propose_common_escorts()