Final analysis

I had some issues on generating the maze before, I said I couldn't make the random maze every time. Finally I figured out.
I have two solutions to make the random maze.
First, I wanted to make a simple maze, but I always met some trouble.
For example,
If I assume that the entrance is top left and exit is bottom right, then I start form the entrance to the exit,
pick one from the blue block randomly and go for it, then sign for passing. 
Then if I randomly choose to go to the yellow point, I will have three choice for next step because I don't want to go back or have the same path only if I have choice. 
But when I come to a died node, which means I can't go anymore, like the red point. I have to go back and find the green point. Then I popped the last point and make a pathlist which means the past points and n-1 is the green point. 
However, 

if this happened , a bug will happen, means that there is no path for the exit. So we have to find tha path both form entrance and exit. 

Like this. But this maze may be really simple so I turned to use DFS to do this. 

I set starting point as current point and sign it. If the current square has the unlabelled neighbors. Choose a unsigned neighbor square. And take out the wall between the current square and neighbor, then sign the neighbor as current. 
In the other hand if the stack is not empty, check out the top of the stack and make it become the current frame. Otherwise choose another square random and tag it. In conclusion, random walk from the starting point, to go the return if it is not free to go, from the one where you can go to start random walk again. 

Comments

Popular posts from this blog

Conclusion

My model

Random Maze Generator