Skip to content

JPDye/Maze-Gen

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Maze-Gen

Being rewritten to improve speed and functionality. Check "rewrite" branch.

Generate Mazes using a number of different algorithms. Colour them, animate them and display them as ASCII art, a png or a gif.

Examples

Recursive Backtracker Algorithm

Pick a random cell and perform a mostly random walk (avoid already visited cells). Store each visited cell on a stack. When a cell is reached that has no viable neighbours (they've already been visited), pop off the stack and repeat. Finish when the stack is empty. Faster than Hunt and Kill but it could rquire Rc's of every cell to be stored on the stack in the worst case. Like Hunt and Kill, it creates mazes with fewer dead ends and longer passages./p>

Hunt and Kill Algorithm

Pick a random cell and perform a mostly random walk (avoid already visited cells). When a cell is reached where there are no unvisited neighbours, end the walk and start a new one at the first unvisited cell that borders a visited cell. Creates mazes with long, windy passages. Not the most efficient algorithm.

Wilson's Algorithm

Loop-erased random walk. Creates mazes with very little bias. Quite inefficient however. Possible implemntation would focus on creating walls and be much faster (since the entire boundary is a wall) so the loop only has to find the boundary rather than the single visited cell as in the current implementation. Would require a rework of existing code however.

Aldous Broder Algorithm

Random walk. Very inefficient but creates mazes with little bias.

Sidewinder Algorithm

Randomly descide whether to carve east or north. If east is chosen add the cell to the current "run". If north is chosen pick a cell in the run and move north from that cell (if possible) and end the run. Repeat until all cells are visited. Creates mazes with an empty passage at the top and a bias for passages running to the north east.

Binary Tree Algorithm

Randomly decide to carve either north or east. If north isn't possible, carve east. If east isn't possible, carve north. If neither can be done, do nothing. This algorithm creates mazes with an empty passage at the north and east of the maze with a strong bias for passages running to the north east.

ToDo

  • Hexagon mazes.

About

Generate, colour and animate mazes.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages