game dev Nov 2024
Procedural Dungeon Generation in Godot 4
A deep dive into BSP tree dungeon generation with working GDScript, room placement heuristics, and corridor carving.
Binary Space Partitioning is one of the cleanest algorithms for dungeon generation. You recursively split a rectangle, place rooms in the leaves, and connect siblings with corridors. The result feels handcrafted even though it's entirely procedural.
This write-up walks through my Godot 4 implementation: the BSP tree class, room sizing variance, L-shaped corridor carving, and how to decorate rooms with weighted random furniture placement.