disable backtrack cost favoring while building

This commit is contained in:
Leijurv 2019-01-09 15:42:49 -08:00
parent b109fc7420
commit 1dca02517e
No known key found for this signature in database
GPG Key ID: 44A3EA646EADAC6A
5 changed files with 10 additions and 7 deletions

View File

@ -517,7 +517,7 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior,
transformed = new GoalXZ(pos.getX(), pos.getZ()); transformed = new GoalXZ(pos.getX(), pos.getZ());
} }
} }
Favoring favoring = new Favoring(context.getBaritone().getPlayerContext(), previous); Favoring favoring = new Favoring(context.getBaritone().getPlayerContext(), previous, context);
return new AStarPathFinder(start.getX(), start.getY(), start.getZ(), transformed, favoring, context); return new AStarPathFinder(start.getX(), start.getY(), start.getZ(), transformed, favoring, context);
} }

View File

@ -65,6 +65,7 @@ public class CalculationContext {
public final int maxFallHeightBucket; public final int maxFallHeightBucket;
public final double waterWalkSpeed; public final double waterWalkSpeed;
public final double breakBlockAdditionalCost; public final double breakBlockAdditionalCost;
public double backtrackCostFavoringCoefficient;
public double jumpPenalty; public double jumpPenalty;
public final double walkOnWaterOnePenalty; public final double walkOnWaterOnePenalty;
public final BetterWorldBorder worldBorder; public final BetterWorldBorder worldBorder;
@ -100,6 +101,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.backtrackCostFavoringCoefficient = Baritone.settings().backtrackCostFavoringCoefficient.get();
this.jumpPenalty = Baritone.settings().jumpPenalty.get(); this.jumpPenalty = Baritone.settings().jumpPenalty.get();
this.walkOnWaterOnePenalty = Baritone.settings().walkOnWaterOnePenalty.get(); this.walkOnWaterOnePenalty = Baritone.settings().walkOnWaterOnePenalty.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?

View File

@ -330,6 +330,7 @@ public class BuilderProcess extends BaritoneProcessHelper {
this.originZ = schematicOrigin.getZ(); this.originZ = schematicOrigin.getZ();
this.jumpPenalty += 10; this.jumpPenalty += 10;
this.backtrackCostFavoringCoefficient = 1;
} }
private IBlockState getSchematic(int x, int y, int z) { private IBlockState getSchematic(int x, int y, int z) {

View File

@ -17,27 +17,27 @@
package baritone.utils.pathing; package baritone.utils.pathing;
import baritone.Baritone;
import baritone.api.pathing.calc.IPath; import baritone.api.pathing.calc.IPath;
import baritone.api.utils.BetterBlockPos; import baritone.api.utils.BetterBlockPos;
import baritone.api.utils.IPlayerContext; import baritone.api.utils.IPlayerContext;
import baritone.pathing.movement.CalculationContext;
import it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap; import it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap;
public final class Favoring { public final class Favoring {
private final Long2DoubleOpenHashMap favorings; private final Long2DoubleOpenHashMap favorings;
public Favoring(IPlayerContext ctx, IPath previous) { public Favoring(IPlayerContext ctx, IPath previous, CalculationContext context) {
this(previous); this(previous, context);
for (Avoidance avoid : Avoidance.create(ctx)) { for (Avoidance avoid : Avoidance.create(ctx)) {
avoid.applySpherical(favorings); avoid.applySpherical(favorings);
} }
System.out.println("Favoring size: " + favorings.size()); System.out.println("Favoring size: " + favorings.size());
} }
public Favoring(IPath previous) { // create one just from previous path, no mob avoidances public Favoring(IPath previous, CalculationContext context) { // create one just from previous path, no mob avoidances
favorings = new Long2DoubleOpenHashMap(); favorings = new Long2DoubleOpenHashMap();
favorings.defaultReturnValue(1.0D); favorings.defaultReturnValue(1.0D);
double coeff = Baritone.settings().backtrackCostFavoringCoefficient.get(); double coeff = context.backtrackCostFavoringCoefficient;
if (coeff != 1D && previous != null) { if (coeff != 1D && previous != null) {
previous.positions().forEach(pos -> favorings.put(BetterBlockPos.longHash(pos), coeff)); previous.positions().forEach(pos -> favorings.put(BetterBlockPos.longHash(pos), coeff));
} }

View File

@ -87,7 +87,7 @@ public class SegmentedCalculator {
private PathCalculationResult segment(Optional<IPath> previous) { private PathCalculationResult segment(Optional<IPath> previous) {
BetterBlockPos segmentStart = previous.map(IPath::getDest).orElse(start); // <-- e p i c BetterBlockPos segmentStart = previous.map(IPath::getDest).orElse(start); // <-- e p i c
AbstractNodeCostSearch search = new AStarPathFinder(segmentStart.x, segmentStart.y, segmentStart.z, goal, new Favoring(previous.orElse(null)), context); // this is on another thread, so cannot include mob avoidances. AbstractNodeCostSearch search = new AStarPathFinder(segmentStart.x, segmentStart.y, segmentStart.z, goal, new Favoring(previous.orElse(null), context), context); // this is on another thread, so cannot include mob avoidances.
return search.calculate(Baritone.settings().primaryTimeoutMS.get(), Baritone.settings().failureTimeoutMS.get()); // use normal time settings, not the plan ahead settings, so as to not overwhelm the computer return search.calculate(Baritone.settings().primaryTimeoutMS.get(), Baritone.settings().failureTimeoutMS.get()); // use normal time settings, not the plan ahead settings, so as to not overwhelm the computer
} }