mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Fine-tuning recovery tankers
This commit is contained in:
parent
ef77637c9a
commit
020281bf80
@ -41,9 +41,10 @@ class MissionScheduler:
|
|||||||
p for p in self.coalition.ato.packages if p.primary_task not in dca_types
|
p for p in self.coalition.ato.packages if p.primary_task not in dca_types
|
||||||
]
|
]
|
||||||
|
|
||||||
carrier_etas = []
|
|
||||||
previous_aewc_end_time: dict[MissionTarget, datetime] = defaultdict(now.replace)
|
previous_aewc_end_time: dict[MissionTarget, datetime] = defaultdict(now.replace)
|
||||||
|
|
||||||
|
max_simultaneous_recovery_tankers = 2 # TODO: make configurable
|
||||||
|
carrier_etas: dict[MissionTarget, list[datetime]] = defaultdict(list)
|
||||||
max_carrier_simultaneous_barcaps = 2 # TODO: make configurable
|
max_carrier_simultaneous_barcaps = 2 # TODO: make configurable
|
||||||
carrier_barcaps: dict[MissionTarget, int] = defaultdict(int)
|
carrier_barcaps: dict[MissionTarget, int] = defaultdict(int)
|
||||||
|
|
||||||
@ -94,22 +95,29 @@ class MissionScheduler:
|
|||||||
# to be present. Runway and air started aircraft will be
|
# to be present. Runway and air started aircraft will be
|
||||||
# delayed until their takeoff time by AirConflictGenerator.
|
# delayed until their takeoff time by AirConflictGenerator.
|
||||||
package.time_over_target = next(start_time) + tot
|
package.time_over_target = next(start_time) + tot
|
||||||
arrivals = []
|
|
||||||
for f in package.flights:
|
for f in package.flights:
|
||||||
if f.departure.is_fleet and not f.is_helo:
|
if f.departure.is_fleet and not f.is_helo:
|
||||||
arrivals.append(f.flight_plan.landing_time - timedelta(minutes=10))
|
carrier_etas[f.departure].append(
|
||||||
if arrivals:
|
f.flight_plan.landing_time - timedelta(minutes=10)
|
||||||
carrier_etas.append(min(arrivals))
|
)
|
||||||
|
|
||||||
|
# division by 2 is meant to provide some leeway to avoid filtering out too many ETAs
|
||||||
|
duration = self.coalition.game.settings.desired_tanker_on_station_time / 2
|
||||||
|
|
||||||
|
for cp in carrier_etas:
|
||||||
|
filtered: list[datetime] = []
|
||||||
|
for eta in sorted(carrier_etas[cp]):
|
||||||
|
count = len([t for t in filtered if eta < t + duration])
|
||||||
|
if count < max_simultaneous_recovery_tankers:
|
||||||
|
filtered.append(eta)
|
||||||
|
carrier_etas[cp] = filtered
|
||||||
for package in [
|
for package in [
|
||||||
p
|
p
|
||||||
for p in self.coalition.ato.packages
|
for p in self.coalition.ato.packages
|
||||||
if p.primary_task is FlightType.RECOVERY
|
if p.primary_task is FlightType.RECOVERY
|
||||||
]:
|
]:
|
||||||
if carrier_etas:
|
if carrier_etas[package.target]:
|
||||||
package.time_over_target = carrier_etas.pop(0)
|
package.time_over_target = carrier_etas[package.target].pop(0)
|
||||||
else:
|
|
||||||
break
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _get_departure_time(package: Package) -> datetime | None:
|
def _get_departure_time(package: Package) -> datetime | None:
|
||||||
|
|||||||
@ -7,6 +7,8 @@ from game.commander.tasks.packageplanningtask import PackagePlanningTask
|
|||||||
from game.commander.theaterstate import TheaterState
|
from game.commander.theaterstate import TheaterState
|
||||||
from game.theater import ControlPoint
|
from game.theater import ControlPoint
|
||||||
|
|
||||||
|
MARGIN = 4 # assume 4 aircraft can land without refueling
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class PlanRecovery(PackagePlanningTask[ControlPoint]):
|
class PlanRecovery(PackagePlanningTask[ControlPoint]):
|
||||||
@ -19,14 +21,14 @@ class PlanRecovery(PackagePlanningTask[ControlPoint]):
|
|||||||
ac_per_tanker = state.context.settings.aircraft_per_recovery_tanker
|
ac_per_tanker = state.context.settings.aircraft_per_recovery_tanker
|
||||||
if not (
|
if not (
|
||||||
self.target in state.recovery_targets
|
self.target in state.recovery_targets
|
||||||
and state.recovery_targets[self.target] >= ac_per_tanker
|
and state.recovery_targets[self.target] >= ac_per_tanker + MARGIN
|
||||||
):
|
):
|
||||||
return False
|
return False
|
||||||
return super().preconditions_met(state)
|
return super().preconditions_met(state)
|
||||||
|
|
||||||
def apply_effects(self, state: TheaterState) -> None:
|
def apply_effects(self, state: TheaterState) -> None:
|
||||||
ac_per_tanker = state.context.settings.aircraft_per_recovery_tanker
|
ac_per_tanker = state.context.settings.aircraft_per_recovery_tanker
|
||||||
state.recovery_targets[self.target] -= ac_per_tanker
|
state.recovery_targets[self.target] -= ac_per_tanker + MARGIN
|
||||||
|
|
||||||
def propose_flights(self) -> None:
|
def propose_flights(self) -> None:
|
||||||
self.propose_flight(FlightType.RECOVERY, 1)
|
self.propose_flight(FlightType.RECOVERY, 1)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user