Class UtilityPathRanker

All Implemented Interfaces:
IPathRanker

public class UtilityPathRanker extends BasicPathRanker
  • Constructor Details

    • UtilityPathRanker

      public UtilityPathRanker(Princess owningPrincess)
  • Method Details

    • calculateAlliesCenter

      @Nullable public Coords calculateAlliesCenter(int myId, @Nullable List<Entity> friends, Game game)
      Overrides:
      calculateAlliesCenter in class PathRanker
    • getBestPath

      @Nullable public RankedPath getBestPath(TreeSet<RankedPath> ps)
      Returns the best path of a list of ranked paths.
      Specified by:
      getBestPath in interface IPathRanker
      Overrides:
      getBestPath in class PathRanker
      Parameters:
      ps - The list of ranked paths to process
      Returns:
      "Best" out of those paths
    • rankPath

      protected RankedPath rankPath(MovePath path, Game game, int maxRange, double fallTolerance, List<Entity> enemies, Coords friendsCoords)
      A path ranking
      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)
    • getBraveryMod

      protected double getBraveryMod(double successProbability, BasicPathRanker.FiringPhysicalDamage damageEstimate, double expectedDamageTaken)
      Calculates bravery modifier of the unit
      Overrides:
      getBraveryMod in class BasicPathRanker
      Parameters:
      successProbability - The probability of success of the move
      damageEstimate - The estimated damage that the unit can do
      expectedDamageTaken - The expected damage that the unit will take
      Returns:
      The bravery modifier score
    • calculateMovementMod

      protected double calculateMovementMod(MovePath pathCopy, Game game)
      Calculates the TMM score of the unit
      Parameters:
      pathCopy - The path to evaluate
      game - The game
      Returns:
      The TMM score
    • calculateFallMod

      protected double calculateFallMod(double successProbability)
    • calculateFacingMod

      protected double calculateFacingMod(MovePath path)
    • calculateAggressionMod

      protected double calculateAggressionMod(Entity movingUnit, MovePath path, double maxRange, Game game)
    • calculateSelfPreservationMod

      protected double calculateSelfPreservationMod(Entity movingUnit, MovePath path, Game game)
      Description copied from class: BasicPathRanker
      Calculates a self-preservation modifier that encourages units to retreat when appropriate.

      This method applies penalties or bonuses based on the unit's movement toward safety:

      • For units in forced withdrawal or moving to a destination, encourages movement toward home edge
      • Applies a significant bonus (BasicPathRanker.ARRIVED_AT_DESTINATION_FACTOR) if the path reaches the home edge
      • Applies a penalty proportional to distance from home edge otherwise

      The method only applies these modifiers when the unit is in forced withdrawal or deliberately moving to a designated location. For normal combat operations, it returns 0 to indicate self-preservation is not a priority factor.

      Overrides:
      calculateSelfPreservationMod in class BasicPathRanker
      Parameters:
      movingUnit - The entity being moved
      path - The movement path being evaluated
      game - The current game state
      Returns:
      A self-preservation modifier value (negative values are better) to be used in path ranking