Skip to content

Commit e750074

Browse files
committed
fix goal distance estimate in findpath
1 parent 6c6e6ac commit e750074

1 file changed

Lines changed: 2 additions & 5 deletions

File tree

‎cpp/findpath.cpp‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
#include <iostream>
1414
#include <stdio.h>
15+
#include <math.h>
1516

1617
#define DEBUG_LISTS 0
1718
#define DEBUG_LIST_LENGTHS_ONLY 0
@@ -121,11 +122,7 @@ void MapSearchNode::PrintNodeInfo()
121122

122123
float MapSearchNode::GoalDistanceEstimate( MapSearchNode &nodeGoal )
123124
{
124-
float xd = float( ( (float)x - (float)nodeGoal.x ) );
125-
float yd = float( ( (float)y - (float)nodeGoal.y) );
126-
127-
return xd + yd;
128-
125+
return fabsf(x - nodeGoal.x) + fabsf(y - nodeGoal.y);
129126
}
130127

131128
bool MapSearchNode::IsGoal( MapSearchNode &nodeGoal )

0 commit comments

Comments
 (0)