Class LocalPathFinder
- java.lang.Object
-
- org.dreambot.api.methods.walking.pathfinding.impl.PathFinder<Tile>
-
- org.dreambot.api.methods.walking.pathfinding.impl.local.LocalPathFinder
-
public class LocalPathFinder extends PathFinder<Tile>
The local pathfinder used for navigating within the local regionThis class generally doesn't need to be used if you're just trying to walk, see
Walking.walk(Tile)
insteadFor global pathfinding across regions, see
WebFinder
instead
-
-
Field Summary
Fields Modifier and Type Field Description static int
sleepBetween
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description @NonNull 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.@NonNull 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.@NonNull LocalPath<Tile>
calculate(int sx, int sy, int sz, int ex, int ey, int ez)
Calculates an AbstractPath from the start location (x1,y1,z1) to the destination tile location (x2,y2,z2)@Nullable LocalPath<Tile>
calculate(@NonNull Tile start, @NonNull Tile end)
Calculates and returns a valid path from the start tile to the end tile.static @NonNull java.util.List<PathNode>
getClosed()
Deprecated.int
getCurrentDepth()
float
getHeuristicCost(int x, int y, int tx, int ty)
Get the heuristic cost for the given location.float
getHeuristicCost(int x, int y, int z, int tx, int ty, int tz)
static @NonNull LocalPathFinder
getLocalPathFinder()
static @NonNull java.util.List<PathNode>
getOpen()
Deprecated.double
getWalkingDistance(@NonNull Tile startTile, @NonNull 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, addTileCondition, addWebOnlyObstacleTile, checkTileCondition, clearBlacklist, clearTileConditions, getBlacklistedTiles, getDirection, getMovementCost, getNode, getObstacle, hasObstacle, isBlacklisted, isDirWall, isInPossibleObstacles, isTileWebOnly, onWebNodeVersionUpdate, removeBlacklistedTile, removeObstacle, removeTileCondition, removeWebOnlyObstacleTile, reset
-
-
-
-
Method Detail
-
getLocalPathFinder
public static @NonNull LocalPathFinder getLocalPathFinder()
-
calculate
public @Nullable LocalPath<Tile> calculate(@NonNull Tile start, @NonNull Tile end)
Calculates and returns a valid path from the start tile to the end tile.If you're trying to walk somewhere, you'll generally not need to use this class or method directly, see
Walking.walk(Tile)
instead.Example usage:
LocalPath path = LocalPathFinder.getLocalPathFinder().calculate(Players.getLocal().getTile(), new Tile(1234, 2345, 1)); if (path != null && !path.isEmpty()) { Logger.log("We found a path: " + path); path.walk(); } else { Logger.warn("No path found!"); }
- Overrides:
calculate
in classPathFinder<Tile>
- Parameters:
start
- Start tileend
- End tile- Returns:
- null if either the start or end tiles are null, empty if we can't find a path, or the full path if it's valid
-
calculate
public @NonNull 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 @NonNull LocalPath<Tile> calculate(int sx, int sy, int sz, int ex, int ey, int ez)
Description copied from class:PathFinder
Calculates an AbstractPath from the start location (x1,y1,z1) to the destination tile location (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.ex
- the destination grid X coordinate.ey
- the destination grid Y coordinate.ez
- the destination grid Z coordinate- Returns:
- AbstractPath
-
getOpen
@Deprecated public static @NonNull java.util.List<PathNode> getOpen()
Deprecated.
-
getClosed
@Deprecated public static @NonNull java.util.List<PathNode> getClosed()
Deprecated.
-
calculate
public @NonNull 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)
-
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
-
getHeuristicCost
public float getHeuristicCost(int x, int y, int z, int tx, int ty, int tz)
-
getWalkingDistance
public double getWalkingDistance(@NonNull Tile startTile, @NonNull 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 crow flies distance. If either tile is null, it will return -1.
-
-