Maze Cube Generator creates random multi-dimensional mazes similar to the Oskar's Cube.
Features:
- Custom maze sizes
- Custom solution lengths
- Hyper-dimensional mazes
- Finds solutions
- STL output (3D only)
- Unfolded STL for easier 3D printing (3D Only)
- Multiple metrics to guage maze difficulty
To build the maze cube generator on Linux or macOS you will first need to
install an appropriate compiler (e.g., llvm, gcc, or Xcode) as well as cmake
.
Once the build tools are installed, compile Maze Cube Generator with:
cmake .
make
Maze Cube Generator is a command-line program with options to control its behavior. Below is a list of command-line options and their purpose.
Basic:
-d size
Generate a new maze with given size (size
format: l,w,h
or l,w,h:options
, e.g., 11,11,11
or 11,11,11:r
).
-h
Print usage information.
-i filename.txt
Load an existing maze from filename.txt
as produced by -o
.
-m filename.stl
Write maze as STL to filename.stl
.
-f filename.stl
Write flattened maze as STL to filename.stl
.
-u filename.stl
Write maze as more easily printable STL to filename.stl
.
-o filename.txt
Write maze as reloadable (-i) text to filename.txt
.
-p solution.stl
Write solution as STL to solution.stl
(implies -s
).
-r num
Seed random number generator using num
.
-s
Find a solution to the maze.
-x
Scale factor when exporting to STL.
Advanced:
-l num
Generate mazes until a solution with length ≥num
is found.
-k num
Generate mazes until at most num
disconnected regions in maze.
-g filename.gv
Writes an input file for graphviz to filename.gv
.
-e width
Specified minimum edge width for faces that are printed flat (-f & -u) (default: 0.4).
Basic random maze generation:
$ ./mcg -r 12345 -d 11,11,11 -o output.txt
Seeds the random number generator with 12345
, generates a random 11x11x11 maze and stores the results in output.txt
.
Larger maze with long solution:
$ ./mcg -r 1 -d 21,21,21:o -l 70 -k 1 -m maze21.stl -o maze21.txt
Seeds the random number generate with 1
, generates random 21x21x21 mazes
until one with a solution of 70 or more is found and all maze positions belong
to the same region. The resulting maze is then stored in maze21.stl
and
maze21.txt
.
Maze generation with optimized start & end locations:
$ ./mcg -r 12345 -d 11,11,11:o -o optimal.txt
Seeds the random number generator with 12345
, generates a random 11x11x11 maze, finds start & end points that maximize solution length, and stores the results in optimal.txt
.
Solve an existing maze:
$ ./mcg -i unsolved_maze.txt -s -o solved_maze.txt
Loads a maze from unsolved_maze.txt
, finds the solution, and writes the maze
along with the solution to solved_maze.txt
.
Write 3D model of solution:
$ ./mcg -i unsolved_maze.txt -s -p solution.stl
Loads a maze from unsolved_maze.txt
, finds the solution, and writes a 3D
model of the solution to solution.stl
.
Write unfolded/flattened model:
$ ./mcg -i maze.txt -f maze_flat.stl
Loads a maze from maze.txt
and writes a flat-pack style 3D model to
maze_flat.stl
for faster 3D printing.
Write mostly assembled model:
$ ./mcg -i maze.txt -u printable.stl -x 5.0
Loads a maze from maze.txt
and writes a mostly assembled 3D model to
printable.stl
for an easier to assemble 3D print at 5x scale.
Hyper-dimensional maze:
$ ./mcg -r 1 -d 11,11,11,11:o -s -o maze4d.txt
Generates a 4-dimensional maze with size 11x11x11x11, and writes the maze
along with its solution to maze4d.txt
.