From 95cda79ef149bd488f6fa464276a4c4b0ff7b10c Mon Sep 17 00:00:00 2001 From: Leijurv Date: Wed, 29 Aug 2018 15:35:41 -0700 Subject: [PATCH] small open set change --- src/main/java/baritone/pathing/calc/AStarPathFinder.java | 5 ++--- .../baritone/pathing/calc/openset/BinaryHeapOpenSet.java | 2 +- .../baritone/pathing/calc/openset/LinkedListOpenSet.java | 3 ++- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/baritone/pathing/calc/AStarPathFinder.java b/src/main/java/baritone/pathing/calc/AStarPathFinder.java index 0a146ff0..f3e70673 100644 --- a/src/main/java/baritone/pathing/calc/AStarPathFinder.java +++ b/src/main/java/baritone/pathing/calc/AStarPathFinder.java @@ -21,7 +21,6 @@ import baritone.Baritone; import baritone.chunk.CachedWorld; import baritone.chunk.WorldProvider; import baritone.pathing.calc.openset.BinaryHeapOpenSet; -import baritone.pathing.calc.openset.IOpenSet; import baritone.pathing.goals.Goal; import baritone.pathing.movement.ActionCosts; import baritone.pathing.movement.CalculationContext; @@ -60,7 +59,7 @@ public class AStarPathFinder extends AbstractNodeCostSearch implements Helper { startNode = getNodeAtPosition(start); startNode.cost = 0; startNode.combinedCost = startNode.estimatedCostToGoal; - IOpenSet openSet = new BinaryHeapOpenSet(); + BinaryHeapOpenSet openSet = new BinaryHeapOpenSet(); openSet.insert(startNode); startNode.isOpen = true; bestSoFar = new PathNode[COEFFICIENTS.length];//keep track of the best node by the metric of (estimatedCostToGoal + cost / COEFFICIENTS[i]) @@ -182,7 +181,7 @@ public class AStarPathFinder extends AbstractNodeCostSearch implements Helper { return Optional.empty(); } System.out.println(numMovementsConsidered + " movements considered"); - System.out.println("Open set size: " + ((BinaryHeapOpenSet) openSet).size()); + System.out.println("Open set size: " + openSet.size()); System.out.println((int) (numNodes * 1.0 / ((System.currentTimeMillis() - startTime) / 1000F)) + " nodes per second"); double bestDist = 0; for (int i = 0; i < bestSoFar.length; i++) { diff --git a/src/main/java/baritone/pathing/calc/openset/BinaryHeapOpenSet.java b/src/main/java/baritone/pathing/calc/openset/BinaryHeapOpenSet.java index b81145f3..da2357d9 100644 --- a/src/main/java/baritone/pathing/calc/openset/BinaryHeapOpenSet.java +++ b/src/main/java/baritone/pathing/calc/openset/BinaryHeapOpenSet.java @@ -26,7 +26,7 @@ import java.util.Arrays; * * @author leijurv */ -public class BinaryHeapOpenSet implements IOpenSet { +public final class BinaryHeapOpenSet implements IOpenSet { /** * The initial capacity of the heap (2^10) diff --git a/src/main/java/baritone/pathing/calc/openset/LinkedListOpenSet.java b/src/main/java/baritone/pathing/calc/openset/LinkedListOpenSet.java index 49ee23d7..8ff5a674 100644 --- a/src/main/java/baritone/pathing/calc/openset/LinkedListOpenSet.java +++ b/src/main/java/baritone/pathing/calc/openset/LinkedListOpenSet.java @@ -22,10 +22,11 @@ import baritone.pathing.calc.PathNode; /** * A linked list implementation of an open set. This is the original implementation from MineBot. * It has incredibly fast insert performance, at the cost of O(n) removeLowest. + * It sucks. BinaryHeapOpenSet results in more than 10x more nodes considered in 4 seconds. * * @author leijurv */ -public class LinkedListOpenSet implements IOpenSet { +class LinkedListOpenSet implements IOpenSet { private Node first = null; @Override