University of Toronto
csc 148S --
Introduction to
Computer Science, Spring 1996
A well-formed rectangular maze is a two-dimensional array of black and white squares with the following properties:
Your definition must be satisfied by the three examples of
well-formed rectangular mazes in Figure 1
and must not be satisfied by the five examples in Figure 2.
In these figures, an arrow denotes the location of an entrance.
Do not be concerned about whether there is a path from the entrance to an exit.
Aim for a small number of simple constraints.
One answer could be
``A well-formed rectangular maze is a two-dimensional array of black and
white squares which is one of the three examples in Figure 1.''
But this is not what is intended and you will get no credit for this or similar
answers.
Write a program that reads a file supposedly describing a well-formed rectangular
maze and checks whether it satisfies your specifications in
question 1 .
Use the following format for your input files.
The first line consists of two positive integers
separated by one or more spaces, denoting the height and width of the maze.
The second line also consists of two positive integers
separated by one or more spaces, denoting the location of the entrance
to the maze, horizontally and vertically, relative to the lower left corner of the maze.
(For example, the square immediately above the
lower left square would be denoted (1,2).)
The remaining lines in the file correspond to the rows of the maze,
listed in order starting from the top of the maze.
The number of such lines (i.e. excluding the first two lines)
should be equal to the height of the maze.
Each of these lines should consist of a sequence of bits.
The number of characters in each line should be equal to the width of the maze,
one for each square in the row from left to right.
In this representation, 0 denotes a white square and 1 denotes a black square.
If the input file's format is incorrect, your program should report the first occurrence
of an error within the file and produce the applicable
error message from among the following list.
Here is a variable that denotes any integer greater than 2.
If the file format is correct, your program should produce one of the following two messages, whichever applies.
You should read all but the first two lines of the file line by line using the command: get line : *
The message produced by your program should appear on a single line,
without any preceding or following spaces.
There should be exactly one space between each word or number
and there should be a period at the end of the message.
Think carefully about how you organize your program
into procedures and functions!
Your external documentation for this program should
consist of an explanation of any limitations of your program and an
explanation of your testing strategy.
In addition to your program, test runs, and external documentation,
you are also required to submit a copy of this program electronically.
Use the ``Hand in'' command, found under the ``Working with files'' icon.
You will be prompted for the name of the file.
You must use the file name maze.t.
The program that will mark the correctness of this part of your assignment is not
terribly clever, and can only compare your
program's output character for character with what we tell it is the correct output.
If your output is different in any way from the expected output, it will be considered wrong.
In addition, you must use the file name maze.t when you hand in this part of
your assignment, or your mark for this part will be zero.
Write a program that allows a user to create a well-formed rectangular maze
on the screen using the mouse (and perhaps the keyboard).
When the well-formed rectangular maze is finished,
the user should be allowed to save it in a file, using the format described in
question 2.
There are two approaches that may be taken.
One way is to write your program
so that, after every step of the construction,
the user has a well-formed rectangular maze.
In other words, the program does
not allow the user to perform any step that results in
a rectangular maze that is not well-formed.
Another way is to require only that the user produce
a well-formed rectangular maze by the
end of the construction.
In this case, you must provide a mechanism for verifying
that a well-formed rectangular maze has been produced when the user claims to be
finished.
Either approach is okay, but you should explain in your external
documentation why you chose the
approach you did.
Your external documentation for this program should
consist of
the explanation for your approach to the problem,
an explanation of any limitations of your program, and
an explanation of your testing strategy.
To document the testing you have performed, include up to 20 screendumps.
These let you send the current contents of your screen to the printer.
Information about screendumps and using the mouse in OOT programs
can be obtained by picking up the files
dump.inf and mouse.inf respectively.
The file mouse.t is an example of an OOT program interacting
with the mouse.
University of Toronto
CSC
Complete this page, and tape it to the front of the envelope containing your assignment.