A* working : previousNode was initialized with one step instead of none.
This commit is contained in:
parent
d42d176e8d
commit
ebc8d961f4
2 changed files with 12 additions and 5 deletions
|
@ -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])
|
||||
{}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue