Maze Generator
Generate complex mazes and dungeons with multiple algorithms
DFS Settings
Preview
About Depth-First Search (DFS)
Depth-First Search (DFS) is a recursive backtracking algorithm that creates mazes with long, winding corridors. It starts at a random cell and explores as far as possible along each branch before backtracking.
- Characteristics: Creates mazes with long, twisting passages and few dead ends
 - Complexity: O(n) time where n is the number of cells
 - Best for: Traditional mazes, puzzles, exploration-based games
 - Path type: Guaranteed single solution path between any two points
 
About Prim's Algorithm
Prim's Algorithm is a minimum spanning tree algorithm adapted for maze generation. It grows the maze outward from a starting point, creating a more organic, branching structure.
- Characteristics: Creates mazes with more branching and shorter passages
 - Complexity: O(n log n) time with proper data structures
 - Best for: Dungeon layouts, room-based mazes, organic structures
 - Path type: More uniform distribution of paths with moderate dead ends
 
About Wilson's Algorithm
Wilson's Algorithm is a loop-erased random walk algorithm that generates unbiased, uniform spanning trees. It produces mazes where all possible mazes of the same size are equally likely.
- Characteristics: Creates perfectly unbiased mazes with uniform distribution
 - Complexity: O(n) expected time, slower initially but guarantees uniformity
 - Best for: Fair puzzles, roguelike games, unbiased procedural generation
 - Path type: Completely random and unbiased maze structure
 
How to Use This Tool
- Select Algorithm: Choose between DFS, Prim's, or Wilson's algorithm using the tabs above
 - Adjust Parameters: Customize maze size, cell size, and wall appearance
 - Generate: Click "Generate Maze" to create a new maze with current settings
 - Preview Controls: Use zoom buttons to inspect maze details, pan by dragging
 - Export: Download your maze as JSON (for data) or TMX (for Tiled map editor)
 
Export Formats
JSON Format
Exports maze data as a JSON file containing:
- Maze grid structure (walls and paths)
 - Dimensions and cell information
 - Algorithm metadata
 - Easy to parse for custom game engines
 
TMX Format (Tiled Map Editor)
Exports maze as a TMX tilemap file compatible with:
- Tiled Map Editor for visual editing
 - Game frameworks like Phaser, Unity, Godot
 - Layer-based structure with walls and floors
 - Embedded tileset definitions
 
Maze Generation Algorithms Explained
Maze generation algorithms are essential in game development, procedural content generation, and computer science education. Each algorithm produces different maze characteristics suitable for various applications:
Choosing the Right Algorithm
- For puzzles and traditional mazes: Use DFS for its long, winding corridors that create challenging navigation
 - For dungeons and organic layouts: Prim's algorithm creates more natural, branching structures
 - For fair, unbiased generation: Wilson's algorithm ensures no algorithmic bias in maze structure
 
Game Development Applications
These mazes are perfect for:
- Roguelike and dungeon crawler games
 - Puzzle games requiring navigation challenges
 - Procedurally generated levels in indie games
 - Educational projects teaching pathfinding algorithms
 - Game jams and rapid prototyping