BSP Tree Dungeon Generator for Roguelikes

Monkey Forums/Monkey Code/BSP Tree Dungeon Generator for Roguelikes

Gerry Quinn(Posted 2013) [#1]
I got interested in the topic and ended up creating one.

You can run the code as an app. Press N for a new dungeon. There are various parameters and consts that you can tweak.

Making the BSP tree itself is pretty easy - the hardest part is making nice paths to join the zones.




impixi(Posted 2013) [#2]
Nice.


Gerry Quinn(Posted 2013) [#3]
Just to note, the parameters in the example give a very large dungeon with oodles of small rooms. For a dungeon that would be more realistic in a game, change the parameters in OnUpdate to to something like:

generator = New BSPGenerator( 80, 60, 6, 20 )

You could also mess with the NOSPLIT and FAVOURBEND factors.

There are also non-parametised things you could vary in BSPGenerator.MakeRooms and BSPRect.Split.

The code doesn't do any sanity-checking but I think it should be pretty robust if you don't do anything too crazy. It should be obvious that NOSPLIT_PERCENT should be less that 100 and EDGEAVOID should be a small positive fraction. FAVOURBEND can be anything from 0..1000: 1.0 is a neutral value. minSize will have some lower limit I think, probably 2-3 - but who wants microscopic rooms anyway? If you want tangled corridors, make small rooms into corridors or mini-mazes in MakeDungeon.


Why0Why(Posted 2013) [#4]
This is really nice. I appreciate you posting!