Class AStarPathFinder


  • public class AStarPathFinder
    extends PathFinder<Tile>
    Created with IntelliJ IDEA.
    Since:
    : 3/28/2015 Time : 9:28 AM
    • Constructor Detail

      • AStarPathFinder

        public AStarPathFinder​(int maxDepth,
                               boolean allowDiagonal)
        Create a path finder with the AStar algorithm using a default heuristic - closest to target
        Parameters:
        maxDepth - Maximum depth we'll search before giving up
        allowDiagonal - True if the search should try diagonal movement
      • AStarPathFinder

        public AStarPathFinder​(int maxDepth,
                               boolean allowDiagonal,
                               org.dreambot.api.methods.walking.pathfinding.impl.astar.heuristic.Heuristic heuristic)
        Create a path finder with the AStar algorithm using a given heuristic
        Parameters:
        maxDepth - Maximum depth we'll search before giving up
        allowDiagonal - True if the search should try diagonal movement
        heuristic - The heuristic used to determine movement weight
    • Method Detail

      • calculate

        public LocalPath<Tile> calculate​(Tile start,
                                         Tile end)
        Description copied from class: PathFinder
        Calculates an AbstractPath from Tile s to Tile e
        Overrides:
        calculate in class PathFinder<Tile>
        Parameters:
        start - Start Tile
        end - End Tile
        Returns:
        AbstractPath
      • calculate

        public LocalPath<Tile> calculate​(int sx,
                                         int sy,
                                         int tx,
                                         int ty)
        Description copied from class: PathFinder
        Calculate a walkable abstract path from the start tile location (sx, sy) to the destination tile location (dx, dy), using data provided by the tile map. Assumes z coordinate is 0
        Overrides:
        calculate in class PathFinder<Tile>
        Parameters:
        sx - the starting grid X coordinate.
        sy - the starting grid Y coordinate.
        tx - the destination grid X coordinate.
        ty - the destination grid Y coordinate.
        Returns:
        the abstract path from the start to destination if a path is found, if unable to find path it will return null.
      • calculate

        public LocalPath<Tile> calculate​(int sx,
                                         int sy,
                                         int sz,
                                         int tx,
                                         int ty,
                                         int z)
        Description copied from class: PathFinder
        Calculates an AbstracPath from the start location (x1,y1,z1) to the destination tile locaion (x2,y2,z2)
        Specified by:
        calculate in class PathFinder<Tile>
        Parameters:
        sx - the starting grid X coordinate.
        sy - the starting grid Y coordinate.
        sz - the starting grid Z coordinate.
        tx - the destination grid X coordinate.
        ty - the destination grid Y coordinate.
        z - the destination grid Z coordinate
        Returns:
        AbstractPath
      • calculate

        public LocalPath<Tile> calculate​(int sx,
                                         int sy,
                                         int tx,
                                         int ty,
                                         int z)
        Description copied from class: PathFinder
        Calculate a walkable abstract path from the start tile location (x1, y1,z) to the destination tile location (x2, y2,z), using data provided by the tile map.
        Overrides:
        calculate in class PathFinder<Tile>
        Parameters:
        sx - the starting grid X coordinate.
        sy - the starting grid Y coordinate.
        tx - the destination grid X coordinate.
        ty - the destination grid Y coordinate.
        z - the z coordinate
        Returns:
        the abstract path from the start to destination if a path is found, if unable to find path it will return null.
      • getCurrentDepth

        public int getCurrentDepth()
      • setCurrentDepth

        public void setCurrentDepth​(int currentDepth)
      • getClosed

        public java.util.List<PathNode> getClosed()
      • getHeuristicCost

        public float getHeuristicCost​(int x,
                                      int y,
                                      int tx,
                                      int ty)
        Get the heuristic cost for the given location. This determines in which order the locations are processed.
        Parameters:
        x - The x coordinate of the tile whose cost is being determined
        y - The y coordinate of the tile whose cost is being determined
        tx - The x coordinate of the target location
        ty - The y coordinate of the target location
        Returns:
        The heuristic cost assigned to the tile
      • getWalkingDistance

        public double getWalkingDistance​(Tile startTile,
                                         Tile endTile)
        Walking distance based on path finding between the provided tiles.
        Parameters:
        startTile - the start tile.
        endTile - the destination tile.
        Returns:
        return the path distance movement cost from the given tile as a double. If there isn't a path to the tile, it will return 3 times the as the crow flies distance.