Procedural Dungeon Generation Tool
Engine: Unity Language: C#
Focus: Tool Development, Procedural Content Generation (PCG), Algorithm Design
This project is a procedural dungeon generation system designed to function as a robust level design tool. The core objective was to solve the common PCG problem of "Chaos vs. Order" by moving beyond simple noise functions that often create unplayable, disconnected islands. Instead, I engineered a hybrid architecture that combines the guaranteed connectivity of constructive algorithms with the organic erosion of simulation-based methods.
The result is a scalable tool that instantly generates fully traversable, tactical cave environments, complete with context-aware prop placement and lightweight enemy AI.
Overview
The Generation Logic
The Skeleton (Biased Random Walkers):
To guarantee player traversability without relying on expensive flood-fill validation, the system uses biased Random Walkers. This mathematically ensures the layout is a single Connected Component.
The Flesh (Cellular Automata):
I implemented a Moore Neighbourhood simulation pass with a strict survival threshold to erode isolated wall blocks. This smooths the rigid walker paths into organic, cave-like structures.
Space Partitioning (BSP Variation):
Early testing revealed that the cellular automata smoothing often created large, empty zones lacking tactical cover. I developed a custom partitioning algorithm as a post-processing pass. The system scans for large contiguous floor spaces and procedurally instantiates dividing walls, bisecting the voids to create defined combat arenas that break lines of sight.


Deterministic Tooling & Code
Deterministic Tooling (Stable Hashing):
Pure randomness makes QA testing and bug-fixing nearly impossible. To ensure this generator functioned as a true commercial development tool, I bypassed Unity's standard randomization and built a custom Stable Hash function. This guarantees that inputting a specific text string (e.g., "PSGAM") will yield the exact same integer sequence and generate the identical dungeon layout across any hardware architecture.

Engineering Solutions & Post-Mortem
Critical UX & Problem Solving:
Instantiation Bottleneck & Physics Clipping:
Generating large grids initially caused severe frame-rate spikes due to thousands of Instantiate() calls, and enemies frequently spawned clipped into floor geometry due to pivot-point discrepancies.
The Solution:
I refined the instantiation logic to calculate valid "Safe Tiles" with at least one open neighbour to prevent wall-spawning. I also implemented precise Vector3 vertical offsets to fix the centre-of-mass physics clipping. For future scalability, the core architecture has been structured to transition into an Object Pooling system to eliminate garbage collection overhead during rapid regeneration.

Critical Reflection & Takeaways
Algorithmic Power vs. Designer UX (Tool Usability):
Critically evaluating the project not as a game, but as a tool, the biggest oversight was the lack of Editor Guardrails. While the C# logic is highly robust, exposing raw float variables (like walker bias, iteration counts, and survival thresholds) directly in the Unity Inspector allowed for unpredictable inputs. If a Level Designer pushed the cellular automata iteration count too high, it would erode the entire map into a single empty room, effectively breaking the tool.
The Takeaway:
Building complex PCG algorithms is only half the job of a Technical Designer; the other half is creating an idiot-proof UX for the rest of the team. In future tool development, I will prioritize building custom Editor Scripts and Inspector GUIs that clamp variable ranges and provide visual debugging overlays in the Scene View before runtime. A tool is only successful if a non-technical designer can use it without needing to read the source code.