Reputation: 2126
i want to implement the Recursive backtracker algorithm to solve maze problem, but i cant understand 2.3 Command ("remove the wall between the current cell and the chosen cell") would any help me ?
Edit In fact I want an algorithm to solve maze problem by using stack.
Upvotes: 2
Views: 4834
Reputation: 14870
Your algorithm is for god
mode. Normally you should do
Upvotes: 1
Reputation: 17541
That algorithm is a maze generator not a maze solver. The idea is that you want to create a random maze. You also want all points in the maze to be reachable from all other points.
If you just randomly remove walls it is likely that your maze will not be connected. The recursive backtracking algorithm takes care of this by creating a random walk and removing the walls along that random walk. The recursive backtracking part allows you to walk to every cell in the maze, even when you reach a dead end.
Upvotes: 4
Reputation: 11922
Removing the wall simply means removing the wall! You start with a grid of cells, each of which is totally surrounded by 4 walls. As you move randomly around (2.1) you remove the wall joining the cells.
Upvotes: 0