public class AStarGrid extends Object
| Constructor and Description |
|---|
AStarGrid(int width,
int height)
Constructs A* grid with A* nodes with given width and height.
|
| Modifier and Type | Method and Description |
|---|---|
AStarNode[][] |
getGrid() |
int |
getHeight() |
AStarNode |
getNode(int x,
int y)
Returns a node at x, y.
|
List<AStarNode> |
getNodes() |
NodeState |
getNodeState(int x,
int y)
Returns state of the node at a, y.
|
List<AStarNode> |
getPath(int startX,
int startY,
int targetX,
int targetY)
Returns a list of A* nodes from start to target.
|
AStarNode |
getRandomNode() |
Optional<AStarNode> |
getRandomNode(Predicate<AStarNode> predicate) |
int |
getWidth() |
boolean |
isWithin(int x,
int y) |
void |
setNodeState(int x,
int y,
NodeState state)
Set state of the node at x, y.
|
void |
setStateForAllNodes(NodeState state)
Convenience method to set state of all nodes to given state.
|
public AStarGrid(int width,
int height)
NodeState.WALKABLEwidth - grid widthheight - grid heightpublic final int getWidth()
public final int getHeight()
public final boolean isWithin(int x,
int y)
x - x coordy - y coordpublic final void setStateForAllNodes(NodeState state)
state - node statepublic final void setNodeState(int x,
int y,
NodeState state)
x - the x coordinatey - the y coordinatestate - the statepublic final NodeState getNodeState(int x, int y)
x - the x coordinatey - the y coordinatepublic final List<AStarNode> getPath(int startX, int startY, int targetX, int targetY)
startX - start node xstartY - start node ytargetX - target node xtargetY - target node ypublic final AStarNode getNode(int x, int y)
x - the x coordinatey - the y coordinatepublic final AStarNode getRandomNode()
public final Optional<AStarNode> getRandomNode(Predicate<AStarNode> predicate)
predicate - filter conditionOptional.empty()
if no such node existspublic final AStarNode[][] getGrid()
Copyright © 2018. All rights reserved.