minimum improvement repropagation

This commit is contained in:
Leijurv 2018-08-17 19:19:25 -07:00
parent bd40c9709d
commit 88b276f7c9
No known key found for this signature in database
GPG Key ID: 44A3EA646EADAC6A
3 changed files with 36 additions and 16 deletions

View File

@ -36,30 +36,41 @@ public class Settings {
* because we want to generally conserve blocks which might be limited
*/
public Setting<Double> blockPlacementPenalty = new Setting<>(20D);
public Setting<Boolean> allowSprint = new Setting<>(true);
public Setting<Double> costHeuristic = new <Double>Setting<Double>(4D);
public Setting<Boolean> chuckCaching = new Setting<>(false);
public Setting<Boolean> allowWaterBucketFall = new Setting<>(true);
public Setting<Integer> planningTickLookAhead = new Setting<>(150);
public Setting<Boolean> chatDebug = new Setting<>(true);
public Setting<Boolean> chatControl = new Setting<>(true); // probably false in impact
public Setting<Boolean> renderPath = new Setting<>(true);
public Setting<Boolean> fadePath = new Setting<>(false); // give this a better name in the UI, like "better path fps" idk
public Setting<Number> pathTimeoutMS = new Setting<>(4000L);
public Setting<Boolean> slowPath = new Setting<>(false);
public Setting<Number> slowPathTimeDelayMS = new Setting<>(100L);
public Setting<Number> slowPathTimeoutMS = new Setting<>(40000L);
public Setting<Boolean> allowSprint = new Setting<>(true);
public Setting<List<Item>> acceptableThrowawayItems = new Setting<>(Arrays.asList(
Item.getItemFromBlock(Blocks.DIRT),
Item.getItemFromBlock(Blocks.COBBLESTONE),
Item.getItemFromBlock(Blocks.NETHERRACK)
));
public Setting<Boolean> renderGoal = new Setting<>(true);
public Setting<Double> costHeuristic = new <Double>Setting<Double>(4D);
// obscure internal A* settings that you probably don't want to change
public Setting<Integer> pathingMaxChunkBorderFetch = new Setting<>(50);
public Setting<Boolean> backtrackCostFavor = new Setting<>(true);
public Setting<Boolean> backtrackCostFavor = new Setting<>(true); // see issue #18
public Setting<Double> backtrackCostFavoringCoefficient = new Setting<>(0.9); // see issue #18
public Setting<Boolean> minimumImprovementRepropagation = new Setting<>(true);
public Setting<Number> pathTimeoutMS = new Setting<>(4000L);
public Setting<Boolean> slowPath = new Setting<>(false);
public Setting<Number> slowPathTimeDelayMS = new Setting<>(100L);
public Setting<Number> slowPathTimeoutMS = new Setting<>(40000L);
public Setting<Boolean> chuckCaching = new Setting<>(false);
public Setting<Integer> planningTickLookAhead = new Setting<>(150);
public Setting<Boolean> chatDebug = new Setting<>(true);
public Setting<Boolean> chatControl = new Setting<>(true); // probably false in impact
public Setting<Boolean> renderPath = new Setting<>(true);
public Setting<Boolean> renderGoal = new Setting<>(true);
public Setting<Float> pathRenderLineWidth = new Setting<>(5F);
public Setting<Float> goalRenderLineWidth = new Setting<>(3F);
public Setting<Boolean> fadePath = new Setting<>(false); // give this a better name in the UI, like "better path fps" idk
public final Map<String, Setting<?>> byName;
public final List<Setting<?>> allSettings;

View File

@ -265,7 +265,7 @@ public class PathingBehavior extends Behavior {
PathRenderer.drawPath(current.getPath(), renderBegin, player(), partialTicks, Color.RED, Baritone.settings().fadePath.get(), 10, 20);
}
if (next != null && next.getPath() != null) {
PathRenderer.drawPath(next.getPath(), 0, player(), partialTicks, Color.GREEN, Baritone.settings().fadePath.get(), 10, 20);
PathRenderer.drawPath(next.getPath(), 0, player(), partialTicks, Color.MAGENTA, Baritone.settings().fadePath.get(), 10, 20);
}
long split = System.nanoTime();

View File

@ -97,6 +97,7 @@ public class AStarPathFinder extends AbstractNodeCostSearch implements Helper {
boolean cache = Baritone.settings().chuckCaching.get();
int pathingMaxChunkBorderFetch = Baritone.settings().pathingMaxChunkBorderFetch.get();
double favorCoeff = Baritone.settings().backtrackCostFavoringCoefficient.get();
boolean minimumImprovementRepropagation = Baritone.settings().minimumImprovementRepropagation.get();
while (!openSet.isEmpty() && numEmptyChunk < pathingMaxChunkBorderFetch && System.currentTimeMillis() < timeoutTime) {
if (slowPath) {
try {
@ -160,6 +161,14 @@ public class AStarPathFinder extends AbstractNodeCostSearch implements Helper {
if (tentativeCost < 0) {
throw new IllegalStateException(movementToGetToNeighbor.getClass() + " " + movementToGetToNeighbor + " overflowed into negative " + actionCost + " " + neighbor.cost + " " + tentativeCost);
}
double improvementBy = neighbor.cost - tentativeCost;
// there are floating point errors caused by random combinations of traverse and diagonal over a flat area
// that means that sometimes there's a cost improvement of like 10 ^ -16
// it's not worth the time to update the costs, decrease-key the heap, potentially repropagate, etc
if (improvementBy < 0.01 && minimumImprovementRepropagation) {
// who cares about a hundredth of a tick? that's half a millisecond for crying out loud!
continue;
}
neighbor.previous = currentNode;
neighbor.previousMovement = movementToGetToNeighbor;
neighbor.cost = tentativeCost;
@ -190,7 +199,7 @@ public class AStarPathFinder extends AbstractNodeCostSearch implements Helper {
bestDist = dist;
}
if (dist > MIN_DIST_PATH * MIN_DIST_PATH) { // square the comparison since distFromStartSq is squared
displayChatMessageRaw("A* cost coefficient " + COEFFICIENTS[i]);
displayChatMessageRaw("Took " + (System.currentTimeMillis() - startTime) + "ms, A* cost coefficient " + COEFFICIENTS[i]);
if (COEFFICIENTS[i] >= 3) {
System.out.println("Warning: cost coefficient is greater than three! Probably means that");
System.out.println("the path I found is pretty terrible (like sneak-bridging for dozens of blocks)");