Slight change to heuristic(no args)
This commit is contained in:
parent
3cdbc4cb83
commit
9393192036
@ -58,16 +58,15 @@ public class GoalNear implements Goal, IGoalRenderPos {
|
||||
public double heuristic() {// TODO less hacky solution
|
||||
int range = (int) Math.ceil(Math.sqrt(rangeSq));
|
||||
HashSet<Double> maybeAlwaysInside = new HashSet<>();
|
||||
HashSet<Double> sometimesOutside = new HashSet<>();
|
||||
double minOutside = Double.POSITIVE_INFINITY;
|
||||
for (int dx = -range; dx <= range; dx++) {
|
||||
for (int dy = -range; dy <= range; dy++) {
|
||||
for (int dz = -range; dz <= range; dz++) {
|
||||
double h = heuristic(x + dx, y + dy, z + dz);
|
||||
if (!sometimesOutside.contains(h) && isInGoal(x + dx, y + dy, z + dz)) {
|
||||
if (h < minOutside && isInGoal(x + dx, y + dy, z + dz)) {
|
||||
maybeAlwaysInside.add(h);
|
||||
} else {
|
||||
maybeAlwaysInside.remove(h);
|
||||
sometimesOutside.add(h);
|
||||
minOutside = Math.min(minOutside, h);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -101,16 +101,15 @@ public class GoalRunAway implements Goal {
|
||||
maxZ = Math.max(minZ, p.getZ() + distance);
|
||||
}
|
||||
HashSet<Double> maybeAlwaysInside = new HashSet<>();
|
||||
HashSet<Double> sometimesOutside = new HashSet<>();
|
||||
double minOutside = Double.POSITIVE_INFINITY;
|
||||
for (int x = minX; x <= maxX; x++) {
|
||||
for (int y = minY; y <= maxY; y++) {
|
||||
for (int z = minZ; z <= maxZ; z++) {
|
||||
double h = heuristic(x, y, z);
|
||||
if (!sometimesOutside.contains(h) && isInGoal(x, y, z)) {
|
||||
if (h < minOutside && isInGoal(x, y, z)) {
|
||||
maybeAlwaysInside.add(h);
|
||||
} else {
|
||||
maybeAlwaysInside.remove(h);
|
||||
sometimesOutside.add(h);
|
||||
minOutside = Math.min(minOutside, h);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user