Merge branch 'master' into benchmark

This commit is contained in:
leijurv
2018-08-28 20:51:42 -07:00
2 changed files with 10 additions and 1 deletions
@@ -72,6 +72,7 @@ public class AStarPathFinder extends AbstractNodeCostSearch implements Helper {
long timeoutTime = startTime + (slowPath ? Baritone.settings().slowPathTimeoutMS : Baritone.settings().pathTimeoutMS).<Long>get(); long timeoutTime = startTime + (slowPath ? Baritone.settings().slowPathTimeoutMS : Baritone.settings().pathTimeoutMS).<Long>get();
long lastPrintout = 0; long lastPrintout = 0;
int numNodes = 0; int numNodes = 0;
int numMovementsConsidered = 0;
int numEmptyChunk = 0; int numEmptyChunk = 0;
boolean favoring = favoredPositions.isPresent(); boolean favoring = favoredPositions.isPresent();
int pathingMaxChunkBorderFetch = Baritone.settings().pathingMaxChunkBorderFetch.get(); // grab all settings beforehand so that changing settings during pathing doesn't cause a crash or unpredictable behavior int pathingMaxChunkBorderFetch = Baritone.settings().pathingMaxChunkBorderFetch.get(); // grab all settings beforehand so that changing settings during pathing doesn't cause a crash or unpredictable behavior
@@ -126,6 +127,7 @@ public class AStarPathFinder extends AbstractNodeCostSearch implements Helper {
timeConsumed.put(movementToGetToNeighbor.getClass(), costEnd - costStart + timeConsumed.getOrDefault(movementToGetToNeighbor.getClass(), 0L)); timeConsumed.put(movementToGetToNeighbor.getClass(), costEnd - costStart + timeConsumed.getOrDefault(movementToGetToNeighbor.getClass(), 0L));
count.put(movementToGetToNeighbor.getClass(), 1 + count.getOrDefault(movementToGetToNeighbor.getClass(), 0)); count.put(movementToGetToNeighbor.getClass(), 1 + count.getOrDefault(movementToGetToNeighbor.getClass(), 0));
//System.out.println(movementToGetToNeighbor.getClass() + "" + (costEnd - costStart)); //System.out.println(movementToGetToNeighbor.getClass() + "" + (costEnd - costStart));
numMovementsConsidered++;
if (actionCost >= ActionCosts.COST_INF) { if (actionCost >= ActionCosts.COST_INF) {
continue; continue;
} }
@@ -181,6 +183,9 @@ public class AStarPathFinder extends AbstractNodeCostSearch implements Helper {
currentlyRunning = null; currentlyRunning = null;
return Optional.empty(); return Optional.empty();
} }
System.out.println(numMovementsConsidered + " movements considered");
System.out.println("Open set size: " + ((BinaryHeapOpenSet) openSet).size());
System.out.println((int) (numNodes * 1.0 / ((System.currentTimeMillis() - startTime) / 1000F)) + " nodes per second");
double bestDist = 0; double bestDist = 0;
for (int i = 0; i < bestSoFar.length; i++) { for (int i = 0; i < bestSoFar.length; i++) {
if (bestSoFar[i] == null) { if (bestSoFar[i] == null) {
@@ -197,7 +202,7 @@ public class AStarPathFinder extends AbstractNodeCostSearch implements Helper {
System.out.println("the path I found is pretty terrible (like sneak-bridging for dozens of blocks)"); System.out.println("the path I found is pretty terrible (like sneak-bridging for dozens of blocks)");
System.out.println("But I'm going to do it anyway, because yolo"); System.out.println("But I'm going to do it anyway, because yolo");
} }
System.out.println("Path goes for " + dist + " blocks"); System.out.println("Path goes for " + Math.sqrt(dist) + " blocks");
currentlyRunning = null; currentlyRunning = null;
return Optional.of(new Path(startNode, bestSoFar[i], numNodes)); return Optional.of(new Path(startNode, bestSoFar[i], numNodes));
} }
@@ -52,6 +52,10 @@ public class BinaryHeapOpenSet implements IOpenSet {
this.array = new PathNode[size]; this.array = new PathNode[size];
} }
public int size() {
return size;
}
@Override @Override
public final void insert(PathNode value) { public final void insert(PathNode value) {
if (size >= array.length - 1) { if (size >= array.length - 1) {