0

I implemented a BFS on a maze that I made, but the one problem that I have is that I do not know how to obtain the indices of the path that it took to solve the maze. Right now all my BFS algorithm does it prints out if it is solvable (it reached the exit of the maze)

I currently have a vector called used that holds all the Cells that the BFS algorithm has visited as well as a queue that does what a BFS do. Is there something that I am missing about this BFS algorithm?

Please help. Thanks

Here is my function. Please note that I am assuming that it is right since it reached the end of the maze.

```
void CMaze::SolveMaze()
{
queue <Cell*> nextQueue;
vector <int> used;
bool found = false;
nextQueue.push(&s[0]);
used.push_back(0);
while(!found)
{
Cell *c;
if((int) nextQueue.size() > 0)
{
c = nextQueue.front();
nextQueue.pop();
}
else
break;
if(c->pos == size - 1)
{
found = true;
break;
}
else
{
for(int i = 0; i < c->neighbor.size(); ++i)
{
if(!hasN(used, c->neighbor[i]))
{
used.push_back(c->neighbor[i]);
nextQueue.push(&s[c->neighbor[i]]);
}
}
}
}
if(found)
cout << "found" << endl;
} //SolveMaze()
```