prevent favoring from affecting movement cost thresholds

This commit is contained in:
Leijurv 2019-01-08 14:56:21 -08:00
parent ee9519d891
commit e971d5d43f
No known key found for this signature in database
GPG Key ID: 44A3EA646EADAC6A
10 changed files with 12 additions and 10 deletions

View File

@ -132,7 +132,9 @@ class Path extends PathBase {
Movement move = moves.apply0(context, src); Movement move = moves.apply0(context, src);
if (move.getDest().equals(dest)) { if (move.getDest().equals(dest)) {
// have to calculate the cost at calculation time so we can accurately judge whether a cost increase happened between cached calculation and real execution // have to calculate the cost at calculation time so we can accurately judge whether a cost increase happened between cached calculation and real execution
move.override(cost); // however, taking into account possible favoring that could skew the node cost, we really want the stricter limit of the two
// so we take the minimum of the path node cost difference, and the calculated cost
move.override(Math.min(move.calculateCost(context), cost));
return move; return move;
} }
} }

View File

@ -84,7 +84,7 @@ public abstract class Movement implements IMovement, MovementHelper {
return cost; return cost;
} }
protected abstract double calculateCost(CalculationContext context); public abstract double calculateCost(CalculationContext context);
@Override @Override
public double recalculateCost() { public double recalculateCost() {

View File

@ -52,7 +52,7 @@ public class MovementAscend extends Movement {
} }
@Override @Override
protected double calculateCost(CalculationContext context) { public double calculateCost(CalculationContext context) {
return cost(context, src.x, src.y, src.z, dest.x, dest.z); return cost(context, src.x, src.y, src.z, dest.x, dest.z);
} }

View File

@ -52,7 +52,7 @@ public class MovementDescend extends Movement {
} }
@Override @Override
protected double calculateCost(CalculationContext context) { public double calculateCost(CalculationContext context) {
MutableMoveResult result = new MutableMoveResult(); MutableMoveResult result = new MutableMoveResult();
cost(context, src.x, src.y, src.z, dest.x, dest.z, result); cost(context, src.x, src.y, src.z, dest.x, dest.z, result);
if (result.y != dest.y) { if (result.y != dest.y) {

View File

@ -54,7 +54,7 @@ public class MovementDiagonal extends Movement {
} }
@Override @Override
protected double calculateCost(CalculationContext context) { public double calculateCost(CalculationContext context) {
MutableMoveResult result = new MutableMoveResult(); MutableMoveResult result = new MutableMoveResult();
cost(context, src.x, src.y, src.z, dest.x, dest.z, result); cost(context, src.x, src.y, src.z, dest.x, dest.z, result);
if (result.y != dest.y) { if (result.y != dest.y) {

View File

@ -43,7 +43,7 @@ public class MovementDownward extends Movement {
} }
@Override @Override
protected double calculateCost(CalculationContext context) { public double calculateCost(CalculationContext context) {
return cost(context, src.x, src.y, src.z); return cost(context, src.x, src.y, src.z);
} }

View File

@ -54,7 +54,7 @@ public class MovementFall extends Movement {
} }
@Override @Override
protected double calculateCost(CalculationContext context) { public double calculateCost(CalculationContext context) {
MutableMoveResult result = new MutableMoveResult(); MutableMoveResult result = new MutableMoveResult();
MovementDescend.cost(context, src.x, src.y, src.z, dest.x, dest.z, result); MovementDescend.cost(context, src.x, src.y, src.z, dest.x, dest.z, result);
if (result.y != dest.y) { if (result.y != dest.y) {

View File

@ -166,7 +166,7 @@ public class MovementParkour extends Movement {
@Override @Override
protected double calculateCost(CalculationContext context) { public double calculateCost(CalculationContext context) {
MutableMoveResult res = new MutableMoveResult(); MutableMoveResult res = new MutableMoveResult();
cost(context, src.x, src.y, src.z, direction, res); cost(context, src.x, src.y, src.z, direction, res);
if (res.x != dest.x || res.z != dest.z) { if (res.x != dest.x || res.z != dest.z) {

View File

@ -42,7 +42,7 @@ public class MovementPillar extends Movement {
} }
@Override @Override
protected double calculateCost(CalculationContext context) { public double calculateCost(CalculationContext context) {
return cost(context, src.x, src.y, src.z); return cost(context, src.x, src.y, src.z);
} }

View File

@ -60,7 +60,7 @@ public class MovementTraverse extends Movement {
} }
@Override @Override
protected double calculateCost(CalculationContext context) { public double calculateCost(CalculationContext context) {
return cost(context, src.x, src.y, src.z, dest.x, dest.z); return cost(context, src.x, src.y, src.z, dest.x, dest.z);
} }