Class AbstractNodeCostSearch

java.lang.Object
com.zenith.feature.pathfinder.calc.AbstractNodeCostSearch
Direct Known Subclasses:
AStarPathFinder

public abstract class AbstractNodeCostSearch extends Object
  • Field Details

    • realStart

      protected final BlockPos realStart
    • startX

      protected final int startX
    • startY

      protected final int startY
    • startZ

      protected final int startZ
    • goal

      protected final Goal goal
    • startNode

      protected PathNode startNode
    • mostRecentConsidered

      protected PathNode mostRecentConsidered
    • bestSoFar

      protected final PathNode[] bestSoFar
    • cancelRequested

      protected boolean cancelRequested
    • COEFFICIENTS

      protected static final float[] COEFFICIENTS
      This is really complicated and hard to explain. I wrote a comment in the old version of MineBot but it was so long it was easier as a Google Doc (because I could insert charts).
      See Also:
    • MIN_DIST_PATH

      protected static final float MIN_DIST_PATH
      If a path goes less than 5 blocks and doesn't make it to its goal, it's not worth considering.
      See Also:
    • MIN_IMPROVEMENT

      protected static final float MIN_IMPROVEMENT
      there are floating point errors caused by random combinations of traverse and diagonal over a flat area that means that sometimes there's a cost improvement of like 10 ^ -16 it's not worth the time to update the costs, decrease-key the heap, potentially repropagate, etc

      who cares about a hundredth of a tick? that's half a millisecond for crying out loud!

      See Also:
  • Method Details

    • cancel

      public void cancel()
    • calculate

      public PathCalculationResult calculate(long primaryTimeout, long failureTimeout)
    • calculate0

      protected abstract Optional<IPath> calculate0(long primaryTimeout, long failureTimeout)
    • getDistFromStartSq

      protected double getDistFromStartSq(PathNode n)
      Determines the distance squared from the specified node to the start node. Intended for use in distance comparison, rather than anything that considers the real distance value, hence the "sq".
      Parameters:
      n - A node
      Returns:
      The distance, squared
    • getNodeAtPosition

      protected PathNode getNodeAtPosition(int x, int y, int z, long hashCode)
      Attempts to search the block position hashCode long to PathNode map for the node mapped to the specified pos. If no node is found, a new node is created.
      Parameters:
      x - The x position of the node
      y - The y position of the node
      z - The z position of the node
      hashCode - The hash code of the node, provided by BlockPos.longHash(int, int, int)
      Returns:
      The associated node
      See Also:
    • pathToMostRecentNodeConsidered

      public Optional<IPath> pathToMostRecentNodeConsidered()
    • bestPathSoFar

      public Optional<IPath> bestPathSoFar()
    • bestSoFar

      public Optional<IPath> bestSoFar(int numNodes)
    • bestSoFar

      public Optional<IPath> bestSoFar(int numNodes, double minDist)
    • isFinished

      public final boolean isFinished()
    • getGoal

      public final Goal getGoal()
    • getStart

      public BlockPos getStart()
    • mapSize

      protected int mapSize()