Generates mazes using various algorithms.
Special thanks to Jamis Buck for writing the blog posts I used to learn these algorithms. Jamis Buck's blog.
The currently supported algorithms are:
- Kruskal
- Prim
- Recursive Backtracker
- Aldous-Broder
- Growing Tree
- Add oldest cell
- Add newest cell
- Add middle cell
- Add random cell
- Allow mixing of methods
- Hunt-and-Kill
- Wilson
- Eller
- Recursive Division
- Sidewinder
- Binary Tree
- North-West
- North-East
- South-West
- South-East
Each step of generating a maze can be written to a file using the -v flag.
Running MazeCreator -v demo.steps 2 2 may produce the maze:
#####
# X#
### #
#S #
#####
and a file names demo.steps that contains:
#####
# # #
#####
# # #
#####
#####
# # #
### #
# # #
#####
#####
# #
### #
# # #
#####
#####
# #
### #
# #
#####
#####
# #
### #
#S #
#####
#####
# X#
### #
#S #
#####
To build, simply run:
mkdir build
mkdir lib
mkdir bin
cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build
The compiled program will be found in bin.
Simply running MazeCreator will generate a 10x10 maze.
Running MazeCreator <W> <H> will generate a maze of size WxH.
This is an example of a generated maze:
#####################
# X # # # #
### ##### # # # ### #
# # # # # #
# # ### # ### ##### #
# # # # # # # # #
# ### # ##### # # # #
# # # # # # #
# ### # # # # # # # #
# # # # # # # #
# # # # # ######### #
# # # # # #
# ##### ### ### #####
# # # # # # # #
### # ### ### ### ###
# # # # #
# ######### # ### # #
# # # # # #
# ### # # ### ##### #
# # # # S#
#####################
The following symbols are defined for a maze:
- # - Wall
- space - Path
- S - Starting location
- X - Destination
- : - Observing
- Q - Queued
A valid maze will have:
- A border of walls.
- A start labeled
S. - An end labeled
X.
The maze consist of cells. Each cell is defined as a 9x9 grid of text.
This is an example of a cell:
###
# #
###
Only the 4 cardinal directions (up, down, left, right) are considered for walls. The corners are included mainly for alignment and ascetics.
This is an example of a cell with no walls:
# #
# #
Two neighboring cells will share the same wall.
This is an example of two neighboring cells (1 and 2):
#####
#1 2#
#####
This is an example of four cells in a 2x2 formation:
#####
#1 2#
### #
#3 4#
#####
Notice that for a maze of size MxN, it takes
Observing cells (:) only come into play for verbose step generation. The observing cell allows the user to see which cells the algorithm is currently considering for processing.
Queued cells (Q) cells only come into play for verbose step generation. The queued cells are cells that the algorithm is remembering, but not actively observing.
- Maze Viewer (text based)
- Maze Generator
-
-
- Add oldest cell
-
-
-
- Add newest cell
-
-
-
- Add middle cell
-
-
-
- Add random cell
-
-
-
- Allow mixing of methods
-
- Verbose Steps
- Write Help