Skip to content

Commit

Permalink
add comment to avoid future confusion.
Browse files Browse the repository at this point in the history
  • Loading branch information
lostsquirrel1 committed Dec 12, 2024
1 parent a7c8883 commit 4028aa9
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions rts/Sim/Path/HAPFS/PathDataTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,11 @@ struct PathNode {
/// functor to define node priority
/// This needs to guarantee that the sorting is stable.
struct lessCost {
inline bool operator() (const PathNode* x, const PathNode* y) const {
return std::tie(x->fCost, y->gCost, x->nodeNum) > std::tie(y->fCost, x->gCost, y->nodeNum);
inline bool operator() (const PathNode* lhs, const PathNode* rhs) const {
// fCost == gCost + hCost.
// When fCosts are the same, prioritize the node closest the goal. Since we don't have hCost to hand, we know
// that hCost == fCost - gCost. This is why we invert the left/right side for the gCost comparison.
return std::tie(lhs->fCost, rhs->gCost, lhs->nodeNum) > std::tie(rhs->fCost, lhs->gCost, rhs->nodeNum);
}
};

Expand Down

0 comments on commit 4028aa9

Please sign in to comment.