A procedural maze generation system built with Godot 4 and C#, featuring multiple algorithms, 3D maze support, and interactive visualization.
- Multiple Algorithms: Growing Tree, Recursive Backtracker, Binary Tree
- 3D Maze Support: Generate multi-level mazes with stairs between floors
- Configurable Generation: Adjust weights, size, extra walls, and more
- Path Visualization: Display the shortest path solution
- Dead End Hiding: Toggle visibility of dead-end corridors
- AI Agents: Perfect and Random maze-solving agents
- Comprehensive Test Suite: 120 tests with 90% code coverage
- Godot 4.x with .NET support
- .NET 8 SDK
- Clone the repository
- Open the project in Godot 4
- Press F5 to run
dotnet buildRun all tests:
cd tests
dotnet test --blame-hang-timeout 60sRun with coverage:
| Key | Action |
|---|---|
| WASD / Arrow Keys | Pan camera |
| Q / E | Zoom out / in |
| Mouse Wheel | Zoom in/out |
| Z / X | Navigate levels (3D mazes) |
| P | Toggle path display |
| G | Toggle graph display |
| V | Switch to Graph View |
| C | Toggle dead ends |
| R | Regenerate maze |
| H | Toggle controls panel |
| ESC | Return to menu |
| Key | Action |
|---|---|
| WASD | Pan camera |
| Q / E | Zoom out / in |
| N / B | Cycle through alternative paths |
| M | Toggle all paths simultaneously |
| T | Toggle animation mode |
| J | Cycle decision point detail (Off/Badges/Detailed) |
| V | Switch to Tile View |
| Key | Action |
|---|---|
| Space | Play/pause animation |
| < / > | Step backward/forward |
| + / - | Increase/decrease speed |
| T | Exit animation mode |
├── scripts/
│ ├── autoload/ # GameState, ServiceContainer (DI)
│ ├── maze/
│ │ ├── model/ # MazePoint, Direction, MazeCell
│ │ ├── generation/ # Algorithms (GrowingTree, Backtracker)
│ │ ├── solver/ # Graph, ShortestPathSolver
│ │ ├── agents/ # PerfectAgent, RandomAgent
│ │ └── factory/ # MazeFactory, MazeGenerationFactory
│ └── ui/ # MenuUI, MazeMain, MazeLoaderUI
├── scenes/ # Godot scene files
├── resources/ # Sprites and assets
├── tests/ # NUnit test project
└── ProceduralGeneration3DMazes.sln
The primary algorithm with configurable cell selection:
- Newest Weight: Creates long, winding corridors (like recursive backtracker)
- Oldest Weight: Creates shorter, more branching paths
- Random Weight: Creates balanced, organic mazes
Classic depth-first maze generation. Equivalent to Growing Tree with 100% Newest Weight.
Simple algorithm with diagonal bias.
var services = new ServiceContainer();
var settings = new MazeGenerationSettings
{
Algorithm = Algorithm.GrowingTreeAlgorithm,
Size = new MazeSize { X = 20, Y = 20, Z = 1 },
Option = MazeType.DirectedMaze,
GrowingTreeSettings = new GrowingTreeSettings
{
NewestWeight = 75,
OldestWeight = 0,
RandomWeight = 25
}
};
var result = services.MazeGenerationFactory.GenerateMaze(settings);
var shortestPath = result.HeuristicsResults.ShortestPathResult.ShortestPath;var jumper = result.MazeJumper;
jumper.JumpToPoint(jumper.StartPoint);
foreach (var direction in jumper.GetsDirectionsFromPoint())
{
if (jumper.CanMoveInDirection(direction))
{
jumper.MoveInDirection(direction);
break;
}
}| Metric | Coverage |
|---|---|
| Line | 90.65% |
| Branch | 79.81% |
| Method | 92.08% |
Run with coverage:
cd tests
dotnet test /p:CollectCoverage=true /p:CoverletOutputFormat=coberturaThe original Unity implementation is preserved on the unity-legacy branch for historical reference.

