Flash Bestiary / Mazes / Simple Maze |
|
Simple MazeThis, the first randomly-generated maze, serves to show a maze-generation algorithm at it's simplest. To generate a new maze, reload the page. On the subsequent pages, we will develop this idea further, culminating in the beginnings of a maze-oriented game. The algorithm I use, called 'hunt and kill' is closely related to the typical algorithms used for the paint-bucket tools in many programs (a.k.a "flood fill"). The mazes produced by this algorithm have the interesting property that between any two grid-cells, there is one and only one path between them (without backtracking). Therefore, to create an "entrance" and "exit" for the maze, we need only punch two holes anywhere we like on the border of the maze, and we can be assured that there will be only one solution. If you wish to understand how this basic algorithm works, the actionscript source code for this particular movie (which was copied from an older Javascript version of mine) provides it in a fairly simple form.
|
|
|
|
Next: Grid Maze |
Copyright © 2003,2004 by Jim Bumgardner. All Rights Reserved. Leave Jim some feedback