User:NotBrandX/BSP dungeon generation
So I don't forget; this is how roguelikes create dungeon maps.
- Start with a grid of the entire floor (eg. 80x20) and a minimum room size (eg. 3x3)
- Divide the long side of the dungeon into two sub-dungeons, roughly equal in size, making sure there's enough room on either side for the smallest room size.
- For each sub-dungeon
- if it's bigger than the minimum room size, goto step 2 and use the subdungeon.
- else, for each subdungeon that doesn't have a room in it, pick two random points in one half to be opposite corners in the room; draw the rectangle.
- pick a random points in each of the two subdungeon's room(s) closest to the other subdungeon, imagine a straight line between them. Draw a corridor joining the rooms along this line.
- This sub-dungeon is complete, go do the other subdungeon.
Arrrgh, hard to describe recursion in English; easier to use pictures.