Skip to content

About

A 2D random dungeon generator based on binary tree space partitioning.

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

29 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

English 中文

🏰 Binary Space Partitioning Dungeon Generator | Unity 2022 Implementation

Final Generation Result

📜 Technical Overview

This system implements a ​Binary Space Partitioning (BSP) algorithm to generate procedural 2D dungeons in Unity 2022. The solution features recursive space division and intelligent connection strategies to create highly playable dungeon layouts.

🔍 Core Algorithm Workflow

1️⃣ Initial Space Partitioning

  • 🧩 Initializes from a rectangular bounding box

  • ✂️ Recursively divides space using binary splitting

  • 🎲 Randomly selects split axis (horizontal/vertical) and position

  • ⏹️ Termination condition: subspace reaches preset room size threshold

    Space Partitioning Diagram

2️⃣ Leaf Node Identification

  • 🌳 Constructs complete binary tree data structure

  • 🔢 Assigns unique identifiers to each leaf node

  • 🚪 Leaf nodes correspond to final room units

    Node Identification Diagram

3️⃣ Spatial Relationship Construction

  • 🏗️ Maintains complete tree topology

  • 📐 Records spatial boundary information for each node

  • 🔗 Establishes parent-child and sibling connections

    Complete Tree Structure

4️⃣ Corridor Generation Algorithm

  • 🛣️ Implements bottom-up traversal strategy

  • 🤝 Creates shortest path connections between adjacent spaces

  • 📏 Dynamically adjusts corridor width parameters

    Corridor Generation Result

5️⃣ Wall System

  • 🧱 8-direction neighborhood detection

  • 🔢 Bitmask-based wall calculation

  • 📐 Automatic wall texture angle matching

    Wall Generation Result

📦 Asset Usage Declaration

All art assets are legally licensed: Dungeon Asset Pack by Pixel Poem


🛠️ Tech Stack
Unity 2022 | C# | BSP Algorithm | Procedural Generation

📅 Version Info
v1.0 | Last Updated: November 2023

👨💻 Developer
guobarou

GitHub stars

💡 Ideal for Roguelike, RPG and other games requiring procedural map generation

About

A 2D random dungeon generator based on binary tree space partitioning.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages