Autoplanner support for ArmedRecon

This commit is contained in:
Raffson
2024-09-15 21:12:34 +02:00
parent 73d2f8fda1
commit 49211dae4f
3 changed files with 32 additions and 0 deletions

View File

@@ -1,5 +1,6 @@
from collections.abc import Iterator
from game.commander.tasks.primitive.armedrecon import PlanArmedRecon
from game.commander.tasks.primitive.bai import PlanBai
from game.commander.theaterstate import TheaterState
from game.htn import CompoundTask, Method
@@ -10,3 +11,6 @@ class AttackBattlePositions(CompoundTask[TheaterState]):
for battle_positions in state.enemy_battle_positions.values():
for battle_position in battle_positions.in_priority_order:
yield [PlanBai(battle_position)]
# Only plan against the 2 most important CPs
for cp in state.control_point_priority_queue[:2]:
yield [PlanArmedRecon(cp)]

View File

@@ -0,0 +1,25 @@
from __future__ import annotations
from dataclasses import dataclass
from game.ato.flighttype import FlightType
from game.commander.tasks.packageplanningtask import PackagePlanningTask
from game.commander.theaterstate import TheaterState
from game.theater import ControlPoint
@dataclass
class PlanArmedRecon(PackagePlanningTask[ControlPoint]):
def preconditions_met(self, state: TheaterState) -> bool:
if self.target not in state.control_point_priority_queue:
return False
if not self.target_area_preconditions_met(state):
return False
return super().preconditions_met(state)
def apply_effects(self, state: TheaterState) -> None:
state.control_point_priority_queue.remove(self.target)
def propose_flights(self) -> None:
self.propose_flight(FlightType.ARMED_RECON, self.get_flight_size())
self.propose_common_escorts()