I need help with A* pathfinding searching the neighbours for lowest GCost
Guys I got the a* pathfinder almost down but my search neighbors for the lowest GCost code isn't working.
That code below should compare the last closeList index closeListNum with the the openList -7 index. It searches 8 moves back for the lowest GCost. I hope someone can help me out with this. :)
// search neighbours
lowestGCost = closeList[i-7].GCost;
for (int i = openListNum-6; i < openListNum; i++)
{
if (openList(i).GCost < lowestGCost)
{
lowestGCost = openList.GCost;
if (lowestGCost < closeList[closeListNum].GCost)
{
closeList[closeListNum].Num = openList.Num;
closeList[closeListNum].GridX = openList.GridX;
closeList[closeListNum].GridY = openList.GridY;
closeList[closeListNum].Heuristic = openList.Heuristic;
closeList[closeListNum].Parent = openList.Parent;
closeList[closeListNum].GCost = openList.GCost;
closeList[closeListNum].FCost = openList.FCost;
}
}
}