Prim's Maze Generator
Generate organic mazes using Prim's minimum spanning tree algorithm.
Prim's Settings
40
30
12
2
Preview
Generation time: -- | Algorithm: Prim's | Size: 40x30
Controls: W/↑ - Forward | S/↓ - Backward | A/← - Turn Left | D/→ - Turn Right
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
How to Use This Tool
- Select Algorithm: Choose between DFS, Prim's, or Wilson's algorithm using the navigation links 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