My model

After I choose to use Deep First Search, I make a model for my project. I want to make sure I have only one way between the entrance and the exit. So I thought what would be a tree, I randomly select a grid as a root node, starting from its depth at random search, offer a way to, until no way to go, take a step back and find another way, go to the corner and back to step back and change another one...Such a cycle, until completely no choice...Actually still back also.In the procedure is the following process (see the code in createMaze () function) :Randomly select a grid as a root node, pressing it into the stack.Then when the stack is not empty execute the following cycle:INTREE symbol of take out a grid, it is set to 1, and then will be out of the tree all of its neighbors in the grid pressure into the stack (random order), and the father of the neighbor grid points to the grid.Solve the two problems, the rest of the maze, display path, ball movement is relatively simple.

Comments

Popular posts from this blog

Conclusion

Random Maze Generator