Class PostureResolver

java.lang.Object
megamek.client.bot.princess.PostureResolver

public class PostureResolver extends Object
Decides each round whether the force is attacking or defending, when the player has left the call to the bot (CombatPosture.AUTO).

The bot reads its posture from two things it already knows. A force that has somewhere to go - a destination edge set in its behavior - is attacking: the mission requires movement, so obstacles are a cost to pay, not a line to hold. Otherwise the enemy's own movement makes the call: an enemy that is closing on the force is coming to fight on our ground, and the right answer is to hold that ground and make them pay for every obstacle on the way in. An enemy holding its distance is not coming, and someone has to make the battle happen, so the force attacks.

The closing test compares the enemy's mean distance to our force against where it stood a few rounds ago, so one unit's jockeying does not flip the whole force's stance, and leaving the defensive takes a much weaker signal than entering it (DEFEND_EXIT_THRESHOLD_HEXES_PER_ROUND) so the stance does not flip-flop while a mutual approach hovers around the entry threshold. Resolution is cached per round: every unit the bot moves in a round moves under the same posture.

  • Constructor Details

    • PostureResolver

      public PostureResolver()
  • Method Details

    • resolutionReason

      public String resolutionReason()
      Returns:
      why the last resolve(megamek.client.bot.princess.BehaviorSettings, int, java.util.List<megamek.common.board.Coords>, java.util.List<megamek.common.board.Coords>) call answered the way it did, in plain words - for the bot to say out loud and for the logs
    • resolve

      public CombatPosture resolve(BehaviorSettings settings, int round, List<Coords> ownPositions, List<Coords> enemyPositions)
      The posture the force fights under this round.
      Parameters:
      settings - the bot's behavior settings; an explicit posture is simply obeyed
      round - the current game round
      ownPositions - positions of the bot's own deployed units
      enemyPositions - positions of the enemy units the bot knows about
      Returns:
      CombatPosture.ATTACK or CombatPosture.DEFEND, never CombatPosture.AUTO
    • resolve

      public CombatPosture resolve(BehaviorSettings settings, int round, List<Coords> ownPositions, List<Coords> enemyPositions, int hexesPerEngagementHex)
      The posture the force fights under this round, measured at a given map scale.

      The closing thresholds are written in engagement hexes a round, which for ground units is simply map hexes. Aerospace units over a ground mapsheet are the exception: a hex there is 30 metres against the 500 of the low-altitude map the aircraft is really flying on (TW p.91), so one velocity point carries it sixteen hexes and a Mek-scale rate of half a hex a round says nothing at all. Dividing by the scale puts both on the same footing, so the doctrine reads the same whatever is flying it.

      Parameters:
      settings - the bot's behavior settings; an explicit posture is simply obeyed
      round - the current game round
      ownPositions - positions of the bot's own deployed units
      enemyPositions - positions of the enemy units the bot knows about
      hexesPerEngagementHex - map hexes that make up one hex at the scale the fight is fought on
      Returns:
      CombatPosture.ATTACK or CombatPosture.DEFEND, never CombatPosture.AUTO