This document provides context for AI coding assistants working on this project.
This is a Godot 4 C# procedural maze generation project. It generates 3D mazes using various algorithms and provides visualization and solving capabilities.
# Build the main project
dotnet build
# Build and run tests
cd tests && dotnet test
# Run tests with coverage
cd tests && dotnet test /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura /p:CoverletOutput=./coverage/
# Run specific test category
cd tests && dotnet test --filter "FullyQualifiedName~AgentTests"
# Run experiments (benchmarking/analysis)
cd experiments && dotnet run
# Run benchmarks (performance testing)
cd benchmarks && dotnet run -c Release
# Run specific benchmark
cd benchmarks && dotnet run -c Release -- --filter "*ShortestPath*"
# Quick benchmark run
cd benchmarks && dotnet run -c Release -- --job shortThe project uses manual DI via ServiceContainer.cs. All services are instantiated in the constructor - no runtime DI framework.
var services = new ServiceContainer();
var result = services.MazeGenerationFactory.GenerateMaze(settings);| Class | Purpose |
|---|---|
GameState |
Godot autoload singleton, holds settings and current maze |
ServiceContainer |
Manual DI container, instantiates all services |
MazeGenerationFactory |
Main entry point for maze generation |
MazeJumper |
Navigate through a generated maze |
ShortestPathSolver |
Dijkstra-based pathfinding |
MazeGenerationSettings→ ConfigurationMazeModelFactory→ Creates maze model (Model1/2/3)Algorithm.GenerateMaze()→ Carves passagesDeadEndFiller→ Wraps model for dead-end hidingHeuristicsGenerator→ Calculates statistics and shortest pathMazeGenerationResults→ Final output with maze and stats
Directions are flags-based for efficient storage:
public enum Direction
{
None = 0,
Left = 1, Right = 2,
Down = 4, Up = 8,
Back = 16, Forward = 32
}- X axis: Left (-X), Right (+X)
- Y axis: Back (-Y), Forward (+Y)
- Z axis: Down (-Z), Up (+Z)
In Godot 2D rendering:
- Positive Y goes down on screen
- Forward (Y+1 in maze) renders as going down
- Back (Y-1 in maze) renders as going up
| File | Purpose |
|---|---|
MazeGenerationTests.cs |
Basic maze generation, all algorithms |
MazeConnectivityTests.cs |
Path finding, connectivity verification |
AgentTests.cs |
PerfectAgent, RandomAgent behavior |
MazeComponentTests.cs |
MazeHelper, MazeJumper, utility classes |
EdgeCaseTests.cs |
Small mazes, edge cases, direction parsing |
- Main project:
ProceduralGeneration3DMazes.csproj - Tests:
tests/ProceduralMaze.Tests.csproj - Experiments:
experiments/ProceduralMaze.Experiments.csproj - Benchmarks:
benchmarks/ProceduralMaze.Benchmarks.csproj - Godot scenes:
scenes/*.tscn - Maze logic:
scripts/maze/ - UI code:
scripts/ui/
- Add maze logic in
scripts/maze/(pure C#, no Godot dependencies) - Wire up in
ServiceContainer.csif new service - Add tests in
tests/ - Add UI in
scripts/ui/andscenes/
# From Godot editor - open project and press F5
# Or from command line:
/path/to/godot --path .The project includes BenchmarkDotNet benchmarks for performance-critical code.
# List all available benchmarks
cd benchmarks && dotnet run -c Release -- --list flat
# Run all benchmarks (takes several minutes)
cd benchmarks && dotnet run -c Release
# Run specific benchmark class
cd benchmarks && dotnet run -c Release -- --filter "*MazeGeneration*"
# Quick run for development
cd benchmarks && dotnet run -c Release -- --filter "*ShortestPath*" -j short
# When running benchmarks as an AI agent, pipe through tail to reduce output
cd benchmarks && dotnet run -c Release -- --filter "*ShortestPath*" -j short 2>&1 | tail -30| File | Benchmarks |
|---|---|
MazeGenerationBenchmarks.cs |
Algorithm comparison (Backtracker, GrowingTree, BinaryTree) at various sizes |
PathfindingBenchmarks.cs |
GraphBuilder and ShortestPathSolver at various maze sizes |
HelperBenchmarks.cs |
ArrayHelper.Shuffle, DirectionsFlagParser performance |
Always benchmark before and after changes:
-
Run relevant benchmarks before making changes:
cd benchmarks && dotnet run -c Release -- --filter "*YourArea*" --exporters json
-
Make your changes
-
Run the same benchmarks after:
cd benchmarks && dotnet run -c Release -- --filter "*YourArea*" --exporters json
-
Compare results in
benchmarks/BenchmarkDotNet.Artifacts/
ShortestPathSolver.ProcessGraph- Hybrid Dijkstra: O(n²) for small graphs, PriorityQueue O(n log n) for large graphs (threshold: 1500 nodes)GrowingTreeAlgorithmLinkedList- UsesElementAt()which is O(n) on LinkedListDirectionsFlagParser.SplitDirectionsFromFlag- Called frequently, allocates arrays- Maze generation algorithms - Main user-facing performance