Here is a sensible maze generation algorithm, which generated the maze to the right. For the source code for a Java applet that generated the maze using the algorithm, click on the maze.
Start with a grid. Randomly select a square of the grid, mark it as part of the maze. Mark the neighbouring squares as next to the maze, store their locations in a list. While there are still squares in the list of squares next to the maze, randomly choose one from the list, remove it from the list, and connect it to the maze, by removing a wall between it and the maze. Mark it as part of the maze. Then mark all squares next to it as next to the maze, if they aren't already marked or part of the maze, adding them to the list. Once the list is empty, the maze is complete.
In mazes generated by that algorithm, it will typically be relatively easy to find the way to the square that was first picked at the beginning of the algorithm, since most paths lead to or from there, but hard to find the way out.
This article is a stub. You can help Wikipedia by fixing it.
Search Encyclopedia
|
Featured Article
|