Class PathRanker

java.lang.Object
megamek.client.bot.princess.PathRanker
All Implemented Interfaces:
IPathRanker
Direct Known Subclasses:
BasicPathRanker

public abstract class PathRanker extends Object implements IPathRanker
  • Constructor Details

    • PathRanker

      public PathRanker(Princess princess)
  • Method Details

    • resolvedPostureFor

      @Nullable protected CombatPosture resolvedPostureFor(Game game, int boardId)
      The posture already resolved for this board this round, or null when none has been.

      Read-only by contract: implementations must not resolve a posture that has not been asked for, since resolving announces it. Overridden by BasicPathRanker; there is nothing to report here.

      Parameters:
      game - the current game
      boardId - the board to report on
      Returns:
      the resolved posture, or null
    • rankPath

      protected abstract RankedPath rankPath(MovePath path, Game game, int maxRange, double fallTolerance, List<Entity> enemies, Coords friendsCoords)
    • rankPaths

      public TreeSet<RankedPath> rankPaths(List<MovePath> movePaths, Game game, int maxRange, double fallTolerance, List<Entity> enemies, List<Entity> friends)
      Specified by:
      rankPaths in interface IPathRanker
    • getBestPath

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

      public void initUnitTurn(Entity unit, Game game)
      Performs initialization to help speed later calls of rankPath for this unit on this turn. Rankers that extend this class should override this function
      Specified by:
      initUnitTurn in interface IPathRanker
    • findClosestEnemy

      public Targetable findClosestEnemy(Entity me, Coords position, Game game)
      Description copied from interface: IPathRanker
      Find the closest enemy to a unit with a path
      Specified by:
      findClosestEnemy in interface IPathRanker
    • findClosestEnemy

      public Targetable findClosestEnemy(Entity me, Coords position, Game game, boolean includeStrategicTargets, int minDistance)
      Find the closest enemy to a unit with a path
      Specified by:
      findClosestEnemy in interface IPathRanker
    • getMovePathSuccessProbability

      protected double getMovePathSuccessProbability(MovePath movePath)
      Calculates the probability that a unit can successfully complete the given movement path.

      This method evaluates all piloting skill rolls required along the path and computes the combined probability of passing all of them. It accounts for:

      • Piloting skill rolls from difficult terrain, elevation changes, etc.
      • MASC failure chances if MASC is activated during the move
      • Supercharger failure chances if a supercharger is used

      The method skips "getting up" and "careful stand" piloting rolls as these are handled separately when evaluating immobile status. Results are cached to avoid redundant calculations during path evaluation.

      The probability is expressed as a value between 0.0 (guaranteed failure) and 1.0 (guaranteed success).

      Parameters:
      movePath - The movement path to evaluate
      Returns:
      The probability (0.0 to 1.0) that all required piloting rolls will succeed
    • calculateMovePathPSRDamage

      protected double calculateMovePathPSRDamage(Entity movingEntity, MovePath path)
      Estimates the most expected damage that a path could cause, given the pilot skill of the path ranker and various conditions.

      XXX Sleet01: add fall pilot damage and skid damage calcs (low-/high-gravity overspeed leg damage is handled below via predictGravityOverspeedDamage(megamek.common.units.Entity, megamek.common.moves.MovePath, megamek.common.rolls.TargetRoll)).

    • getPSRList

      protected List<TargetRoll> getPSRList(MovePath path)
    • distanceToHomeEdge

      public int distanceToHomeEdge(Coords position, int boardId, CardinalEdge homeEdge, Game game)
      Description copied from interface: IPathRanker
      Returns distance to the unit's home edge. Gives the distance to the closest edge
      Specified by:
      distanceToHomeEdge in interface IPathRanker
      Parameters:
      position - Final coordinates of the proposed move.
      boardId - The board on which to look
      homeEdge - Unit's home edge.
      game - The current Game
      Returns:
      The distance, in hexes to the unit's home edge.
    • calculateAlliesCenter

      @Nullable public Coords calculateAlliesCenter(int myId, @Nullable List<Entity> friends, Game game)
    • calcAllyCenter

      @Nullable public static Coords calcAllyCenter(int myId, @Nullable List<Entity> friends, Game game)
    • getOwner

      protected Princess getOwner()
    • getPathRankerState

      protected PathRankerState getPathRankerState()
      Convenience property to access bot-wide state information.
      Returns:
      the owner's path ranker state