Recursive Division Maze Algorithm

Starting work on a procedural generated maze (which I might make into a dungeon type thing as some point, as you can specify the room size with this algorithm). But anyway...

For those that don't know how this works it is quickly explained here http://amazeaday.blogspot.com/2009/03/recursive-division-part-ii.html

My problem starts with
Then place a door in a random location in the division just created.

Normally this works out fine but sometimes this creates parts of the maze that are completely inaccessible. I don't know if this is a code error or if I am just implementing it incorrectly. (I have tried only creating gaps on even numbers but I get a similar problem). http://puu.sh/9FDSM/e088c38da4.png

Here is my code so far. http://pastebin.com/did57Ea7
Any advice on how to avoid this would be greatly appreciated.

I know this is in C# (didn't even think about that until now...so used to C++) but this is more about the algorithm than the code and this is the only place I am active so don't kill me!).


EDIT:
It seems separating the sides/gaps into even numbers for horizontal and odd for vertical works well enough. Not my favorite solution but it will work if there isn't a better way.
Last edited on
Topic archived. No new replies allowed.