add jump penalty

This commit is contained in:
Leijurv 2018-12-19 14:37:11 -08:00
parent d41aa5f9ae
commit 77938a77e8
No known key found for this signature in database
GPG Key ID: 44A3EA646EADAC6A
5 changed files with 18 additions and 4 deletions

View File

@ -68,6 +68,11 @@ public class Settings {
*/ */
public Setting<Double> blockBreakAdditionalPenalty = new Setting<>(2D); public Setting<Double> blockBreakAdditionalPenalty = new Setting<>(2D);
/**
* Additional penalty for hitting the space bar (ascend, pillar, or parkour) beacuse it uses hunger
*/
public Setting<Double> jumpPenalty = new Setting<>(2D);
/** /**
* Allow Baritone to fall arbitrary distances and place a water bucket beneath it. * Allow Baritone to fall arbitrary distances and place a water bucket beneath it.
* Reliability: questionable. * Reliability: questionable.

View File

@ -61,6 +61,7 @@ public class CalculationContext {
private final int maxFallHeightBucket; private final int maxFallHeightBucket;
private final double waterWalkSpeed; private final double waterWalkSpeed;
private final double breakBlockAdditionalCost; private final double breakBlockAdditionalCost;
private final double jumpPenalty;
private final BetterWorldBorder worldBorder; private final BetterWorldBorder worldBorder;
public CalculationContext(IBaritone baritone) { public CalculationContext(IBaritone baritone) {
@ -93,6 +94,7 @@ public class CalculationContext {
float mult = depth / 3.0F; float mult = depth / 3.0F;
this.waterWalkSpeed = ActionCosts.WALK_ONE_IN_WATER_COST * (1 - mult) + ActionCosts.WALK_ONE_BLOCK_COST * mult; this.waterWalkSpeed = ActionCosts.WALK_ONE_IN_WATER_COST * (1 - mult) + ActionCosts.WALK_ONE_BLOCK_COST * mult;
this.breakBlockAdditionalCost = Baritone.settings().blockBreakAdditionalPenalty.get(); this.breakBlockAdditionalCost = Baritone.settings().blockBreakAdditionalPenalty.get();
this.jumpPenalty = Baritone.settings().jumpPenalty.get();
// why cache these things here, why not let the movements just get directly from settings? // why cache these things here, why not let the movements just get directly from settings?
// because if some movements are calculated one way and others are calculated another way, // because if some movements are calculated one way and others are calculated another way,
// then you get a wildly inconsistent path that isn't optimal for either scenario. // then you get a wildly inconsistent path that isn't optimal for either scenario.
@ -212,4 +214,8 @@ public class CalculationContext {
public double breakBlockAdditionalCost() { public double breakBlockAdditionalCost() {
return breakBlockAdditionalCost; return breakBlockAdditionalCost;
} }
public double jumpPenalty() {
return jumpPenalty;
}
} }

View File

@ -115,15 +115,18 @@ public class MovementAscend extends Movement {
if (jumpingToBottomSlab) { if (jumpingToBottomSlab) {
if (jumpingFromBottomSlab) { if (jumpingFromBottomSlab) {
walk = Math.max(JUMP_ONE_BLOCK_COST, WALK_ONE_BLOCK_COST); // we hit space immediately on entering this action walk = Math.max(JUMP_ONE_BLOCK_COST, WALK_ONE_BLOCK_COST); // we hit space immediately on entering this action
walk += context.jumpPenalty();
} else { } else {
walk = WALK_ONE_BLOCK_COST; // we don't hit space we just walk into the slab walk = WALK_ONE_BLOCK_COST; // we don't hit space we just walk into the slab
} }
} else { } else {
// jumpingFromBottomSlab must be false
if (toPlace.getBlock() == Blocks.SOUL_SAND) { if (toPlace.getBlock() == Blocks.SOUL_SAND) {
walk = WALK_ONE_OVER_SOUL_SAND_COST; walk = WALK_ONE_OVER_SOUL_SAND_COST;
} else { } else {
walk = WALK_ONE_BLOCK_COST; walk = Math.max(JUMP_ONE_BLOCK_COST, WALK_ONE_BLOCK_COST);
} }
walk += context.jumpPenalty();
} }
// cracks knuckles // cracks knuckles

View File

@ -115,7 +115,7 @@ public class MovementParkour extends Movement {
res.x = x + xDiff * i; res.x = x + xDiff * i;
res.y = y; res.y = y;
res.z = z + zDiff * i; res.z = z + zDiff * i;
res.cost = costFromJumpDistance(i); res.cost = costFromJumpDistance(i) + context.jumpPenalty();
return; return;
} }
} }
@ -145,7 +145,7 @@ public class MovementParkour extends Movement {
res.x = destX; res.x = destX;
res.y = y; res.y = y;
res.z = destZ; res.z = destZ;
res.cost = costFromJumpDistance(4) + context.placeBlockCost(); res.cost = costFromJumpDistance(4) + context.placeBlockCost() + context.jumpPenalty();
return; return;
} }
} }

View File

@ -112,7 +112,7 @@ public class MovementPillar extends Movement {
if (ladder) { if (ladder) {
return LADDER_UP_ONE_COST + hardness * 5; return LADDER_UP_ONE_COST + hardness * 5;
} else { } else {
return JUMP_ONE_BLOCK_COST + context.placeBlockCost() + hardness; return JUMP_ONE_BLOCK_COST + context.placeBlockCost() + context.jumpPenalty() + hardness;
} }
} }