public class AStarPathFinder extends PathFinder
Position
to a goal Position
. Returns a path with only the
goal position if no path could be found.Modifier and Type | Field and Description |
---|---|
private java.util.ArrayList<AStarNode> |
closed
The set of nodes that have been searched through
|
private AStarNode[][] |
graph
The graph in array format.
|
private java.util.ArrayList<AStarNode> |
open
The set of nodes that we do not yet consider fully searched
|
discretizedMap, map, precision
Constructor and Description |
---|
AStarPathFinder(Map map,
double precision)
Creates an A* path finder.
|
Modifier and Type | Method and Description |
---|---|
private double |
getHeuristicDistance(AStarNode node,
AStarNode goal)
Gets the heuristic distance between two
AStarNode s. |
private java.util.Collection<AStarNode> |
getNeighbors(AStarNode node)
Gets the neighbors of a
AStarNode . |
private AStarNode |
getNodeFromPosition(Position position)
Gets a AStar node from a
Position . |
java.util.List<Position> |
getPath(Position start,
Position goal,
boolean smooth)
|
private Position |
getPositionFromNode(AStarNode node)
Gets a
Position from a A Star Node. |
directPathPossible, getCornerPoints2, getPath, smooth
private java.util.ArrayList<AStarNode> closed
private AStarNode[][] graph
private java.util.ArrayList<AStarNode> open
public AStarPathFinder(Map map, double precision)
map
- The map.precision
- The precision.private double getHeuristicDistance(AStarNode node, AStarNode goal)
AStarNode
s. It is the
euclidean distance between the two nodes (while assuming no obstacles),
but corrects for the maximum angle allowed in the graph.node
- The starting node.goal
- The goal node.private java.util.Collection<AStarNode> getNeighbors(AStarNode node)
AStarNode
.node
- The node.private AStarNode getNodeFromPosition(Position position)
Position
.position
- The position.public java.util.List<Position> getPath(Position start, Position goal, boolean smooth)
PathFinder
Position
to a goal
Position
. The method returns a list of points that are the corner
points of the specified path.getPath
in class PathFinder
start
- The start position.goal
- The goal position.smooth
- Smooth or not.