From 2bd39bd9f531f0ea2fee978bd2c3c305a1ccdf08 Mon Sep 17 00:00:00 2001 From: SnappyComebacks <74509817+SnappyComebacks@users.noreply.github.com> Date: Tue, 26 Jul 2022 22:41:45 -0600 Subject: [PATCH] Changed garrison terminology to battle position. (#2352) --- .../{garrisons.py => battlepositions.py} | 30 +++++++++---------- game/commander/objectivefinder.py | 2 +- .../tasks/compound/attackairinfrastructure.py | 4 +-- ...kgarrisons.py => attackbattlepositions.py} | 8 ++--- game/commander/tasks/compound/nextaction.py | 4 +-- game/commander/tasks/primitive/airassault.py | 6 ++-- game/commander/tasks/primitive/bai.py | 4 +-- .../tasks/primitive/breakthroughattack.py | 8 ++--- game/commander/theaterstate.py | 24 ++++++++------- 9 files changed, 46 insertions(+), 44 deletions(-) rename game/commander/{garrisons.py => battlepositions.py} (53%) rename game/commander/tasks/compound/{attackgarrisons.py => attackbattlepositions.py} (52%) diff --git a/game/commander/garrisons.py b/game/commander/battlepositions.py similarity index 53% rename from game/commander/garrisons.py rename to game/commander/battlepositions.py index d6c69c95..5a232f10 100644 --- a/game/commander/garrisons.py +++ b/game/commander/battlepositions.py @@ -9,7 +9,7 @@ from game.utils import meters @dataclass -class Garrisons: +class BattlePositions: blocking_capture: list[VehicleGroupGroundObject] defending_front_line: list[VehicleGroupGroundObject] @@ -18,35 +18,35 @@ class Garrisons: yield from self.blocking_capture yield from self.defending_front_line - def eliminate(self, garrison: VehicleGroupGroundObject) -> None: - if garrison in self.blocking_capture: - self.blocking_capture.remove(garrison) - if garrison in self.defending_front_line: - self.defending_front_line.remove(garrison) + def eliminate(self, battle_position: VehicleGroupGroundObject) -> None: + if battle_position in self.blocking_capture: + self.blocking_capture.remove(battle_position) + if battle_position in self.defending_front_line: + self.defending_front_line.remove(battle_position) def __contains__(self, item: VehicleGroupGroundObject) -> bool: return item in self.in_priority_order @classmethod - def for_control_point(cls, control_point: ControlPoint) -> Garrisons: - """Categorize garrison groups based on target priority. + def for_control_point(cls, control_point: ControlPoint) -> BattlePositions: + """Categorize battle position groups based on target priority. - Any garrisons blocking base capture are the highest priority. + Any battle positions blocking base capture are the highest priority. """ blocking = [] defending = [] - garrisons = [ + battle_positions = [ tgo for tgo in control_point.ground_objects if isinstance(tgo, VehicleGroupGroundObject) and not tgo.is_dead ] - for garrison in garrisons: + for battle_position in battle_positions: if ( - meters(garrison.distance_to(control_point)) + meters(battle_position.distance_to(control_point)) < ControlPoint.CAPTURE_DISTANCE ): - blocking.append(garrison) + blocking.append(battle_position) else: - defending.append(garrison) + defending.append(battle_position) - return Garrisons(blocking, defending) + return BattlePositions(blocking, defending) diff --git a/game/commander/objectivefinder.py b/game/commander/objectivefinder.py index 4ca1c61b..bdda6a57 100644 --- a/game/commander/objectivefinder.py +++ b/game/commander/objectivefinder.py @@ -105,7 +105,7 @@ class ObjectiveFinder: # better control over planning profiles and target dependent # loadouts we can clean this up. if not isinstance(ground_object, BuildingGroundObject): - # Other group types (like ships, SAMs, garrisons, etc) have better + # Other group types (like ships, SAMs, battle positions, etc) have better # suited mission types like anti-ship, DEAD, and BAI. continue diff --git a/game/commander/tasks/compound/attackairinfrastructure.py b/game/commander/tasks/compound/attackairinfrastructure.py index 50c452b6..9f604013 100644 --- a/game/commander/tasks/compound/attackairinfrastructure.py +++ b/game/commander/tasks/compound/attackairinfrastructure.py @@ -11,5 +11,5 @@ class AttackAirInfrastructure(CompoundTask[TheaterState]): aircraft_cold_start: bool def each_valid_method(self, state: TheaterState) -> Iterator[Method[TheaterState]]: - for garrison in state.oca_targets: - yield [PlanOcaStrike(garrison, self.aircraft_cold_start)] + for battle_position in state.oca_targets: + yield [PlanOcaStrike(battle_position, self.aircraft_cold_start)] diff --git a/game/commander/tasks/compound/attackgarrisons.py b/game/commander/tasks/compound/attackbattlepositions.py similarity index 52% rename from game/commander/tasks/compound/attackgarrisons.py rename to game/commander/tasks/compound/attackbattlepositions.py index 9f029cfb..2286a341 100644 --- a/game/commander/tasks/compound/attackgarrisons.py +++ b/game/commander/tasks/compound/attackbattlepositions.py @@ -5,8 +5,8 @@ from game.commander.theaterstate import TheaterState from game.htn import CompoundTask, Method -class AttackGarrisons(CompoundTask[TheaterState]): +class AttackBattlePositions(CompoundTask[TheaterState]): def each_valid_method(self, state: TheaterState) -> Iterator[Method[TheaterState]]: - for garrisons in state.enemy_garrisons.values(): - for garrison in garrisons.in_priority_order: - yield [PlanBai(garrison)] + for battle_positions in state.enemy_battle_positions.values(): + for battle_position in battle_positions.in_priority_order: + yield [PlanBai(battle_position)] diff --git a/game/commander/tasks/compound/nextaction.py b/game/commander/tasks/compound/nextaction.py index 33a1503c..56c6bad2 100644 --- a/game/commander/tasks/compound/nextaction.py +++ b/game/commander/tasks/compound/nextaction.py @@ -5,7 +5,7 @@ from game.commander.tasks.compound.attackairinfrastructure import ( AttackAirInfrastructure, ) from game.commander.tasks.compound.attackbuildings import AttackBuildings -from game.commander.tasks.compound.attackgarrisons import AttackGarrisons +from game.commander.tasks.compound.attackbattlepositions import AttackBattlePositions from game.commander.tasks.compound.capturebases import CaptureBases from game.commander.tasks.compound.defendbases import DefendBases from game.commander.tasks.compound.degradeiads import DegradeIads @@ -28,7 +28,7 @@ class PlanNextAction(CompoundTask[TheaterState]): yield [CaptureBases()] yield [DefendBases()] yield [InterdictReinforcements()] - yield [AttackGarrisons()] + yield [AttackBattlePositions()] yield [AttackAirInfrastructure(self.aircraft_cold_start)] yield [AttackBuildings()] yield [DegradeIads()] diff --git a/game/commander/tasks/primitive/airassault.py b/game/commander/tasks/primitive/airassault.py index 575536bf..48a59a97 100644 --- a/game/commander/tasks/primitive/airassault.py +++ b/game/commander/tasks/primitive/airassault.py @@ -14,7 +14,7 @@ class PlanAirAssault(PackagePlanningTask[ControlPoint]): if self.target not in state.air_assault_targets: return False if self.capture_blocked(state): - # Do not task if there are enemy garrisons blocking the capture + # Do not task if there are enemy battle_positions blocking the capture return False if not self.target_area_preconditions_met(state): # Do not task if air defense is present in the target area @@ -22,8 +22,8 @@ class PlanAirAssault(PackagePlanningTask[ControlPoint]): return super().preconditions_met(state) def capture_blocked(self, state: TheaterState) -> bool: - garrisons = state.enemy_garrisons[self.target] - return len(garrisons.blocking_capture) > 0 + battle_positions = state.enemy_battle_positions[self.target] + return len(battle_positions.blocking_capture) > 0 def apply_effects(self, state: TheaterState) -> None: state.air_assault_targets.remove(self.target) diff --git a/game/commander/tasks/primitive/bai.py b/game/commander/tasks/primitive/bai.py index 33ba74af..a06c151e 100644 --- a/game/commander/tasks/primitive/bai.py +++ b/game/commander/tasks/primitive/bai.py @@ -11,14 +11,14 @@ from game.ato.flighttype import FlightType @dataclass class PlanBai(PackagePlanningTask[VehicleGroupGroundObject]): def preconditions_met(self, state: TheaterState) -> bool: - if not state.has_garrison(self.target): + if not state.has_battle_position(self.target): 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.eliminate_garrison(self.target) + state.eliminate_battle_position(self.target) def propose_flights(self) -> None: self.propose_flight(FlightType.BAI, 2) diff --git a/game/commander/tasks/primitive/breakthroughattack.py b/game/commander/tasks/primitive/breakthroughattack.py index f6c184f8..a67a812e 100644 --- a/game/commander/tasks/primitive/breakthroughattack.py +++ b/game/commander/tasks/primitive/breakthroughattack.py @@ -14,14 +14,14 @@ class BreakthroughAttack(FrontLineStanceTask): def have_sufficient_front_line_advantage(self) -> bool: return self.ground_force_balance >= 2.0 - def opposing_garrisons_eliminated(self, state: TheaterState) -> bool: - garrisons = state.enemy_garrisons[self.enemy_cp] - return not bool(garrisons.blocking_capture) + def opposing_battle_positions_eliminated(self, state: TheaterState) -> bool: + battle_positions = state.enemy_battle_positions[self.enemy_cp] + return not bool(battle_positions.blocking_capture) def preconditions_met(self, state: TheaterState) -> bool: if not super().preconditions_met(state): return False - return self.opposing_garrisons_eliminated(state) + return self.opposing_battle_positions_eliminated(state) def apply_effects(self, state: TheaterState) -> None: super().apply_effects(state) diff --git a/game/commander/theaterstate.py b/game/commander/theaterstate.py index 765b21b8..cf6c34a0 100644 --- a/game/commander/theaterstate.py +++ b/game/commander/theaterstate.py @@ -7,7 +7,7 @@ from collections.abc import Iterator from dataclasses import dataclass from typing import Optional, TYPE_CHECKING, Union -from game.commander.garrisons import Garrisons +from game.commander.battlepositions import BattlePositions from game.commander.objectivefinder import ObjectiveFinder from game.db import GameDb from game.ground_forces.combat_stance import CombatStance @@ -56,7 +56,7 @@ class TheaterState(WorldState["TheaterState"]): enemy_convoys: list[Convoy] enemy_shipping: list[CargoShip] enemy_ships: list[NavalGroundObject] - enemy_garrisons: dict[ControlPoint, Garrisons] + enemy_battle_positions: dict[ControlPoint, BattlePositions] oca_targets: list[ControlPoint] strike_targets: list[TheaterGroundObject] enemy_barcaps: list[ControlPoint] @@ -87,11 +87,11 @@ class TheaterState(WorldState["TheaterState"]): self.enemy_ships.remove(target) self._rebuild_threat_zones() - def has_garrison(self, target: VehicleGroupGroundObject) -> bool: - return target in self.enemy_garrisons[target.control_point] + def has_battle_position(self, target: VehicleGroupGroundObject) -> bool: + return target in self.enemy_battle_positions[target.control_point] - def eliminate_garrison(self, target: VehicleGroupGroundObject) -> None: - self.enemy_garrisons[target.control_point].eliminate(target) + def eliminate_battle_position(self, target: VehicleGroupGroundObject) -> None: + self.enemy_battle_positions[target.control_point].eliminate(target) def ammo_dumps_at( self, control_point: ControlPoint @@ -119,8 +119,9 @@ class TheaterState(WorldState["TheaterState"]): enemy_convoys=list(self.enemy_convoys), enemy_shipping=list(self.enemy_shipping), enemy_ships=list(self.enemy_ships), - enemy_garrisons={ - cp: dataclasses.replace(g) for cp, g in self.enemy_garrisons.items() + enemy_battle_positions={ + cp: dataclasses.replace(g) + for cp, g in self.enemy_battle_positions.items() }, oca_targets=list(self.oca_targets), strike_targets=list(self.strike_targets), @@ -128,7 +129,7 @@ class TheaterState(WorldState["TheaterState"]): threat_zones=self.threat_zones, # Persistent properties are not copied. These are a way for failed subtasks # to communicate requirements to other tasks. For example, the task to - # attack enemy garrisons might fail because the target area has IADS + # attack enemy battle_positions might fail because the target area has IADS # protection. In that case, the preconditions of PlanBai would fail, but # would add the IADS that prevented it from being planned to the list of # IADS threats so that DegradeIads will consider it a threat later. @@ -171,8 +172,9 @@ class TheaterState(WorldState["TheaterState"]): enemy_convoys=list(finder.convoys()), enemy_shipping=list(finder.cargo_ships()), enemy_ships=list(finder.enemy_ships()), - enemy_garrisons={ - cp: Garrisons.for_control_point(cp) for cp in ordered_capturable_points + enemy_battle_positions={ + cp: BattlePositions.for_control_point(cp) + for cp in ordered_capturable_points }, oca_targets=list(finder.oca_targets(min_aircraft=20)), strike_targets=list(finder.strike_targets()),