feat(astar): compare total cost

This commit is contained in:
Paul Alnet 2024-05-03 14:46:33 +02:00
parent a0c6437bd2
commit 24012e3afc

View file

@ -33,8 +33,21 @@ public class Label implements Comparable<Label> {
return pathCost;
}
public float getTotalCost() {
// will be overriden for A*
return pathCost;
}
public int compareTo(Label other) {
final float difference = this.getTotalCost() - other.getTotalCost();
final boolean equal = Math.abs(difference) < 1.0;
if (equal) {
return 0;
//TODO
}
// TODO ensure this works properly
return (int)(this.pathCost - other.pathCost);
// return (int)(this.pathCost - other.pathCost);
return this.pathCost - other.pathCost < 0 ? -1 : 1;
}
}