Table of Contents
main(): The main program
Appclass: The application as a whole
App.__init__(): The constructor
App.__commandLine(): Process the command line arguments
App.__newSeed(): Randomize the random seed
App.__createWidgets(): Create all Tkinter widgets
App.__seedHandler(): Regenerate with a given random seed
App.__showHandler(): Turn display of the solution on or off
App.redoHandler(): Regenerate the maze
App.saveHandler(): Save the current image
class Maze: The maze and its rendering
Maze.generate(): Create a new maze
Maze.__buildMaps(): Construct cells and walls
Maze.__addWall(): Build one wall
Maze.__makePath(): Create the solution path
Maze.__extendPath(): Add one cell to the path
Maze.__genNeighbors(): Find the cells adjacent to a given cell
Maze.__exitCheck(): Is there an open route to the goal from this cell?
Maze.__addReachables(): Compute the transitive closure of the neighbor relation
Maze.__cutPath(): Remove walls along the solution route
Maze.__wallBetween(): What wall divides two adjacent cells?
Maze.killWall(): Remove one wall
Maze.getWallCells(): What cells adjoin this wall?
Maze.__kruskal(): Connect remaining cells to the solution
Maze.render(): Draw the maze on a canvas
Maze.__tkWall(): Draw a cell wall
Maze.__toDisplay(): Convert to display coordinates
Maze.__annotate(): Add descriptive text
Maze.pathDraw(): Show the solution path
Maze.__pathEdge(): Draw one segment of the solution path
Maze.__cellCenter(): Display coordinates of the center of a cell
Maze.blob(): Render one endpoint of the solution
Maze.pathErase(): Remove the solution path from the canvas
Maze.postscript(): Export the contents of the canvas as PostScript
class Path: The solution path
class Cell: One cell in the maze
class Wall: One wall in the maze
fatal(): Write a message and terminate
Here 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.