mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Autoplanner support for ArmedRecon
This commit is contained in:
@@ -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)]
|
||||
|
||||
25
game/commander/tasks/primitive/armedrecon.py
Normal file
25
game/commander/tasks/primitive/armedrecon.py
Normal 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()
|
||||
Reference in New Issue
Block a user