From 71914b8a8b3e3094524ec7d9ba9565d16f1d68e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Kr=C3=BCger?= Date: Tue, 9 Feb 2021 21:35:47 +0100 Subject: [PATCH] Aew&c ai planning. AI will generate AWE&C * Only one flight per turn * Takes the airfield farthest away from the frontline * Prefers CV over any airfield --- gen/ato.py | 2 +- gen/flights/ai_flight_planner.py | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/gen/ato.py b/gen/ato.py index b1de7b11..7d541f77 100644 --- a/gen/ato.py +++ b/gen/ato.py @@ -173,8 +173,8 @@ class Package: FlightType.SEAD, FlightType.TARCAP, FlightType.BARCAP, - FlightType.SWEEP, FlightType.AEWC, + FlightType.SWEEP, FlightType.ESCORT, ] for task in task_priorities: diff --git a/gen/flights/ai_flight_planner.py b/gen/flights/ai_flight_planner.py index 2267fcb4..6f961e4e 100644 --- a/gen/flights/ai_flight_planner.py +++ b/gen/flights/ai_flight_planner.py @@ -433,6 +433,22 @@ class ObjectiveFinder: return (c for c in self.game.theater.controlpoints if c.is_friendly(self.is_player)) + def farthest_friendly_control_point(self) -> ControlPoint: + """ + Iterates over all friendly control points and find the one farthest away from the frontline + BUT! prefer Cvs. Everybody likes CVs! + """ + from_frontline = 0 + + for c in self.game.theater.controlpoints: + if c.is_carrier: + return c + if c.is_friendly(self.is_player) & c.has_frontline: + if c.distance_to(self.front_lines().__next__()) > from_frontline: + from_frontline = c.distance_to(self.front_lines().__next__()) + cp = c + return cp + def enemy_control_points(self) -> Iterator[ControlPoint]: """Iterates over all enemy control points.""" return (c for c in self.game.theater.controlpoints if @@ -487,6 +503,7 @@ class CoalitionMissionPlanner: MAX_OCA_RANGE = nautical_miles(150) MAX_SEAD_RANGE = nautical_miles(150) MAX_STRIKE_RANGE = nautical_miles(150) + MAX_AWEC_RANGE = nautical_miles(200) def __init__(self, game: Game, is_player: bool) -> None: self.game = game @@ -506,6 +523,13 @@ class CoalitionMissionPlanner: ensure that they can be planned again next turn even if all aircraft are eliminated this turn. """ + + #Find farthest, friendly CP for AEWC + cp = self.objective_finder.farthest_friendly_control_point() + yield ProposedMission(cp, [ + ProposedFlight(FlightType.AEWC, 1, self.MAX_AWEC_RANGE) + ]) + # Find friendly CPs within 100 nmi from an enemy airfield, plan CAP. for cp in self.objective_finder.vulnerable_control_points(): # Plan three rounds of CAP to give ~90 minutes coverage. Spacing