Class AStarPathFinder
- java.lang.Object
-
- org.dreambot.api.methods.walking.pathfinding.impl.PathFinder<Tile>
-
- org.dreambot.api.methods.walking.pathfinding.impl.astar.AStarPathFinder
-
public class AStarPathFinder extends PathFinder<Tile>
Created with IntelliJ IDEA.- Since:
- : 3/28/2015 Time : 9:28 AM
-
-
Constructor Summary
Constructors Constructor Description AStarPathFinder(int maxDepth, boolean allowDiagonal)
Create a path finder with the AStar algorithm using a default heuristic - closest to targetAStarPathFinder(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
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description LocalPath<Tile>
calculate(int sx, int sy, int tx, int ty)
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.LocalPath<Tile>
calculate(int sx, int sy, int tx, int ty, int z)
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.LocalPath<Tile>
calculate(int sx, int sy, int sz, int tx, int ty, int z)
Calculates an AbstracPath from the start location (x1,y1,z1) to the destination tile locaion (x2,y2,z2)LocalPath<Tile>
calculate(Tile start, Tile end)
Calculates an AbstractPath from Tile s to Tile ejava.util.List<PathNode>
getClosed()
int
getCurrentDepth()
float
getHeuristicCost(int x, int y, int tx, int ty)
Get the heuristic cost for the given location.SortedPathList<PathNode>
getOpen()
double
getWalkingDistance(Tile startTile, Tile endTile)
Walking distance based on path finding between the provided tiles.void
setCurrentDepth(int currentDepth)
-
Methods inherited from class org.dreambot.api.methods.walking.pathfinding.impl.PathFinder
addBlacklistedTile, addObstacle, clearBlacklist, getDirection, getMovementCost, getNode, getObstacle, hasObstacle, isBlacklisted, isDirWall, removeObstacle, reset
-
-
-
-
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 upallowDiagonal
- 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 upallowDiagonal
- True if the search should try diagonal movementheuristic
- 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 classPathFinder<Tile>
- Parameters:
start
- Start Tileend
- 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 classPathFinder<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 classPathFinder<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 classPathFinder<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)
-
getOpen
public SortedPathList<PathNode> getOpen()
-
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 determinedy
- The y coordinate of the tile whose cost is being determinedtx
- The x coordinate of the target locationty
- 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.
-
-