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.
This commit is contained in:
Raffson 2024-09-15 20:40:03 +02:00
parent f63939ce3c
commit d35962b784
No known key found for this signature in database
GPG Key ID: B0402B2C9B764D99
3 changed files with 4 additions and 4 deletions

View File

@ -7,7 +7,6 @@ from game.commander.tasks.compound.destroyenemygroundunits import (
from game.commander.tasks.compound.reduceenemyfrontlinecapacity import ( from game.commander.tasks.compound.reduceenemyfrontlinecapacity import (
ReduceEnemyFrontLineCapacity, ReduceEnemyFrontLineCapacity,
) )
from game.commander.tasks.primitive.airassault import PlanAirAssault
from game.commander.tasks.primitive.breakthroughattack import BreakthroughAttack from game.commander.tasks.primitive.breakthroughattack import BreakthroughAttack
from game.commander.theaterstate import TheaterState from game.commander.theaterstate import TheaterState
from game.htn import CompoundTask, Method from game.htn import CompoundTask, Method
@ -23,7 +22,6 @@ class CaptureBase(CompoundTask[TheaterState]):
yield [DestroyEnemyGroundUnits(self.front_line)] yield [DestroyEnemyGroundUnits(self.front_line)]
if self.worth_destroying_ammo_depots(state): if self.worth_destroying_ammo_depots(state):
yield [ReduceEnemyFrontLineCapacity(self.enemy_cp(state))] yield [ReduceEnemyFrontLineCapacity(self.enemy_cp(state))]
yield [PlanAirAssault(self.enemy_cp(state))]
def enemy_cp(self, state: TheaterState) -> ControlPoint: def enemy_cp(self, state: TheaterState) -> ControlPoint:
return self.front_line.control_point_hostile_to(state.context.coalition.player) return self.front_line.control_point_hostile_to(state.context.coalition.player)

View File

@ -2,6 +2,7 @@ from collections.abc import Iterator
from dataclasses import dataclass from dataclasses import dataclass
from game.commander.tasks.compound.capturebase import CaptureBase from game.commander.tasks.compound.capturebase import CaptureBase
from game.commander.tasks.primitive.airassault import PlanAirAssault
from game.commander.theaterstate import TheaterState from game.commander.theaterstate import TheaterState
from game.htn import CompoundTask, Method from game.htn import CompoundTask, Method
@ -11,3 +12,5 @@ class CaptureBases(CompoundTask[TheaterState]):
def each_valid_method(self, state: TheaterState) -> Iterator[Method[TheaterState]]: def each_valid_method(self, state: TheaterState) -> Iterator[Method[TheaterState]]:
for front in state.active_front_lines: for front in state.active_front_lines:
yield [CaptureBase(front)] yield [CaptureBase(front)]
for cp in state.vulnerable_control_points:
yield [PlanAirAssault(cp)]

View File

@ -21,6 +21,5 @@ class PlanAirAssault(PackagePlanningTask[ControlPoint]):
state.vulnerable_control_points.remove(self.target) state.vulnerable_control_points.remove(self.target)
def propose_flights(self) -> None: def propose_flights(self) -> None:
size = self.get_flight_size() self.propose_flight(FlightType.AIR_ASSAULT, self.get_flight_size())
self.propose_flight(FlightType.AIR_ASSAULT, size)
self.propose_common_escorts() self.propose_common_escorts()