From fb7d729b11a02c996436f3a85bc4e485ae40f446 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Sun, 16 Sep 2018 17:11:04 -0700 Subject: [PATCH] misc cleanup --- .../movement/movements/MovementTraverse.java | 3 +- .../baritone/pathing/path/PathExecutor.java | 2 +- .../pathing/calc/openset/OpenSetsTest.java | 34 +++++++++++++------ .../utils/pathing/BetterBlockPosTest.java | 4 +++ 4 files changed, 30 insertions(+), 13 deletions(-) diff --git a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java index 36c0cfc9..f28f29fb 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java @@ -263,9 +263,8 @@ public class MovementTraverse extends Movement { if (Objects.equals(LookBehaviorUtils.getSelectedBlock().orElse(null), against1) && Minecraft.getMinecraft().player.isSneaking()) { if (LookBehaviorUtils.getSelectedBlock().get().offset(side).equals(positionToPlace)) { return state.setInput(InputOverrideHandler.Input.CLICK_RIGHT, true); - } else { - // Out.gui("Wrong. " + side + " " + LookBehaviorUtils.getSelectedBlock().get().offset(side) + " " + positionsToPlace[0], Out.Mode.Debug); } + // wrong side? } System.out.println("Trying to look at " + against1 + ", actually looking at" + LookBehaviorUtils.getSelectedBlock()); return state.setInput(InputOverrideHandler.Input.CLICK_LEFT, true); diff --git a/src/main/java/baritone/pathing/path/PathExecutor.java b/src/main/java/baritone/pathing/path/PathExecutor.java index 9db754ae..02435502 100644 --- a/src/main/java/baritone/pathing/path/PathExecutor.java +++ b/src/main/java/baritone/pathing/path/PathExecutor.java @@ -212,7 +212,7 @@ public class PathExecutor implements Helper { } long end = System.nanoTime() / 1000000L; if (end - start > 0) { - //logDebug("Recalculating break and place took " + (end - start) + "ms"); + System.out.println("Recalculating break and place took " + (end - start) + "ms"); } Movement movement = path.movements().get(pathPosition); if (costEstimateIndex == null || costEstimateIndex != pathPosition) { diff --git a/src/test/java/baritone/pathing/calc/openset/OpenSetsTest.java b/src/test/java/baritone/pathing/calc/openset/OpenSetsTest.java index 6812f90d..5ab10d24 100644 --- a/src/test/java/baritone/pathing/calc/openset/OpenSetsTest.java +++ b/src/test/java/baritone/pathing/calc/openset/OpenSetsTest.java @@ -22,24 +22,37 @@ import baritone.pathing.goals.Goal; import baritone.utils.pathing.BetterBlockPos; import net.minecraft.util.math.BlockPos; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; import java.util.*; import static org.junit.Assert.*; +@RunWith(Parameterized.class) public class OpenSetsTest { - @Test - public void testOpenSets() { - for (int size = 1; size < 100; size++) { - testSize(size); - } - for (int size = 100; size < 10000; size += 100) { - testSize(size); - } + private final int size; + + public OpenSetsTest(int size) { + this.size = size; } - public void removeAndTest(int amount, IOpenSet[] test, Optional> mustContain) { + @Parameterized.Parameters + public static Collection data() { + ArrayList testSizes = new ArrayList<>(); + for (int size = 1; size < 20; size++) { + testSizes.add(new Object[]{size}); + } + for (int size = 100; size <= 1000; size += 100) { + testSizes.add(new Object[]{size}); + } + testSizes.add(new Object[]{5000}); + testSizes.add(new Object[]{10000}); + return testSizes; + } + + private static void removeAndTest(int amount, IOpenSet[] test, Optional> mustContain) { double[][] results = new double[test.length][amount]; for (int i = 0; i < test.length; i++) { long before = System.nanoTime() / 1000000L; @@ -62,7 +75,8 @@ public class OpenSetsTest { } } - public void testSize(int size) { + @Test + public void testSize() { System.out.println("Testing size " + size); // Include LinkedListOpenSet even though it's not performant because I absolutely trust that it behaves properly // I'm really testing the heap implementations against it as the ground truth diff --git a/src/test/java/baritone/utils/pathing/BetterBlockPosTest.java b/src/test/java/baritone/utils/pathing/BetterBlockPosTest.java index 758812f2..ff54579b 100644 --- a/src/test/java/baritone/utils/pathing/BetterBlockPosTest.java +++ b/src/test/java/baritone/utils/pathing/BetterBlockPosTest.java @@ -20,6 +20,8 @@ package baritone.utils.pathing; import net.minecraft.util.math.BlockPos; import org.junit.Test; +import static org.junit.Assert.assertTrue; + public class BetterBlockPosTest { @Test @@ -33,7 +35,9 @@ public class BetterBlockPosTest { for (int i = 0; i < 10; i++) { // eliminate any advantage to going first benchN(); + assertTrue(i<10); } + } public void benchOne() {