👌formatting
This commit is contained in:
parent
e529438c7e
commit
0c7741120a
@ -56,15 +56,15 @@ public interface Goal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the heuristic at the goal.
|
* Returns the heuristic at the goal.
|
||||||
* i.e. {@code heuristic() == heuristic(x,y,z)}
|
* i.e. {@code heuristic() == heuristic(x,y,z)}
|
||||||
* when {@code isInGoal(x,y,z) == true}
|
* when {@code isInGoal(x,y,z) == true}
|
||||||
* This is needed by {@code PathingBehavior#estimatedTicksToGoal} because
|
* This is needed by {@code PathingBehavior#estimatedTicksToGoal} because
|
||||||
* some Goals actually do not have a heuristic of 0 when that condition is met
|
* some Goals actually do not have a heuristic of 0 when that condition is met
|
||||||
*
|
*
|
||||||
* @return The estimate number of ticks to satisfy the goal when the goal
|
* @return The estimate number of ticks to satisfy the goal when the goal
|
||||||
* is already satisfied
|
* is already satisfied
|
||||||
*/
|
*/
|
||||||
default double heuristic() {
|
default double heuristic() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ public class GoalComposite implements Goal {
|
|||||||
@Override
|
@Override
|
||||||
public double heuristic() {
|
public double heuristic() {
|
||||||
double min = Double.MAX_VALUE;
|
double min = Double.MAX_VALUE;
|
||||||
for (Goal g: goals) {
|
for (Goal g : goals) {
|
||||||
//just take the highest value that is guaranteed to be inside the goal
|
//just take the highest value that is guaranteed to be inside the goal
|
||||||
min = Math.min(min, g.heuristic());
|
min = Math.min(min, g.heuristic());
|
||||||
}
|
}
|
||||||
|
@ -56,14 +56,14 @@ public class GoalNear implements Goal, IGoalRenderPos {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double heuristic() {//TODO less hacky solution
|
public double heuristic() {//TODO less hacky solution
|
||||||
int range = (int)Math.ceil(Math.sqrt(rangeSq));
|
int range = (int) Math.ceil(Math.sqrt(rangeSq));
|
||||||
HashSet<Double> maybeAlwaysInside = new HashSet<>();
|
HashSet<Double> maybeAlwaysInside = new HashSet<>();
|
||||||
HashSet<Double> sometimesOutside = new HashSet<>();
|
HashSet<Double> sometimesOutside = new HashSet<>();
|
||||||
for (int dx = -range; dx <= range; dx++) {
|
for (int dx = -range; dx <= range; dx++) {
|
||||||
for (int dy = -range; dy <= range; dy++) {
|
for (int dy = -range; dy <= range; dy++) {
|
||||||
for (int dz = -range; dz <= range; dz++) {
|
for (int dz = -range; dz <= range; dz++) {
|
||||||
double h = heuristic(x+dx, y+dy, z+dz);
|
double h = heuristic(x + dx, y + dy, z + dz);
|
||||||
if (!sometimesOutside.contains(h) && isInGoal(x+dx, y+dy, z+dz)) {
|
if (!sometimesOutside.contains(h) && isInGoal(x + dx, y + dy, z + dz)) {
|
||||||
maybeAlwaysInside.add(h);
|
maybeAlwaysInside.add(h);
|
||||||
} else {
|
} else {
|
||||||
maybeAlwaysInside.remove(h);
|
maybeAlwaysInside.remove(h);
|
||||||
|
@ -85,7 +85,7 @@ public class GoalRunAway implements Goal {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double heuristic() {//TODO less hacky solution
|
public double heuristic() {//TODO less hacky solution
|
||||||
int distance = (int)Math.ceil(Math.sqrt(distanceSq));
|
int distance = (int) Math.ceil(Math.sqrt(distanceSq));
|
||||||
int minX = from[0].getX() - distance;
|
int minX = from[0].getX() - distance;
|
||||||
int minY = from[0].getY() - distance;
|
int minY = from[0].getY() - distance;
|
||||||
int minZ = from[0].getZ() - distance;
|
int minZ = from[0].getZ() - distance;
|
||||||
|
Loading…
Reference in New Issue
Block a user