add cost verification lookahead

This commit is contained in:
Leijurv 2018-08-26 08:19:14 -07:00
parent 50fd63647b
commit 6dd501a46b
No known key found for this signature in database
GPG Key ID: 44A3EA646EADAC6A
2 changed files with 16 additions and 0 deletions

View File

@ -119,6 +119,13 @@ public class Settings {
*/
public Setting<Boolean> cutoffAtLoadBoundary = new Setting<>(true);
/**
* Stop 5 movements before anything that made the path COST_INF.
* For example, if lava has spread across the path, don't walk right up to it then recalculate, it might
* still be spreading lol
*/
public Setting<Integer> costVerificationLookahead = new Setting<>(5);
/**
* Static cutoff factor. 0.9 means cut off the last 10% of all paths, regardless of chunk load state
*/

View File

@ -211,6 +211,15 @@ public class PathExecutor implements Helper {
Baritone.INSTANCE.getInputOverrideHandler().clearAllKeys();
return true;
}
for (int i = 1; i < Baritone.settings().costVerificationLookahead.get() && pathPosition + i < path.length() - 1; i++) {
if (path.movements().get(pathPosition + 1).recalculateCost() >= ActionCosts.COST_INF) {
displayChatMessageRaw("Something has changed in the world and a future movement has become impossible. Cancelling.");
pathPosition = path.length() + 3;
failed = true;
Baritone.INSTANCE.getInputOverrideHandler().clearAllKeys();
return true;
}
}
if (costEstimateIndex == null || costEstimateIndex != pathPosition) {
costEstimateIndex = pathPosition;
currentMovementInitialCostEstimate = currentCost; // do this only once, when the movement starts