public class SimpleGoal extends java.lang.Object implements AStarGoalBase<AStarNode>
Constructor and Description |
---|
SimpleGoal() |
Modifier and Type | Method and Description |
---|---|
int |
distanceToGoal(int startX,
int startY,
int startZ)
The heuristic function used by the A* algorithm to judge the cost of a
node.
|
int |
getNodeCost(AStarNode from,
int endX,
int endY,
int endZ)
Returns the actual cost accurately, for moving from node
from
to the given set of coordinates. |
boolean |
isPathFinished(AStarNode currentNode)
Returns if the given node corresponds to the goal tile on the map.
|
void |
setGoalNode(AStarNode goal) |
void |
setMaximumRevolutions(int maximum)
Sets the number of revolutions the A* search algorithm may execute, before
the goal declares the search unsuccessful.
|
void |
setNodeStorage(AStarOpenListBase<AStarNode> openList)
Tells the goal about the used storage containers.
|
boolean |
shouldGiveUp(int currentRevolutions)
Returns if the taken search revolutions exceed the set maximum.
|
public void setGoalNode(AStarNode goal)
setGoalNode
in interface AStarGoalBase<AStarNode>
public int distanceToGoal(int startX, int startY, int startZ)
AStarGoalBase
distanceToGoal
in interface AStarGoalBase<AStarNode>
public int getNodeCost(AStarNode from, int endX, int endY, int endZ)
AStarGoalBase
from
to the given set of coordinates. It is assumed that these are adjacent.getNodeCost
in interface AStarGoalBase<AStarNode>
from
- Start node of movement.endX
- X-position of destination.endY
- Y-position of destination.endZ
- Z-position of destination.public boolean isPathFinished(AStarNode currentNode)
AStarGoalBase
isPathFinished
in interface AStarGoalBase<AStarNode>
currentNode
- The node to check for corresponding to the goal tile.true
if the node's tile is the goal,
false
otherwise.public void setNodeStorage(AStarOpenListBase<AStarNode> openList)
AStarGoalBase
setNodeStorage
in interface AStarGoalBase<AStarNode>
public void setMaximumRevolutions(int maximum)
AStarGoalBase
setMaximumRevolutions
in interface AStarGoalBase<AStarNode>
maximum
- The number of revolutions.public boolean shouldGiveUp(int currentRevolutions)
AStarGoalBase
shouldGiveUp
in interface AStarGoalBase<AStarNode>
currentRevolutions
- Number of revolutions the search has already
taken.true
if the search should be ended, false
otherwise.