Random Maze Generator

         I was planning to do a KENKEN problem solver but recently I changed my idea for the final project. I am doing the Random Maze Generator now. I am trying to get the Maze randomly and find the solution right away with DFS.
         Firstly, I set the size of the maze, and set the first maze as matrix which are the height and the width. Then I got number of the squares are h*w. And I can generate the vertical and horizontal wall randomly according to signs.
I need to make the unit square with a Boolean statement:
this.notMarked = new boolean[this.height][this.width];
Actually my general idea of the maze generator is trying to take the walls away randomly. So I do need to judge the existence of the both vertical and horizontal walls. Constantly randomly choose one side wall, if it can be separated by the walls of the room which is not connected to each other, then pull down the wall. Then repeat the process until the entre and the exit, resulting in the maze.  And the key problem is how to judge the two rooms are connected.
And I already finished the interface for the cell type.
          I am working on how to store the data now, because the maze is a rectangular area, so I can use two dimensional array labyrinth. So such a maze of every position can be only designated in its ranks, but the two-dimensional arrays cannot be dynamically define its size. I am considering to define a large two dimensional array maze[M+2][N+2], then I use it before M rows and N columns to hold the elements. So it could be a two-dimensional array, M*N(0,0) is the location of the maze entrance, so (M-1, N-1) is the location of maze experts.

Comments

Popular posts from this blog

Conclusion

My model