In the last week or so, I've been attempting to implement pathfinding for my first time. I've been reading a tutorial on the general concept and have been trying to implement it on my own. For the Closed List and Open List, I use std::vector. The guide says once I find the optimal node to delete it from the Open List and add it to the Closed List. I'm doing that with this code:
closedList.push_back(openList[lowF]);
openList.erase(openList.begin()+lowF);
The issue is that the wrong node is being deleted from the Open List, causing the pathfinding calculations to flow in an infinite loop. For Instance:
Closed List = (9,4)
Open List = (9,3) (10,4)
After the code I posted above executes, the vectors look like this:
Closed List = (9,4) (9,3)
Open List = (9,3)
While they should look like this
Closed List = (9,4) (9,3)
Open List = (10,4)
I checked the lowF value, and it is 0. So openList.erase(openList.begin()+lowF) should be the same as openList.erase(openList.begin()). For some reason, that line of code is deleting the second element in the vector instead of the first. I'm attaching a error log file I printed out. I'd appreciate any help. ty