mirror of
https://github.com/cabaletta/baritone
synced 2024-12-29 10:32:31 +00:00
sanity checks in pathfinder
This commit is contained in:
parent
d884c2dea8
commit
dff3e1efe5
@ -88,9 +88,15 @@ public class AStarPathFinder extends AbstractNodeCostSearch {
|
||||
if (actionCost >= ActionCosts.COST_INF) {
|
||||
continue;
|
||||
}
|
||||
if (actionCost <= 0) {
|
||||
throw new IllegalStateException(movementToGetToNeighbor.getClass() + " " + movementToGetToNeighbor + " calculated implausible cost " + actionCost);
|
||||
}
|
||||
PathNode neighbor = getNodeAtPosition(movementToGetToNeighbor.getDest());
|
||||
double tentativeCost = currentNode.cost + actionCost;
|
||||
if (tentativeCost < neighbor.cost) {
|
||||
if (tentativeCost < 0) {
|
||||
throw new IllegalStateException(movementToGetToNeighbor.getClass() + " " + movementToGetToNeighbor + " overflowed into negative " + actionCost + " " + neighbor.cost + " " + tentativeCost);
|
||||
}
|
||||
neighbor.previous = currentNode;
|
||||
neighbor.previousMovement = movementToGetToNeighbor;
|
||||
neighbor.cost = tentativeCost;
|
||||
|
Loading…
Reference in New Issue
Block a user