Abstract
Design and implementation of a Python program to generate satisfyingly challenging pencil mazes.

This publication is available in Web form and also as a PDF document.
Please forward any comments to tcc-doc@nmt.edu.
Table of Contents
cell-key and
wall-keymain(): The main programApp class: The application as a
wholeApp.__init__(): The
constructorApp.__commandLine(): Process the
command line argumentsApp.__newSeed(): Randomize the random
seedApp.__createWidgets(): Create all
Tkinter widgetsApp.__seedHandler(): Regenerate with
a given random seedApp.__showHandler(): Turn display of
the solution on or offApp.redoHandler(): Regenerate the
mazeApp.saveHandler(): Save the current
imageclass Maze: The maze and its
renderingMaze.__init__(): ConstructorMaze.generate(): Create a new
mazeMaze.__buildMaps(): Construct cells
and wallsMaze.__addWall(): Build one wallMaze.__makePath(): Create the
solution pathMaze.__extendPath(): Add one cell to
the pathMaze.__genNeighbors(): Find the cells
adjacent to a given cellMaze.__exitCheck(): Is there an open
route to the goal from this cell?Maze.__addReachables(): Compute the
transitive closure of the neighbor relationMaze.__cutPath(): Remove walls along
the solution routeMaze.__wallBetween(): What wall
divides two adjacent cells?Maze.killWall(): Remove one
wallMaze.getWallCells(): What cells
adjoin this wall?Maze.__kruskal(): Connect remaining
cells to the solutionMaze.render(): Draw the maze on a
canvasMaze.__tkWall(): Draw a cell
wallMaze.__toDisplay(): Convert to
display coordinatesMaze.__annotate(): Add descriptive
textMaze.pathDraw(): Show the solution
pathMaze.__pathEdge(): Draw one segment
of the solution pathMaze.__cellCenter(): Display
coordinates of the center of a cellMaze.blob(): Render one endpoint of
the solutionMaze.pathErase(): Remove the solution
path from the canvasMaze.postscript(): Export the
contents of the canvas as PostScriptclass Path: The solution pathclass Cell: One cell in the mazeclass Wall: One wall in the
mazefatal(): Write a message and
terminateHere is the rationale for this project.
Some people, including the author, find pencil mazes an amusing pastime.
The present program presents what may be a novel way to generate mazes that tend to be more challenging than mazes generate using algorithms in wide use.
This project is an example of lightweight literate programming: the program itself is contained in the documentation, rather than embedding documentation in the program or making it a separate entity.
This project is also an example of Cleanroom software engineering. In particular, comments [ within square
brackets ] are Cleanroom intended functions, an
informal mathematical notation used to verify the
correctness of the implementation.
The project demonstrates the use of the Python language and two Python subsystems: the Tkinter graphical user interface and the pexpect module for running auxiliary processes.
This work is licensed under a
Creative Commons Attribution-NonCommercial-ShareAlike 3.0
Unported License.