There's probably another implementation like this somewhere. I just wanted to get away from the floor/wall style of generation where a cell can only be one or the other. I know I'll be using this for generating maps where each cell is a screen. That means each cell takes care of its own walls.
I used a 70x70 map for the demo.
Granted, mazes probably aren't the goal for most maps. Here's an idea to make a similar map more open. I have yet to try it... but it sounds nifty! ;)
- Generate one Prim maze. Calculate the distance to each cell from the starting point.
- Generate a second Prim maze and pretend it overlays the first.
- If a connection between cells only exists in the second maze, find the absolute value of the difference in distance.
- If the difference is below a certain minimum, just add the connection.
- Otherwise, make it a door or guard or some other obstacle depending on how high the value is.