misc fixes to coefficients, descend, and pathexecutor

This commit is contained in:
Leijurv 2018-08-13 16:41:08 -07:00
parent 4ba5d81b5c
commit bc9f76d1c7
No known key found for this signature in database
GPG Key ID: 44A3EA646EADAC6A
5 changed files with 24 additions and 13 deletions

View File

@ -57,7 +57,7 @@ public abstract class AbstractNodeCostSearch implements IPathFinder {
*
* @see <a href="https://docs.google.com/document/d/1WVHHXKXFdCR1Oz__KtK8sFqyvSwJN_H4lftkHFgmzlc/edit"></a>
*/
protected static final double[] COEFFICIENTS = {1.5, 2, 2.5, 3, 4, 5, 10};
protected static final double[] COEFFICIENTS = {1, 1.5, 2, 2.5, 3, 4, 5, 10};
/**
* If a path goes less than 5 blocks and doesn't make it to its goal, it's not worth considering.
*/

View File

@ -23,6 +23,7 @@ import net.minecraft.util.math.Vec3d;
/**
* Useful for long-range goals that don't have a specific Y level.
*
* @author leijurv
*/
public class GoalXZ implements Goal {
@ -97,7 +98,7 @@ public class GoalXZ implements Goal {
diagonal = z;
}
diagonal *= SQRT_2;
return (diagonal + straight) * WALK_ONE_BLOCK_COST;
return (diagonal + straight) * 4;
}
public static GoalXZ fromDirection(Vec3d origin, float yaw, double distance) {

View File

@ -22,13 +22,13 @@ public interface ActionCosts extends ActionCostsButOnlyTheOnesThatMakeMickeyDieI
/**
* These costs are measured roughly in ticks btw
*/
double WALK_ONE_BLOCK_COST = 20 / 4.317;
double WALK_ONE_BLOCK_COST = 20 / 4.317; // // 4.633
double WALK_ONE_IN_WATER_COST = 20 / 2.2;
double JUMP_ONE_BLOCK_COST = 5.72854;//see below calculation for fall. 1.25 blocks
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 SPRINT_ONE_BLOCK_COST = 20 / 5.612;
double SPRINT_ONE_BLOCK_COST = 20 / 5.612; // 3.564
/**
* To walk off an edge you need to walk 0.5 to the edge then 0.3 to start falling off
*/

View File

@ -68,10 +68,14 @@ public class MovementDescend extends Movement {
case RUNNING:
BlockPos playerFeet = playerFeet();
if (playerFeet.equals(dest) && (BlockStateInterface.isLiquid(dest) || player().posY - playerFeet.getY() < 0.01)) {
// Wait until we're actually on the ground before saying we're done because sometimes we continue to fall if the next action starts immediately
state.setStatus(MovementStatus.SUCCESS);
return state;
if (playerFeet.equals(dest)) {
if (BlockStateInterface.isLiquid(dest) || player().posY - playerFeet.getY() < 0.01) {
// Wait until we're actually on the ground before saying we're done because sometimes we continue to fall if the next action starts immediately
state.setStatus(MovementStatus.SUCCESS);
return state;
} else {
System.out.println(player().posY + " " + playerFeet.getY() + " " + (player().posY - playerFeet.getY()));
}
}
double diffX = player().posX - (dest.getX() + 0.5);
double diffZ = player().posZ - (dest.getZ() + 0.5);
@ -79,15 +83,19 @@ public class MovementDescend extends Movement {
double x = player().posX - (src.getX() + 0.5);
double z = player().posZ - (src.getZ() + 0.5);
double fromStart = Math.sqrt(x * x + z * z);
if (!playerFeet.equals(dest) || ab > 0.2) {
if (!playerFeet.equals(dest) || ab > 0.25) {
BlockPos fakeDest = new BlockPos(dest.getX() * 2 - src.getX(), dest.getY(), dest.getZ() * 2 - src.getZ());
double diffX2 = player().posX - (fakeDest.getX() + 0.5);
double diffZ2 = player().posZ - (fakeDest.getZ() + 0.5);
double d = Math.sqrt(diffX2 * diffX2 + diffZ2 * diffZ2);
MovementHelper.moveTowards(state, fakeDest);
if (fromStart > 1.2 && numTicks++ < 10) {
state.setInput(InputOverrideHandler.Input.MOVE_FORWARD, false);
state.setInput(InputOverrideHandler.Input.MOVE_BACK, true);
if (numTicks++ < 20) {
MovementHelper.moveTowards(state, fakeDest);
if (fromStart > 1.25) {
state.setInput(InputOverrideHandler.Input.MOVE_FORWARD, false);
state.setInput(InputOverrideHandler.Input.MOVE_BACK, true);
}
} else {
MovementHelper.moveTowards(state, dest);
}
}
return state;

View File

@ -91,6 +91,7 @@ public class PathExecutor implements Helper {
if (whereAmI.equals(path.positions().get(i))) {
displayChatMessageRaw("Skipping back " + (pathPosition - i) + " steps, to " + i);
pathPosition = Math.max(i - 1, 0); // previous step might not actually be done
Baritone.INSTANCE.getInputOverrideHandler().clearAllKeys();
return false;
}
}
@ -100,6 +101,7 @@ public class PathExecutor implements Helper {
displayChatMessageRaw("Skipping forward " + (i - pathPosition) + " steps, to " + i);
}
pathPosition = i - 1;
Baritone.INSTANCE.getInputOverrideHandler().clearAllKeys();
return false;
}
}