feat(astar): compare total cost
This commit is contained in:
parent
a0c6437bd2
commit
24012e3afc
1 changed files with 14 additions and 1 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue