Class InfantryPathRanker

All Implemented Interfaces:
IPathRanker

public class InfantryPathRanker extends BasicPathRanker
  • Constructor Details

    • InfantryPathRanker

      public InfantryPathRanker(Princess princess)
  • Method Details

    • rankPath

      protected RankedPath rankPath(MovePath path, Game game, int maxRange, double fallTolerance, List<Entity> enemies, Coords friendsCoords)
      Description copied from class: BasicPathRanker
      Evaluates and ranks movement paths for MegaMek units based on multiple strategic factors. Returns a utility score where higher values represent more desirable paths.

      The utility score calculation combines several weighted factors:

         utility = -fallMod + braveryMod - aggressionMod - mutualSupportMod + movementMod
                   - crowdingTolerance - facingMod - selfPreservationMod - (utility * offBoardMod)
       

      Key Components:

      • fallMod: Penalty for paths with risk of failing piloting rolls
        • Calculated as pilotingFailure * fallShame
        • Higher values = worse paths (more likely to fall)
      • braveryMod: Reward for paths balancing damage output vs. incoming damage
        • Based on potential damage to enemies vs. expected damage received
        • Higher values = better paths (can do more damage than take)
      • aggressionMod: Penalty for staying far from enemies
        • Calculated as distanceToEnemy * aggressionValue
        • Higher values = worse paths (too far from enemies when aggression is high)
      • mutualSupportMod: Penalty for moving away from friendly units
        • Calculated as distanceToFriends * mutualSupportValue
        • Higher values = worse paths (isolated from allies)
      • facingMod: Penalty for not facing toward enemies
        • Based on facing direction relative to enemies
        • Higher values = worse paths (facing away from threats)
      • selfPreservationMod: Penalty for not moving toward retreat edge when needed
        • Special case: if reaching the home edge, gives a large bonus of ARRIVED_AT_DESTINATION_FACTOR
        • Higher values = worse paths (not retreating when damaged)
      • movementMod: Reward for using movement effectively
        • Based on multiple strategic factors
        • Higher values = better paths (using speed effectively)
      • crowdingTolerance: Penalty for ending in crowded areas
        • Based on nearby threats relative to maximum weapon range
        • Higher values = worse paths (too many enemies nearby)
      • offBoardMod: Penalty for aerospace units at risk of flying off the board
        • Applies as a multiplier to existing penalties
        • Higher values = worse paths (likely to fly off the board)

      The function uses behavior settings like bravery, aggression, and mutual support to adjust the relative importance of these factors based on the AI's configured personality.

      Overrides:
      rankPath in class BasicPathRanker
      Parameters:
      path - The movement path to be evaluated
      game - The current game state
      maxRange - Entity max weapon range
      fallTolerance - a maximum PSR failure chance to be acceptable
      enemies - List of enemy units visible
      friendsCoords - Center of Gravity of friendly units (average coordinate position)
      Returns:
      A double representing the utility/desirability of the path (higher is better)