Homework 1

CS 320

50 points, due Feb. 23, 1998

A maze can be looked at as an array of square cells, where m is the number of rows and n is the number of columns in the maze. Each cell has the property that one to three of its sides (or walls) is present. If two walls are present there is a path into the cell and a path leaving the cell. If three walls are present, the cell is a dead end. It is also possible to have a cell with a single wall. (Note: a maze can be represented by a graph in which each node represents a cell and each branch a connections between cells, i.e., the absence of a wall between adjacent cells.)

You are to use OpenGL to construct and display a maze where m and n are command line inputs to the program. The particular type of maze you are to construct is one in which every cell is connected to every other cell and there is exactly one simple path between any pair of cells.

One method to construct such a maze is to start with an array of cells, each of which has all four walls present. We then remove various walls to construct the desired maze. Consider the following algorithm. Initially all cells are said to be unvisited. We start by selecting (visiting) a random cell. We connect this cell to one of its neighbors by randomly visiting one of its unvisited neighbors. We remove the wall between the two cells to connect them. If any of the other three neighbors has not been visited, we put their identifiers on a stack. If we reach a dead end (a cell all of whose neighbors has been visited), we pop an unvisited cell off the stack. When all cells are visited, the stack is empty and we have a maze. (Note that the algorithm requires a stack and a data structure to keep track of which cells have been visited and which have not been visited.) We can then remove two pieces of the outside wall to create an entrance and an exit to the maze. You are also to show a path in another color from between the entrance and exit.

The graphics part of this project is very simple. You can do most of the work before using any graphics at all. Hence, you should be working on the project even before we have finished our introduction to OpenGL.

The following will be taken into consideration in evaluating your work:

  1. The design of your solution. E.g., elegance.

  2. The generality of your solution. E.g., allowing the user to specify the size of the window on the command line.

  3. Attention to detail. E.g., detecting pathological conditions and doing the ``right'' thing.

  4. Completeness of testing (of course, you need to provide evidence of testing).

This list is not exhaustive.

Your solution is to be e-mailed to Send mail to kelliher AT DOMAIN goucher.edu by 11:59 pm on the 23rd. Attach all relevant files (all files necessary to build your program, documentation files, and test files) to one piece of e-mail; I will not sort out multiple submissions from an individual. The body of the e-mail should be a ``packing list'' describing the attached files. I will build your program from source and run it for myself.



Thomas P. Kelliher
Tue Feb 3 20:10:05 EST 1998
Tom Kelliher