fix(astar): compareto using sign for better precision
This commit is contained in:
parent
f77aea0371
commit
df55fb1472
1 changed files with 3 additions and 9 deletions
|
@ -40,14 +40,8 @@ public class Label implements Comparable<Label> {
|
|||
|
||||
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 this.pathCost - other.pathCost < 0 ? -1 : 1;
|
||||
return (int) Math.signum(difference);
|
||||
// Note that doesn't address the requested condition regarding equality :
|
||||
// "En cas d'égalité, on considèrera en premier le sommet ayant le plus petit coût estimé à la destination."
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue