From 76365a4564c58a3620753fe50e71c4ce6f5d16c8 Mon Sep 17 00:00:00 2001 From: Leijurv Date: Mon, 1 Oct 2018 10:05:04 -0700 Subject: [PATCH] sprint on soul sand, fixes #120 --- .../baritone/api/pathing/movement/ActionCosts.java | 14 +++++++------- .../movement/movements/MovementDiagonal.java | 9 ++++++--- .../movement/movements/MovementTraverse.java | 9 ++++++--- 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/src/api/java/baritone/api/pathing/movement/ActionCosts.java b/src/api/java/baritone/api/pathing/movement/ActionCosts.java index e1f72dfa..683b1b10 100644 --- a/src/api/java/baritone/api/pathing/movement/ActionCosts.java +++ b/src/api/java/baritone/api/pathing/movement/ActionCosts.java @@ -23,21 +23,21 @@ public interface ActionCosts { * These costs are measured roughly in ticks btw */ double WALK_ONE_BLOCK_COST = 20 / 4.317; // 4.633 - double WALK_ONE_IN_WATER_COST = 20 / 2.2; + double WALK_ONE_IN_WATER_COST = 20 / 2.2; // 9.091 double WALK_ONE_OVER_SOUL_SAND_COST = WALK_ONE_BLOCK_COST * 2; // 0.4 in BlockSoulSand but effectively about half - double SPRINT_ONE_OVER_SOUL_SAND_COST = WALK_ONE_OVER_SOUL_SAND_COST * 0.75; - double LADDER_UP_ONE_COST = 20 / 2.35; - double LADDER_DOWN_ONE_COST = 20 / 3.0; - double SNEAK_ONE_BLOCK_COST = 20 / 1.3; + double LADDER_UP_ONE_COST = 20 / 2.35; // 8.511 + double LADDER_DOWN_ONE_COST = 20 / 3.0; // 6.667 + double SNEAK_ONE_BLOCK_COST = 20 / 1.3; // 15.385 double SPRINT_ONE_BLOCK_COST = 20 / 5.612; // 3.564 + double SPRINT_MULTIPLIER = SPRINT_ONE_BLOCK_COST / WALK_ONE_BLOCK_COST; // 0.769 /** * To walk off an edge you need to walk 0.5 to the edge then 0.3 to start falling off */ - double WALK_OFF_BLOCK_COST = WALK_ONE_BLOCK_COST * 0.8; + double WALK_OFF_BLOCK_COST = WALK_ONE_BLOCK_COST * 0.8; // 3.706 /** * To walk the rest of the way to be centered on the new block */ - double CENTER_AFTER_FALL_COST = WALK_ONE_BLOCK_COST - WALK_OFF_BLOCK_COST; + double CENTER_AFTER_FALL_COST = WALK_ONE_BLOCK_COST - WALK_OFF_BLOCK_COST; // 0.927 /** * don't make this Double.MAX_VALUE because it's added to other things, maybe other COST_INFs, diff --git a/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java b/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java index 7519f801..454421c4 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java @@ -117,19 +117,22 @@ public class MovementDiagonal extends Movement { return COST_INF; } } + boolean water = false; if (BlockStateInterface.isWater(BlockStateInterface.getBlock(x, y, z)) || BlockStateInterface.isWater(destInto.getBlock())) { // Ignore previous multiplier // Whatever we were walking on (possibly soul sand) doesn't matter as we're actually floating on water // Not even touching the blocks below multiplier = WALK_ONE_IN_WATER_COST; + water = true; } if (optionA != 0 || optionB != 0) { multiplier *= SQRT_2 - 0.001; // TODO tune } - if (multiplier == WALK_ONE_BLOCK_COST && context.canSprint()) { - // If we aren't edging around anything, and we aren't in water or soul sand + if (context.canSprint() && !water) { + // If we aren't edging around anything, and we aren't in water // We can sprint =D - multiplier = SPRINT_ONE_BLOCK_COST; + // Don't check for soul sand, since we can sprint on that too + multiplier *= SPRINT_MULTIPLIER; } return multiplier * SQRT_2; } diff --git a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java index a16a50a1..72bfa526 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java @@ -67,8 +67,10 @@ public class MovementTraverse extends Movement { Block srcDown = BlockStateInterface.getBlock(x, y - 1, z); if (MovementHelper.canWalkOn(destX, y - 1, destZ, destOn)) {//this is a walk, not a bridge double WC = WALK_ONE_BLOCK_COST; + boolean water = false; if (BlockStateInterface.isWater(pb0.getBlock()) || BlockStateInterface.isWater(pb1.getBlock())) { WC = WALK_ONE_IN_WATER_COST; + water = true; } else { if (destOn.getBlock() == Blocks.SOUL_SAND) { WC += (WALK_ONE_OVER_SOUL_SAND_COST - WALK_ONE_BLOCK_COST) / 2; @@ -83,10 +85,11 @@ public class MovementTraverse extends Movement { } double hardness2 = MovementHelper.getMiningDurationTicks(context, destX, y, destZ, pb1, false); if (hardness1 == 0 && hardness2 == 0) { - if (WC == WALK_ONE_BLOCK_COST && context.canSprint()) { - // If there's nothing in the way, and this isn't water or soul sand, and we aren't sneak placing + if (!water && context.canSprint()) { + // If there's nothing in the way, and this isn't water, and we aren't sneak placing // We can sprint =D - WC = SPRINT_ONE_BLOCK_COST; + // Don't check for soul sand, since we can sprint on that too + WC *= SPRINT_MULTIPLIER; } return WC; }