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:
parent
73d2f8fda1
commit
49211dae4f
@ -1,5 +1,6 @@
|
|||||||
from collections.abc import Iterator
|
from collections.abc import Iterator
|
||||||
|
|
||||||
|
from game.commander.tasks.primitive.armedrecon import PlanArmedRecon
|
||||||
from game.commander.tasks.primitive.bai import PlanBai
|
from game.commander.tasks.primitive.bai import PlanBai
|
||||||
from game.commander.theaterstate import TheaterState
|
from game.commander.theaterstate import TheaterState
|
||||||
from game.htn import CompoundTask, Method
|
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_positions in state.enemy_battle_positions.values():
|
||||||
for battle_position in battle_positions.in_priority_order:
|
for battle_position in battle_positions.in_priority_order:
|
||||||
yield [PlanBai(battle_position)]
|
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()
|
||||||
@ -63,6 +63,7 @@ class TheaterState(WorldState["TheaterState"]):
|
|||||||
enemy_barcaps: list[ControlPoint]
|
enemy_barcaps: list[ControlPoint]
|
||||||
threat_zones: ThreatZones
|
threat_zones: ThreatZones
|
||||||
vulnerable_control_points: list[ControlPoint]
|
vulnerable_control_points: list[ControlPoint]
|
||||||
|
control_point_priority_queue: list[ControlPoint]
|
||||||
|
|
||||||
def _rebuild_threat_zones(self) -> None:
|
def _rebuild_threat_zones(self) -> None:
|
||||||
"""Recreates the theater's threat zones based on the current planned state."""
|
"""Recreates the theater's threat zones based on the current planned state."""
|
||||||
@ -137,6 +138,7 @@ class TheaterState(WorldState["TheaterState"]):
|
|||||||
threatening_air_defenses=self.threatening_air_defenses,
|
threatening_air_defenses=self.threatening_air_defenses,
|
||||||
detecting_air_defenses=self.detecting_air_defenses,
|
detecting_air_defenses=self.detecting_air_defenses,
|
||||||
vulnerable_control_points=self.vulnerable_control_points,
|
vulnerable_control_points=self.vulnerable_control_points,
|
||||||
|
control_point_priority_queue=self.control_point_priority_queue,
|
||||||
)
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@ -198,4 +200,5 @@ class TheaterState(WorldState["TheaterState"]):
|
|||||||
enemy_barcaps=list(game.theater.control_points_for(not player)),
|
enemy_barcaps=list(game.theater.control_points_for(not player)),
|
||||||
threat_zones=game.threat_zone_for(not player),
|
threat_zones=game.threat_zone_for(not player),
|
||||||
vulnerable_control_points=vulnerable_control_points,
|
vulnerable_control_points=vulnerable_control_points,
|
||||||
|
control_point_priority_queue=ordered_capturable_points,
|
||||||
)
|
)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user