A* working : previousNode was initialized with one step instead of none.

This commit is contained in:
Teo-CD 2019-06-09 05:37:08 +02:00
parent d42d176e8d
commit ebc8d961f4
2 changed files with 12 additions and 5 deletions

View file

@ -120,8 +120,13 @@ Orientation Level::findPath(pro_maat::GridPos start, pro_maat::GridPos goal, int
if(std::find(goalNeighboursBeginIterator,goalNeighboursEndIterator,currentNode) != goalNeighboursEndIterator)
{
if(currentNode == start)
{
return(Orientation::None);
}
// Trace back to the start
pro_maat::GridPos& previousNode = paths[currentNode];
pro_maat::GridPos& previousNode = currentNode;
for(;paths[previousNode]!=start;previousNode = paths[previousNode])
{}