|Maze Maker||Lab Report|
The purpose of this program is to draw a maze of a specified size and show the solution path.
Materials and Equipment
Delphi 4 only (Will not compile in Delphi 3 since new Delphi 4 features are used)
The WMGetMinMaxInfo routine in the ScreenMazeMaker unit enforces a minimum window size as a response to a Windows wm_GetMinMaxInfo message.
The UpdateMaze routine in the ScreenMazeMaker unit is called by the various controls whenever a value changes that affects the maze.
Direct entry of values in the SpinBoxes can cause problem when the SpinBox is blank. Borland should make a TSpinBox more than an undocumented "Sample," especially by version 4 of Delphi.
The Maze Algorithm is in the MazeLibrary unit in the DrawMaze routine. Each cell in the maze is represented by a 2-bit quantity (a 0..3 type) in a dynamically-allocated two-dimensional Cells array using the Delphi 4 SetLength routine. Bit 0 is set if the cell has an East exit, and bit 1 is set if it has a South exit. To test if a North or West exit exists, the appropriate adjacent cells must be considered.
The DrawMaze routine shows an interesting way to create a stack in Delphi. In-line assembly language was used to Push and Pop values off a memory stack without any other code to implement the stack.
The Rainbow Path Color is one way to segment the solution path into regions. The function WavelengthToColor in the SpectraLibrary unit returns a TColor for a given wavelength of light from 380 to 780 nanometers. The maze path was scaled to vary between these extremes.
The MazeMaker is an interesting recreational math program.
For a given array of maze cells, a study of the distribution of the maze length may be interesting.
The Borland February 2000 Delphi Games Contest had some interesting maze generators:
Random Maze Generator
Delphi for Fun: Maze Generator
Maze Construction FAQ
Books (Amazon Links)
Mazes and Labyrinths: Their History and Development
Labyrinths and Number Mazes
Puzzles, Mazes and Numbers
Maze algorithm, ScrollBox, FormResize, wm_GetMinMaxInfo, rainbow colors, stack, Ellipse, MoveTo, LineTo, FrameRect, FillRect
Delphi 4 Source and EXE (208 KB): MazeMaker.ZIP
Because Delphi 4 dynamic arrays were used in the MazeLibrary unit to create an "array of array of 0..3", and because of default parameters used in the DrawMaze routine, this program will NOT compile in Delphi 3.
The maze generation algorithm in the MazeLibrary unit is Copyright © 1999 by Gary Williams, email@example.com and is used with permission.
Updated 18 Feb 2002
since 28 Feb 1998