public class JumpPointSearchPathFinder extends PathFinder
Modifier and Type | Field and Description |
---|---|
private JumpPointNode |
goalNode
The goal node.
|
private JumpPointNode[][] |
graph
The graph in array format.
|
discretizedMap, map, precision
Constructor and Description |
---|
JumpPointSearchPathFinder(Map map,
double precision)
Creates the path finder.
|
Modifier and Type | Method and Description |
---|---|
private void |
doSuccessor(JumpPointNode node,
java.util.ArrayList<JumpPointNode> openList)
Performs the successor step in the algorithm.
|
private void |
emptyMap()
Empties the map and sets all values to null.
|
private float |
getDistance(JumpPointNode first,
JumpPointNode second)
Gets the distance between two nodes.
|
private java.util.Collection<JumpPointNode> |
getNeighbors(JumpPointNode node)
Gets the neighbors of a
JumpPointNode . |
private JumpPointNode |
getNextNode(java.util.ArrayList<JumpPointNode> openList)
Gets the next node from the open list.
|
private JumpPointNode |
getNode(int x,
int y)
Gets a node from its coordinates.
|
private JumpPointNode |
getNodeFromPosition(Position position)
Gets a JPS node from a
Position . |
java.util.List<Position> |
getPath(Position start,
Position goal,
boolean smooth)
|
private Position |
getPositionFromNode(JumpPointNode node)
Gets a
Position from a A Star Node. |
private boolean |
isTraversable(int x,
int y)
Determines if the graph is traversable at (x,y)
|
private JumpPointNode |
jump(JumpPointNode child,
JumpPointNode parent)
Perform the jump.
|
private void |
resetMap()
Resets the map.
|
directPathPossible, getCornerPoints2, getPath, smooth
private JumpPointNode[][] graph
private JumpPointNode goalNode
public JumpPointSearchPathFinder(Map map, double precision)
map
- The map.precision
- The precision.private void doSuccessor(JumpPointNode node, java.util.ArrayList<JumpPointNode> openList)
node
- The node.openList
- The open list.private void emptyMap()
private float getDistance(JumpPointNode first, JumpPointNode second)
first
- The first node.second
- The second node.private java.util.Collection<JumpPointNode> getNeighbors(JumpPointNode node)
JumpPointNode
.node
- The node.private JumpPointNode getNextNode(java.util.ArrayList<JumpPointNode> openList)
openList
- The open list.private JumpPointNode getNode(int x, int y)
x
- X coordinate.y
- Y coordinate.private JumpPointNode 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.private Position getPositionFromNode(JumpPointNode node)
Position
from a A Star Node.node
- The node.private boolean isTraversable(int x, int y)
x
- X coordinatey
- Y coordinateprivate JumpPointNode jump(JumpPointNode child, JumpPointNode parent)
child
- The child.parent
- The parent.private void resetMap()