float Heuristic(Cell* current, Cell* goal)
{
return ( goal->Pos() - current->Pos() ).length();
}
float Cost(Cell* current, Cell* next)
{
return ( next->Pos() - current->Pos() ).length();
}
A* Heuristic and Cost functions
I have a graph of connected cells where each cell has a world-space 3d-position (x,y,z), This is not a 2d-grid so I don't have an (x,y) index for a cell.
A* calls two functions:
Heuristic() - returns the estimated heuristic from the current cell to the goal cell.
Cost() - returns the cost to travel from the current cell to a neighbor.
Can I use the Euclidean distance in both the Heuristic() and Cost() functions?
Both h() and g() are in the same "space" (or scale or whatever you want to call it) so I'm thinking that should be fine... right?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement