Friday, March 13, 2009

Recursive Division Part II

Based on Walter Pullen's comment on my recursice division alogorithm I read his simplified approach at Think Labyrinth and implemented a second recursive division solution.

The algorithm works like this: using an orthogonal mazes, divide the area either vertically or horizontally at a random position. Then place a door in a random location in the division just created. The division will create two subsections of the original area. Repeat the process on the subsections if they are bigger then a single cell in height or width. If the subsection is wider then taller, divide vertically. If the subsection is taller then wider, divide horizontally, otherwise for a square subsection make a random choice between horizontal or vertical.

Here is an animated gif I created of this algorithm running:

No comments:

Post a Comment