Class Princess

All Implemented Interfaces:
IClient
Direct Known Subclasses:
Caspar

public class Princess extends BotClient
  • Field Details

    • DISTANCE_TO_WAYPOINT

      public static final int DISTANCE_TO_WAYPOINT
      Distance to the waypoint to consider for considering the waypoint reached
      See Also:
  • Constructor Details

    • Princess

      public Princess(String name, String host, int port)
      Constructor - initializes a new instance of the Princess bot.
      Parameters:
      name - The display name.
      host - The host address to which to connect.
      port - The port on the host where to connect.
  • Method Details

    • createPrincess

      public static Princess createPrincess(String name, String host, int port, BehaviorSettings behavior)
      Returns a new Princess Bot with the given behavior and name, configured for the given host and port. The new Princess Bot outputs its settings to its own LOGGER.
    • startPrecognition

      public void startPrecognition()
      Helper method to start the pre-cognition. This is extracted from the initializer to allow for sub-classing of Princess and remove the possibility that it'll start before a sub-class finishes initializing.
    • getArtilleryTargetingControl

      public ArtilleryTargetingControl getArtilleryTargetingControl()
      Lazy-loading accessor for the artillery targeting control.
      Returns:
      ArtilleryTargetingControl
    • isAtmosphericAerospace

      protected boolean isAtmosphericAerospace(Entity entity)
      Whether this unit is flying under the atmospheric aerospace rules - over a ground mapsheet or on a low-altitude map.

      Excludes space, which has no altitude and therefore no dead zone, and excludes vector movement, which PathRanker.PathRankerType.NewtonianAerospace already handles.

      Parameters:
      entity - the unit to test
      Returns:
      true if the unit is an airborne aerospace unit in an atmosphere
    • getFallBack

      public boolean getFallBack()
    • pickTagTarget

      protected int pickTagTarget(GameCFREvent evt)
      Picks a tag target based on the data contained within the given GameCFREvent Expects the event to have some tag targets and tag target types.
      Overrides:
      pickTagTarget in class BotClient
    • setFleeBoard

      public void setFleeBoard(boolean fleeBoard, String reason)
      Sets whether Princess-controlled units are allowed to flee off the board once they reach their destination edge.
      Parameters:
      fleeBoard - true if units should leave the board when they reach their destination edge.
      reason - The reason for the change, used for logging.
    • getFireControlState

      public FireControlState getFireControlState()
    • getPathRankerState

      public PathRankerState getPathRankerState()
    • getMaxWeaponRange

      public int getMaxWeaponRange(Entity entity)
    • getMaxWeaponRange

      public int getMaxWeaponRange(Entity entity, boolean airborneTarget)
      Parameters:
      entity - Entity we're checking
      airborneTarget - Whether the potential target is in the air, only relevant for aircraft shooting at other aircraft on ground maps.
      Returns:
      maximum weapon range for the given entity. Cached version of entity.getMaxWeaponRange()
    • setFallBack

      public void setFallBack(boolean fallBack, String reason)
    • getHoldPosition

      public boolean getHoldPosition()
      Returns:
      true if the bot has been ordered to hold position (units stay where they are).
    • setHoldPosition

      public void setHoldPosition(boolean holdPosition)
      Orders the bot to hold position: its units stay where they are during the movement phase (they still fight from their current location and may turn in place to face the enemy) until the hold is lifted. Airborne units are exempt, as they cannot legally stand still.
      Parameters:
      holdPosition - true to hold position, false to resume normal movement.
    • getAerospaceFocus

      public AerospaceFocus getAerospaceFocus()
      Returns:
      the standing aerospace focus order, AerospaceFocus.AUTO when none has been given.
    • setAerospaceFocus

      public void setAerospaceFocus(AerospaceFocus aerospaceFocus)
      Sets the flight's standing order: press the air battle, support the ground force, or AUTO to let the doctrine weigh both halves itself. A battle order rather than saved configuration - it is not part of behavior settings and resets with the bot client.
      Parameters:
      aerospaceFocus - the focus to fly under
    • getAerospaceGroundOrder

      public AerospaceGroundOrder getAerospaceGroundOrder()
      Returns:
      the standing ground-or-sky order for DropShips and small craft, AerospaceGroundOrder.AUTO when none has been given.
    • setAerospaceGroundOrder

      public void setAerospaceGroundOrder(AerospaceGroundOrder aerospaceGroundOrder)
      Orders the bot's DropShips and small craft to lift off, land, or hold their current domain. Fighters are unaffected. A battle order rather than saved configuration - it resets with the bot client.
      Parameters:
      aerospaceGroundOrder - the order to follow
    • getShootAndScoot

      public boolean getShootAndScoot()
      Returns:
      true if "shoot and scoot" is enabled, letting a threatened artillery unit displace to regain its standoff instead of holding in place
    • setShootAndScoot

      public void setShootAndScoot(boolean shootAndScoot)
      Enables or disables "shoot and scoot" for artillery. While the bot is holding position, an artillery unit with usable ammo that has an enemy inside its minimum effective range breaks the hold and displaces toward safety to regain standoff, instead of sitting still and being overrun. Only the threatened artillery unit moves; every other unit keeps holding.
      Parameters:
      shootAndScoot - true to let threatened artillery displace, false for a pure hold.
    • getShootAndScootHex

      @Nullable public Coords getShootAndScootHex()
      Returns:
      The hex the bot's artillery should fall back to under shoot-and-scoot, or null to auto-displace away from the nearest enemy
    • setShootAndScootHex

      public void setShootAndScootHex(@Nullable Coords shootAndScootHex)
      Designates a fallback hex for shoot-and-scoot: threatened artillery heads to this hex (which may take several turns) and then holds and fires from there, instead of auto-displacing. Setting a hex also enables shoot-and-scoot. Passing null clears the hex and reverts to auto-displacement.
      Parameters:
      shootAndScootHex - The fallback hex, or null to clear it
    • getDesignatedTagTargets

      public Set<Integer> getDesignatedTagTargets()
      Returns:
      The set of enemy unit IDs the player has designated for the bot to TAG (for the player's own homing artillery). The bot's TAG fire prefers these targets when they are hittable.
    • addDesignatedTagTarget

      public void addDesignatedTagTarget(int targetId)
      Designates an enemy unit for the bot to put its TAG on, so a player's homing artillery has a known designation.
      Parameters:
      targetId - The enemy unit ID to TAG
    • clearDesignatedTagTargets

      public void clearDesignatedTagTargets()
      Clears all designated TAG targets, returning the bot's TAG to autonomous best-hit targeting.
    • showArtilleryHeatMap

      public void showArtilleryHeatMap(Map<Coords,Princess.HeatMapMarker> predictedImpacts, Map<Coords,Princess.HeatMapMarker> chosenTargets, int boardId)
      Optionally paints this bot's artillery heat map on the board for testing: a cold-to-hot color fill at each hex an enemy is predicted to advance to (navy blue for a single enemy converging, up to crimson red for many, so the map cools as units are destroyed), and a crosshair at each hex it is firing at. A predicted hex shows the prediction's turn; a firing hex counts down the turns until the rounds land. Only acts when the local client has the "Show Bot Artillery Heat Map" advanced testing setting on; the markers are visible to all and clear themselves each round. No-op for a headless bot (no GUI preferences).
      Parameters:
      predictedImpacts - The hexes enemies were predicted to advance to, mapped to their heat-map marker
      chosenTargets - The hexes the bot is firing at (this turn's shots plus in-flight shells), mapped to their heat-map marker (turn = countdown to impact)
      boardId - The board the hexes are on
    • setBehaviorSettings

      public void setBehaviorSettings(BehaviorSettings behaviorSettings)
      Description copied from class: BotClient
      Applies the given behavior settings to this bot. Implementations decide how the settings take effect (for example, re-initializing scorers or notifying the server) and are responsible for storing them in BotClient.behaviorSettings.
      Specified by:
      setBehaviorSettings in class BotClient
      Parameters:
      behaviorSettings - the new behavior settings to apply
    • getUnitBehaviorTracker

      public UnitBehavior getUnitBehaviorTracker()
    • getStrategicBuildingTargets

      public Set<Coords> getStrategicBuildingTargets()
    • hasStrategicBuildingTargets

      public boolean hasStrategicBuildingTargets(Coords coords)
    • addStrategicBuildingTarget

      public void addStrategicBuildingTarget(Coords coords)
    • removeStrategicBuildingTarget

      public void removeStrategicBuildingTarget(Coords coords)
    • getPriorityUnitTargets

      public Set<Integer> getPriorityUnitTargets()
    • getAppropriateTarget

      public Targetable getAppropriateTarget(Coords strategicTarget)
    • getAppropriateTarget

      public Targetable getAppropriateTarget(Coords strategicTarget, int boardId)
    • calculateArtyAutoHitHexes

      protected Vector<BoardLocation> calculateArtyAutoHitHexes()
      Specified by:
      calculateArtyAutoHitHexes in class BotClient
    • initTargeting

      protected void initTargeting()
      Overrides:
      initTargeting in class BotClient
    • calculateDeployment

      protected void calculateDeployment()
      Specified by:
      calculateDeployment in class BotClient
    • getFirstValidCoords

      @Nullable protected Coords getFirstValidCoords(Entity deployedUnit, List<Coords> possibleDeployCoords)
      Returns the first set of valid deployment coordinates for the given unit out of the given deployment coordinates. It's possible to return null, which indicates that there are no valid hexes for the given unit to deploy into.
      Overrides:
      getFirstValidCoords in class BotClient
    • rankKernelAroundCoords

      protected double rankKernelAroundCoords(MovePath start, Entity deployedUnit, int radius, BasicPathRanker ranker)
    • prioritizeDeploymentCoords

      protected List<Coords> prioritizeDeploymentCoords(Entity deployedUnit, List<Coords> possibleDeployCoords)
      Orders the candidate deployment hexes that rankDeploymentCoords(Entity, List) will scan.

      This matters more than it looks. The candidate list arrives shuffled, and the scan below stops after roughly twenty entries, so whatever sits at the front of this list is very nearly the whole choice. Princess returns it unchanged: each unit is placed on terrain merit alone, with no regard for where the rest of the force went.

      Parameters:
      deployedUnit - the unit being placed
      possibleDeployCoords - legal deployment hexes
      Returns:
      the hexes to scan, in the order to scan them
    • rankDeploymentCoords

      protected Coords rankDeploymentCoords(Entity deployedUnit, List<Coords> possibleDeployCoords)
    • calculateFiringTurn

      protected void calculateFiringTurn()
      Specified by:
      calculateFiringTurn in class BotClient
    • calculateTargetingOffBoardTurn

      protected void calculateTargetingOffBoardTurn()
      Calculates the targeting/ off board turn This includes firing TAG and non-direct-fire artillery
      Overrides:
      calculateTargetingOffBoardTurn in class BotClient
    • calcAmmoConservation

      protected Map<WeaponMounted,Double> calcAmmoConservation(Entity shooter)
    • calculatePointBlankShot

      protected Vector<EntityAction> calculatePointBlankShot(int firingEntityID, int targetID)
      Worker method that calculates a point blank shot action vector given a firing entity ID and a target ID.
      Overrides:
      calculatePointBlankShot in class BotClient
      Parameters:
      firingEntityID - the ID of the entity taking the point blank shot
      targetID - the ID of the entity being shot at potentially
    • calculateMoveIndex

      protected double calculateMoveIndex(Entity entity, StringBuilder msg)
      Calculates the move index for the given unit. In general, faster units and units closer to the enemy should move before others. Additional modifiers for being prone, stealth-ed, unit type and so on are also factored in.
      Parameters:
      entity - The unit to be indexed.
      Returns:
      The movement index of this unit. May be positive or negative. Higher index values should move first.
    • getEnhancedTargetingControl

      @Deprecated(since="0.51.0", forRemoval=true) public boolean getEnhancedTargetingControl()
      Deprecated, for removal: This API element is subject to removal in a future version.
    • setEnableEnhancedTargeting

      @Deprecated(since="0.51.0", forRemoval=true) public void setEnableEnhancedTargeting(boolean newSetting)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • resetEnhancedTargeting

      public void resetEnhancedTargeting(boolean enable)
      Sets all enhanced targeting controls to default values and optionally enables its use
      Parameters:
      enable - true to immediately enable enhanced targeting features after reset
    • setEnhancedTargetingTargetTypes

      @Deprecated(since="0.51.0", forRemoval=true) public void setEnhancedTargetingTargetTypes(List<Integer> newTargetTypes)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Swap out current set of valid enhanced targeting target types for a new set. Automatically removes certain types that will never apply, such as infantry.
      Parameters:
      newTargetTypes - List of UnitType constants, may be empty or null to clear
    • setEnhancedTargetingAttackerTypes

      @Deprecated(since="0.51.0", forRemoval=true) public void setEnhancedTargetingAttackerTypes(List<Integer> newAttackerTypes)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Swap out current set of valid enhanced targeting attacker types for a new set
      Parameters:
      newAttackerTypes - List of UnitType constants, may be empty or null to clear
    • seeEnhancedTargetingTargetTypes

      @Deprecated(since="0.51.0", forRemoval=true) public List<Integer> seeEnhancedTargetingTargetTypes()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Returns a copy of the list of valid enhanced targeting target types
      Returns:
      list of UnitType constants, or empty list
    • seeEnhancedTargetingAttackerTypes

      @Deprecated(since="0.51.0", forRemoval=true) public List<Integer> seeEnhancedTargetingAttackerTypes()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Returns a copy of the list of valid enhanced targeting attacker types
      Returns:
      list of UnitType constants, or empty list
    • isValidEnhancedTargetingTarget

      public boolean isValidEnhancedTargetingTarget(int testType)
      Checks if the supplied unit type is considered a valid target for enhanced targeting
      Parameters:
      testType - UnitType constant
      Returns:
      true, if unit is a valid target for enhanced targeting
    • isValidEnhancedTargetingAttacker

      public boolean isValidEnhancedTargetingAttacker(int testType)
      Checks if the supplied unit type is considered a valid attacker for enhanced targeting
      Parameters:
      testType - UnitType constant
      Returns:
      true, if unit is a valid attacker for enhanced targeting
    • getAllowCalledShotsOnImmobile

      @Deprecated(since="0.51.0", forRemoval=true) public boolean getAllowCalledShotsOnImmobile()
      Deprecated, for removal: This API element is subject to removal in a future version.
    • setAllowCalledShotsOnImmobile

      @Deprecated(since="0.51.0", forRemoval=true) public void setAllowCalledShotsOnImmobile(boolean newSetting)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • getPartialCoverEnhancedTargeting

      @Deprecated(since="0.51.0", forRemoval=true) public boolean getPartialCoverEnhancedTargeting()
      Deprecated, for removal: This API element is subject to removal in a future version.
    • setPartialCoverEnhancedTargeting

      @Deprecated(since="0.51.0", forRemoval=true) public void setPartialCoverEnhancedTargeting(boolean newSetting)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Controls whether enhanced targeting will be used against targets with partial cover from the shooter. Use with caution as this can result in situations like aiming for a location which is protected by intervening cover.
      Parameters:
      newSetting - true, to allow aimed/called shots against targets with partial cover
    • checkForEnhancedTargeting

      protected boolean checkForEnhancedTargeting(Entity shooter, Targetable targetable, int cover)
      Determine if a shooter should consider using enhanced targeting - aimed or called shots - against a given target. This includes some basic filtering for unit types and equipment such targeting computers.
      Parameters:
      shooter - Entity doing the shooting
      targetable - Hex, Building, or Entity being shot at (Enhanced Targeting only works on the last one)
      cover - LosEffects constant for partial cover, derived from ToHitData.getCover()
      Returns:
      true, if aimed or called shots should be checked
    • getAimedShotLocation

      protected int getAimedShotLocation(Targetable target, FiringPlan planOfAttack, boolean rearAttack, boolean includeHead)
      Determine which location to aim for on a general target. Returned location constant is relative to the provided target type. Currently only supports aimed shots against Meks.
      Parameters:
      target - Entity being shot at
      planOfAttack - Proposed attacks against target
      rearAttack - true if attacking from rear arc
      includeHead - true if the head is a valid location, ignored for non-Mek targets
      Returns:
      location constant to aim for, with the LOC_NONE constant indicating no suitable location
    • getCalledShotDirection

      protected int getCalledShotDirection(Targetable target, int attackSide, FiringPlan planOfAttack)
      Determine which direction to make a called shot - left, right, high, or low. Some target types only support calling shots left or right. Currently only supports called shots against Meks.
      Parameters:
      target - Entity being shot at
      attackSide - ToHitData SIDE_ constant, indicating attack direction relative to target
      planOfAttack - Proposed attacks against target
      Returns:
      CalledShot constant indicating which direction to call, may return CalledShot.CALLED_NONE.
    • calculateAimedShotLocation

      protected int calculateAimedShotLocation(Mek target, List<WeaponFireInfo> aimedShots, boolean rearAttack, boolean includeHead)
      Determine which location to aim for on a Mek. Prioritizes torsos and legs, and ignores destroyed locations. Prefers right to left, given that most non-symmetrical Meks are 'right-handed'.
      Parameters:
      target - Mek being shot at
      aimedShots - Proposed attacks against target
      rearAttack - true if attacking from the rear arc
      includeHead - true to include the head as a valid location
      Returns:
      Mek constant for location to shoot, or Mek.LOC_NONE for none
    • calculateCalledShotDirection

      protected int calculateCalledShotDirection(Mek target, int attackSide, List<WeaponFireInfo> calledShots)
      Determine which direction to make a called shot against a Mek - left, right, high, or low. Shots into a side arc will be called to become rear shots. Shots to the front or rear will call high or low based on how many locations have minimal armor.
      Parameters:
      target - Mek being shot at
      attackSide - ToHitData SIDE_ constant, indicating attack direction relative to target
      calledShots - Proposed attacks against target parameter
      Returns:
      CalledShot constant indicating which direction to call, may return CalledShot.CALLED_NONE.
    • setAttackAsAimedOrCalled

      protected void setAttackAsAimedOrCalled(WeaponFireInfo shot, int aimLocation, int calledShotDirection, int destructionThreshold)
      If a shot meets criteria, set it as aimed or called. aimLocation and calledShotDirection are not mutually exclusive - if both are provided, weapons which cannot make an aimed shot will make a called shot instead
      Parameters:
      shot - Single-weapon attack action
      aimLocation - Mek LOC_ constant with aiming location
      destructionThreshold - how much damage to completely destroy the location
    • calculateMoveTurn

      @Nullable protected MovePath calculateMoveTurn()
      Description copied from class: BotClient
      Determines which entity should be moved next and then calls to BotClient.continueMovementFor(Entity) with that entity.
      Specified by:
      calculateMoveTurn in class BotClient
      Returns:
      The calculated move path.
    • calculatePhysicalTurn

      @Nullable protected PhysicalOption calculatePhysicalTurn()
      Specified by:
      calculatePhysicalTurn in class BotClient
    • calculatePreEndDeclarationsTurn

      protected void calculatePreEndDeclarationsTurn()
      Description copied from class: BotClient
      Calculate what to do during the PRE_END_DECLARATIONS phase. This phase allows infantry to initiate building/vessel combat.
      Specified by:
      calculatePreEndDeclarationsTurn in class BotClient
    • calculateInfantryVsInfantryCombatTurn

      protected void calculateInfantryVsInfantryCombatTurn()
      Description copied from class: BotClient
      Calculate what to do during the INFANTRY_VS_INFANTRY_COMBAT phase. This phase allows infantry to reinforce or withdraw from building/vessel combat.
      Specified by:
      calculateInfantryVsInfantryCombatTurn in class BotClient
    • continueMovementFor

      protected MovePath continueMovementFor(Entity entity)
      Description copied from class: BotClient
      Calculates the full MovePath for the given Entity.
      Specified by:
      continueMovementFor in class BotClient
      Parameters:
      entity - The entity who is to move.
      Returns:
      The calculated move path.
    • initFiring

      protected void initFiring()
      Specified by:
      initFiring in class BotClient
    • getMovePathsAndSetNecessaryTargets

      public List<MovePath> getMovePathsAndSetNecessaryTargets(Entity mover, boolean forceMoveToContact)
      Function with side effects. Retrieves the move path collection we want the entity to consider. Sometimes it's the standard "circle", sometimes it's pruned long-range movement paths
    • updateEntityState

      public void updateEntityState(@Nullable Entity entity)
      Update the various state trackers for a specific entity. Useful to call when receiving an entity update packet
    • initMovement

      protected void initMovement()
      Specified by:
      initMovement in class BotClient
    • initialize

      public void initialize()
      Specified by:
      initialize in class BotClient
    • initializeFireControls

      public void initializeFireControls()
      Initialize the fire controls.
    • registerFireControl

      protected void registerFireControl(FireControl.FireControlType fireControlType, FireControl fireControl)
      Wiring seam for subclasses (CASPAR): replaces the registered fire control of the given type. Call after super.initializeFireControls(). Mirrors registerPathRanker(megamek.client.bot.princess.PathRanker.PathRankerType, megamek.client.bot.princess.BasicPathRanker).
      Parameters:
      fireControlType - the fire control slot to replace
      fireControl - the replacement fire control
    • initializePathRankers

      public void initializePathRankers()
      Initialize the possible path rankers. Has a dependency on the fire controls being initialized.
    • registerPathRanker

      protected void registerPathRanker(PathRanker.PathRankerType rankerType, BasicPathRanker pathRanker)
      Wiring seam for subclasses (CASPAR): replaces the registered path ranker of the given type, wiring the replacement to the precognition path enumerator the same way the stock rankers are wired. Call after super.initializePathRankers().
      Parameters:
      rankerType - the ranker slot to replace
      pathRanker - the replacement ranker
    • aeroGroundPathFinder

      protected AeroGroundPathFinder aeroGroundPathFinder(Game game)
      Factory seam for subclasses (CASPAR): builds the path finder used for airborne aerodyne units flying over a ground mapsheet.

      Unlike the low-altitude finder, the stock ground finder drives every path it generates to a single altitude, so a ranker never gets an altitude to choose between. Overriding this is the only way to put that choice back without changing what Princess generates.

      Parameters:
      game - the current game
      Returns:
      the path finder to enumerate ground-mapsheet aerospace movement with
    • computeTeamTagUtility

      public int computeTeamTagUtility(Targetable te, int damage)
      Reduce utility of TAGging something if we're already trying. Update the utility if it's better, otherwise try to dissuade the next attacker.
    • computeGuidedWeapons

      public List<WeaponMounted> computeGuidedWeapons(Entity entityToFire, Coords location)
      Because Aerospace units can either TAG _or_ attack with their weapons, we want every friendly TAG-equipped Aero (and possibly others) to know about all the possible incoming Homing or IF attacks that could take advantage of their TAGs, for later calculations.

      Steps are: 1. All relevant guidable attacks (within range of the target) are added to a list. 1a. All Homing Weapons landing this turn are added to the list. 1b. All IF-capable, Semi-Guided, and Homing weapons that have not yet fired but _could_ are added as well. 2. Each attacker-target location pair's expected homing/indirect fire damage is cached for later re-use. 3. During the Indirect phase, when TAG attacks are announced, relevant units can use this info to decide whether they want to TAG or reserve their activation for actual attacks. 4. All info is cleared at the start of the next turn.

    • refreshCrippledUnits

      public void refreshCrippledUnits()
      Load the list of units considered crippled at the time the bot was loaded or the beginning of the turn, whichever is the more recent.
    • die

      public void die()
      Description copied from class: AbstractClient
      Shuts down threads and sockets
      Specified by:
      die in interface IClient
      Overrides:
      die in class AbstractClient
    • processChat

      protected void processChat(GamePlayerChatEvent ge)
      Specified by:
      processChat in class BotClient
    • calculateAdjustment

      public static int calculateAdjustment(String ticks)
    • checkMorale

      protected void checkMorale()
      Specified by:
      checkMorale in class BotClient
    • getHonorUtil

      public IHonorUtil getHonorUtil()
    • getSpinUpThreshold

      public int getSpinUpThreshold()
      Lazy-loaded calculation of the "to-hit target number" threshold, below which rapid fire autocannon will fire multiple shots. More aggressive behavior (left on the Self Preservation slider) start at TN 11 and under, while less aggressive behavior (right on the slider) start at 4 and under.
    • resetSpinUpThreshold

      @Deprecated(since="0.51.0", forRemoval=true) public void resetSpinUpThreshold()
      Deprecated, for removal: This API element is subject to removal in a future version.
    • endOfTurnProcessing

      public void endOfTurnProcessing()
      Overrides:
      endOfTurnProcessing in class BotClient
    • handlePacket

      protected void handlePacket(Packet c)
      Description copied from class: AbstractClient
      This method is the starting point that handles all received Packets. This method should only be overridden in very special cases such as in Princess to call Precognition.
      Overrides:
      handlePacket in class AbstractClient
      Parameters:
      c - The packet to handle
    • sendLoadGame

      public void sendLoadGame(File f)
      sends a load game file to the server
      Overrides:
      sendLoadGame in class Client
    • sendPrincessSettings

      public void sendPrincessSettings()
    • sendDishonoredData

      public void sendDishonoredData()
      Reports to the server which players this bot currently considers dishonored, so that clients can warn a human player before committing an action that would newly dishonor them. The reported set is fully resolved - it already accounts for pirates having no honor to give - so a receiving client only needs a membership test.
    • sendBotSettingsToServer

      protected void sendBotSettingsToServer()
      Description copied from class: Client
      Hook invoked when the server greets this client, allowing a bot client to push its behavior settings to the server. Non-bot clients have no settings to send, so this default implementation does nothing; bot clients override it.
      Overrides:
      sendBotSettingsToServer in class Client
    • disconnected

      protected void disconnected()
      Description copied from class: AbstractClient
      The client has become disconnected from the server
      Overrides:
      disconnected in class AbstractClient
    • shouldAbandon

      protected boolean shouldAbandon(Entity entity)
    • abandonShipOneUnit

      protected void abandonShipOneUnit(Entity movingEntity, Vector<Transporter> transporters, MovePath path)
    • flagManualAMSUse

      public void flagManualAMSUse(int id)
      Flag an entity as having used manual AMS this round
    • usedManualAMS

      public boolean usedManualAMS(int id)
    • clearManualAMSIds

      public void clearManualAMSIds()
      Clear the manual AMS tracking list
    • getEnemyHotSpots

      public List<Coords> getEnemyHotSpots()
      Get a list of all hot spots (positions of high activity) for opposing units
    • getFriendlyHotSpot

      @Deprecated(since="0.51.0", forRemoval=true) public Coords getFriendlyHotSpot()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Get the best hot spot (positions of high activity) for friendly units
      Returns:
      Coords with high friendly activity; may return null
    • getFriendlyHotSpot

      public Coords getFriendlyHotSpot(Coords testPosition)
      Get the nearest top-rated hot spot for friendly units
    • initEnemyHeatMaps

      protected void initEnemyHeatMaps()
      Set up heat maps to track enemy unit positions over time
    • initFriendlyHeatMap

      protected void initFriendlyHeatMap()
      Set up heat map to track friendly units over time
    • updateEnemyHeatMaps

      protected void updateEnemyHeatMaps()
      Update the heat maps with known enemy unit positions, then apply decay
    • updateFriendlyHeatMap

      protected void updateFriendlyHeatMap()
      Update the heat map with allied unit positions (entities controlled by this bot have already been processed as they move), then apply decay
    • sendChat

      public void sendChat(String message, org.apache.logging.log4j.Level logLevel)
    • receiveEntityUpdate

      public void receiveEntityUpdate(Packet packet) throws InvalidPacketDataException
      Override for the 'receive entity update' handler Updates internal state in addition to base client functionality
      Overrides:
      receiveEntityUpdate in class BotClient
      Throws:
      InvalidPacketDataException
    • getSwarmContext

      public SwarmContext getSwarmContext()
    • getEnemyTracker

      public EnemyTracker getEnemyTracker()
    • getCoverageValidator

      public CoverageValidator getCoverageValidator()
    • getSwarmCenterManager

      @Deprecated(since="0.51.0", forRemoval=true) public SwarmCenterManager getSwarmCenterManager()
      Deprecated, for removal: This API element is subject to removal in a future version.
    • postMovementProcessing

      protected void postMovementProcessing()
      Specified by:
      postMovementProcessing in class BotClient
    • getArtilleryCommandAndControl

      public ArtilleryCommandAndControl getArtilleryCommandAndControl()
    • revealEntities

      protected void revealEntities(int movedEntityID)
      Given an entity that just moved, decide if I should reveal any entities in response
      Overrides:
      revealEntities in class BotClient
    • decideToRerollInitiative

      protected boolean decideToRerollInitiative()
      Determines whether Princess should reroll initiative using the Tactical Genius special ability.

      The decision is based on:

      • Whether Tactical Genius is available to the player
      • Whether it has already been used this round
      • The probability that rerolling will improve the net initiative outcome against enemies

      Princess will only reroll if currently losing more initiative comparisons than winning, and if the probability of improvement exceeds the configured threshold.

      Overrides:
      decideToRerollInitiative in class BotClient
      Returns:
      true if Tactical Genius should be used to reroll initiative