Wednesday, July 15, 2009

Better Maze Algorithm


I've done some Google-ing and found a better maze building algorithm care of Mazeworks.com.

Basically, the algorithm works by creating a grid (a maze with every possible wall). Then the algorithm picks a start point randomly. Next, it goes around sort of drilling a path through walls, essentially destroying the wall between two cells and then moving to the next cell. It keeps drilling (back tracking if necessary) until each cell has been visited and no cell has no walls. Mazeworks has a great explanation here.

This is pretty awesome because the algorithm can build any size maze.

Try out my Maze Generator game here. You'll need the XNA redistributable as usual.

No comments:

Post a Comment