Mazex is a tool for generating mazes using different algorithms and rendering them as png images.
| Instalation | Usage | Algorithms | License
In order to generate mazes with mazex
you need to have Elixir installed.
After that you can clone this repository and compile the project by running mix compile
Maze can be generated by using mix mazex
task. The task accepts the following options:
## Options
--rows # Number of rows for the maze
--columns # Number of columns for the maze
--algorithm # One of the following algorithms: aldous_broder, binary_tree, kruskal, prim, recursive_backtracker, sidewinder, wilson
--output # Output folder if not given it will use the current folder as output folder
--filename # File name to be used for generated maze image, if not given it will use the maze_<current_timestamp>.png.
Example:
mix mazex --rows=10 --columns=15 --algorithm=binary_tree
mix mazex --rows=10 --columns=15 --algorithm=sidewinder --output=/tmp --filename=maze.png
Supported maze algorithms:
Binary Tree produces mazes by visiting each cell in a grid and carving a passage either south or east. This causes a bias toward paths which flow down and to the right.
Sidewinder is based upon Binary Tree, but tries to group adjacent cells together before carving a passage south from one of them.
Aldous-Broder picks a random cell in the grid and the does a random walk by choosing a random unvisited neighbor. The algorithm ends when all cells have been visited.
Wilson's starts at a random cell and then does a random walk. When it introduces a loop by coming back to a visited cell, it erases the loop then continues the random walk from that point. The algorithm produces a completely unbiased maze.
Recursive Backtracker uses a random-walk algorithm. When it encounters a dead end, it backtracks to the last unvisited cell and resumes the random walk from that position. It completes when it backtracks to the starting cell.
Kruskal's algorithm is focused on generating a minimum spanning tree.
Prim's algorithm generates a minimum spanning tree by starting with a position and adding the cheapest edge available. Weights are assigned randomly to ensure a less biased maze.
Copyright © Alexandru Bogdan Bâgu
Distributed under the MIT License.