Thanks Jos,
Actually the problem was that I was using cells without the concept of walls - that is, this cell is either filled in or it isn't. In this way, each 'cell' was a filled square - and was either there or not (so the whole thing could be stored in a boolean array.
Everything I found on the net seemed to suggest the same sort of method you specified, but I really didn't want to change the way I was drawing the maze on the screen.
Eventually, I decided to bring the concept of walls in, but in such a way that only squares with both x & y coordinates even would be cells, and any other cell would be a wall (with odd x & y ALWAYS being a wall).
Using an algorithm similar to yours, I manged to generate a maze as desired (in non language-specific code):
-
Pick Random_Cell
-
RandomCell->Visited=true;
-
wallList Add(Random_Cell's Surrounding_walls)
-
while( wallList Not Empty) loop
-
-
wall = wallList->getRandomWall();
-
if(wall has unvisited cell on either side)
-
{
-
unvisited cell = visited;
-
wallList Add(wall->newly_visited_cell's- Surrounding_walls);
-
}
-
Remove wall from wallList;
-
}
-
Same principle, I suppose...Gives you a unique path to any cell in the maze.
Currently, the maze is 29x29 cells, and the pattern generated is sufficiently complex to make the RH rule tedious, and lengthy (for a human user), although I will consider removing some random walls just to add to the challenge!!
Although counting the steps taken and reporting back to the user how many they took, and the minimum they could have taken works well for now.
Tanks Again!!