public class AStarSearch extends Object implements Serializable
a faster pathfinding algorithm with more features.
,
Serialized FormModifier and Type | Class and Description |
---|---|
static class |
AStarSearch.SearchType
The type of heuristic to use.
|
Modifier and Type | Field and Description |
---|---|
protected int |
height |
protected double[][] |
map |
protected HashSet<Coord> |
open |
protected Coord[][] |
parent |
protected Coord |
start |
protected Coord |
target |
protected AStarSearch.SearchType |
type |
protected int |
width |
Modifier | Constructor and Description |
---|---|
protected |
AStarSearch() |
|
AStarSearch(double[][] map,
AStarSearch.SearchType type)
Builds a pathing object to run searches on.
|
Modifier and Type | Method and Description |
---|---|
protected double |
f(int x,
int y)
Combines g and h to get the estimated distance from start to goal going on the current route.
|
protected double |
g(int x,
int y)
Finds the g value (start to current) for the given location.
|
protected double |
h(int x,
int y)
Returns the heuristic distance from the current cell to the goal location\
using the current calculation type.
|
Queue<Coord> |
path(Coord start,
Coord target)
Finds an A* path to the target from the start.
|
Queue<Coord> |
path(int startx,
int starty,
int targetx,
int targety)
Finds an A* path to the target from the start.
|
protected Coord |
smallestF() |
protected final double[][] map
protected final int width
protected final int height
protected final AStarSearch.SearchType type
protected AStarSearch()
public AStarSearch(double[][] map, AStarSearch.SearchType type)
map
- the search map. It is not modified by this class, hence you can
share this map among multiple instances.type
- the manner of searchpublic Queue<Coord> path(int startx, int starty, int targetx, int targety)
startx
- the x coordinate of the start locationstarty
- the y coordinate of the start locationtargetx
- the x coordinate of the target locationtargety
- the y coordinate of the target locationpublic Queue<Coord> path(Coord start, Coord target)
start
- the start locationtarget
- the target locationprotected double g(int x, int y)
x
- coordinatey
- coordinateprotected double h(int x, int y)
x
- coordinatey
- coordinateprotected double f(int x, int y)
x
- coordinatey
- coordinateCopyright © 2012–2016. All rights reserved.