No Title



next up previous
Next: About this document

University of Toronto
csc 148S -- Introduction to Computer Science, Spring 1996

Assignment 2: MAZES


Due: ~Wednesday 5 February, 6:00 pm

This assignment is worth 10 marks towards your final grade.

Introduction



This assignment has a number of goals: You will get practice writing and understanding specifications. You will be producing a relatively large amount of code, so it provides a good opportunity for you to use the software engineering techniques discussed in class. You will also be able to practice writing internal and external documentation.
Your overall task is to provide tools for creating well-formed rectangular mazes. See Figure 1 for some examples of well-formed rectangular mazes. Figure 2 contains some examples that are not well-formed rectangular mazes.

Question 1: Specifications



Write a complete, clear, and concise definition of well-formed rectangular maze by completing the following.

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.

Question 2: Checking



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.

Question 3: Ambiguity



The output specifications described in question 2 are ambiguous in some cases.
  1. Give an example of an input file for which there is more than one output message that is consistent with these output specifications.
  2. Explain what to add to these specifications so that any ambiguity is eliminated.

Question 4: Creation



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.

Question 5: Data Structure



Clearly describe the data structure your programs in questions 2 and 4 use to represent the well-formed rectangular maze being checked or created.

Question 6: User's Guide



Provide a clearly written user's guide for your program in question 4. It should be suitable for a ten year old to understand. The text of your guide should be about one to two pages long. Be sure to describe any constraints or limitations imposed by your program.

What to Hand In



Tentative Grading scheme



Below is the tentative grading scheme. Although we reserve the right to change it somewhat, it should give you an idea of where to focus your efforts.

University of Toronto
CSC

148
S
-Introduction to Computer Science, Spring 1996

Cover sheet for Assignment 2



Complete this page, and tape it to the front of the envelope containing your assignment.





next up previous
Next: About this document



Diane Horton
Fri Jan 26 17:19:33 EST 1996