我要实现的递归backtracker算法来解决迷宫问题,但是我无法理解2.3命令(删除当前单元格和所选单元格之间的墙)将任何帮助我吗?
编辑 其实我想一个算法使用栈解决迷宫问题。
解决方案这算法是一个迷宫的发电机的不是一个迷宫的求解器的。我们的想法是要创建一个随机的迷宫。你也想在迷宫中所有的点是从所有其他点到达。
如果你只是随意删除墙壁很可能是你的迷宫将无法连接。递归回溯算法需要照顾的通过创建一个随机的走的,并沿着随机游走拆除围墙。递归回溯一部分,还可以步行到每一个细胞都在迷宫中,甚至当你达到一个死胡同。
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.
解决方案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.
更多推荐
迷宫问题和递归backtracker算法
发布评论