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
This commit is contained in:
Simon Krüger 2021-02-09 21:35:47 +01:00 committed by GitHub
parent 7a077a0d21
commit 71914b8a8b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 1 deletions

View File

@ -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:

View File

@ -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