← Back to Hub

Binary Space Partitioning (BSP)

The Concept

BSP works by recursively splitting a large rectangle into smaller ones. Once the areas are small enough, we place a room inside each one and connect them with corridors.

This method produces very structured, "man-made" looking dungeons.

Core Logic


function split(rect) {
    if(rect.w > MIN_SIZE || rect.h > MIN_SIZE) {
        // Choose horizontal or vertical split
        // Add children to leaf node
    }
}