i dont know much about c++, but i wanted to help a friend get this into c++ code.. any help would be great =)
Initialize Finished and Queue;
int count = limit read in from user;
Node * initialPosition = node containing initial board position;
Node * finalPosition = node containing final board position;
Set pred pointer of initialPosition to NULL;
Add initialPosition to queue;
while( Queue not empty )
{
Remove a node N from Queue;
if ( N is in Finished )
; // do nothing
else if ( N is the same as finalPosition )
{
Report success and print pred list from N to initialPosition in reverse (i.e., N last);
Exit;
}
else
{
count --
if(count == 0) // Count unique board positions examined
{
Tell user that can't find board within limit;
Exit;
}
Insert N into Finished;
Generate a list L of all children of N;
forall M in L
if( M is not in Finished )
{
Set the pred pointer of M to point to N;
Add M to the Queue;
}
}
}