From dff3e1efe5efcd897784a8e06b53b152294402d1 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 6 Aug 2018 08:42:26 -0700 Subject: [PATCH] sanity checks in pathfinder --- .../java/baritone/bot/pathing/calc/AStarPathFinder.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/baritone/bot/pathing/calc/AStarPathFinder.java b/src/main/java/baritone/bot/pathing/calc/AStarPathFinder.java index 6ee0d244..9ef8b0aa 100644 --- a/src/main/java/baritone/bot/pathing/calc/AStarPathFinder.java +++ b/src/main/java/baritone/bot/pathing/calc/AStarPathFinder.java @@ -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;