Create random maze using the spanning tree algorithm from "How to Build a Maze", David Matuszek, Byte Magazine, vol.6, n.12, pp.190-196, December 1981, https://archive.org/details/byte-magazine-1981-12 Download everything: newmaze.zip create.c - create maze draw.c - draw maze maze.c - utility routines maze.h - constants and datatypes Use maze.sh to create and draw (gif) a maze and solution, or draw.sh to draw (gif) from existing maze data. See examples in data/ Any two edge cells can be used for the entrance and exit, but the code here always uses the top left and bottom right cells. After generating the spanning tree, additional cell walls can be broken, which may make the maze harder to solve. Manual examples using the C programs directly: % cat data/m-2-4a.txt 2 4 0 1 0 0 1 0 0 0 1 1 0 1 0 1 1 1 % ./draw < data/m-2-4a.txt _______ _ | | |_ _ _|_ % ./draw -x < data/m-2-4a.txt XXXXXXXXXXXXXXXXXX XX XX XXXXXX XX XX XX XX XX XXXXXXXXXXXXXXXXXX % % ./create > j % ./draw < j % ./draw -x < j % ./draw -g < j | ./mazeplot.sh > j.gif % eog j.gif & % ./draw -g -s < j > solve.out % ./draw -g < j | ./solveplot.sh > j.gif % % ./create > m-8-16.txt % ./draw -g -s < m-8-16.txt > m-8-16-solve.txt % ./draw -g < m-8-16.txt | ./solveplot.sh m-8-16-solve.txt > m-8-16-solve.gif