From a06e9d0ec73c03404ceb0744b84a62a4dcbe9215 Mon Sep 17 00:00:00 2001 From: Raffson Date: Mon, 23 Dec 2024 18:06:11 +0100 Subject: [PATCH] Plan more ANTI-SHIP against ship-groups with air-defences --- game/commander/tasks/compound/attackships.py | 6 +----- game/commander/tasks/primitive/antiship.py | 12 +++++++++++- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/game/commander/tasks/compound/attackships.py b/game/commander/tasks/compound/attackships.py index e035c65b..5a02c812 100644 --- a/game/commander/tasks/compound/attackships.py +++ b/game/commander/tasks/compound/attackships.py @@ -8,8 +8,4 @@ from game.htn import CompoundTask, Method class AttackShips(CompoundTask[TheaterState]): def each_valid_method(self, state: TheaterState) -> Iterator[Method[TheaterState]]: for ship in state.enemy_ships: - # Ammo depots are targeted based on the needs of the front line by - # ReduceEnemyFrontLineCapacity. No reason to target them before that front - # line is active. - if ship.has_live_radar_sam: - yield [PlanAntiShip(ship)] + yield [PlanAntiShip(ship)] diff --git a/game/commander/tasks/primitive/antiship.py b/game/commander/tasks/primitive/antiship.py index 09b81851..265586e7 100644 --- a/game/commander/tasks/primitive/antiship.py +++ b/game/commander/tasks/primitive/antiship.py @@ -7,12 +7,16 @@ from game.commander.missionproposals import EscortType from game.commander.tasks.packageplanningtask import PackagePlanningTask from game.commander.theaterstate import TheaterState from game.theater.theatergroundobject import NavalGroundObject +from game.utils import meters @dataclass class PlanAntiShip(PackagePlanningTask[NavalGroundObject]): def preconditions_met(self, state: TheaterState) -> bool: - if self.target not in state.threatening_air_defenses: + if ( + self.target not in state.threatening_air_defenses + and not self.target.is_naval_control_point + ): return False if not self.target_area_preconditions_met(state, ignore_iads=True): return False @@ -24,5 +28,11 @@ class PlanAntiShip(PackagePlanningTask[NavalGroundObject]): def propose_flights(self) -> None: size = self.get_flight_size() + if self.target.max_detection_range() > meters(0): + size = 4 # attempt to saturate ship's air-defences + self.propose_flight(FlightType.ANTISHIP, size) + self.propose_flight(FlightType.ESCORT, 2, EscortType.AirToAir) self.propose_flight(FlightType.ANTISHIP, size) self.propose_flight(FlightType.ESCORT, 2, EscortType.AirToAir) + if self.target.max_detection_range() > meters(0): + self.propose_flight(FlightType.SEAD, 2, EscortType.Sead)