home page icon Flash Bestiary / Mazes / Simple Maze

Simple Maze

This, 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.


sourcecode iconDownload the flash project
book iconJim's Favorite Actionscript Books
wiki iconAsk Jim about Actionscript
Next: Grid Maze

Having trouble opening the project? You may need to Upgrade to Flash MX 2004

Copyright © 2003,2004 by Jim Bumgardner. All Rights Reserved.        Leave Jim some feedback