Adventures in the Imaginary Land of Gack

MCS-178: Introduction to Computer Science II

Prelab

In this lab you will work on your own. You will be using object-oriented programming to extend an adventure game, the Land of Gack. This game is explained in section 14.5 of the text, so you should read that section before coming to lab.

In lab

Since this lab involves the object-oriented programming system, you will need to tell DrScheme to load in that system. To do this on any of the machines in the MCS department lab, you select "Add Teachpack..." from DrScheme's "Language" menu, and then in the dialog box that comes up, select oops.ss. If you are working on your own machine, you will need to first obtain a copy of oops.ss; see the web site of supporting materials for the book.

The code for the game has been divided into a collection of individual files, but for convenience there is a single ``master file'' called game.scm which loads all the others in. The first thing you should do is to copy the whole collection of files, so that you will be able to modify any of them as the need arises. If you add any additional files (for example, for newly added classes), you should extend your copy of game.scm to load in the new files as well.

To make a copy of all the files, the simplest approach would be to use the shell to copy the whole directory containing the files. If you are in a shell window, type:

         cp -r ~mc28/labs/gack/gack .
(note that this command ends with a space and then a period), you will get a subdirectory called gack containing all the files. Ask for help with this if you need it.

You should open your own copy of game.scm in DrScheme. To play the game, press the Execute button in this window and then evaluate (play) in the associated interaction window.

If you want to edit one of the other files, open it up in its own window in DrScheme, make your changes, and save the file back out. But don't press the Execute button in that window. Instead, press the Execute button back in the window that holds game.scm

Following are links to the various files that comprise the program, together with short descriptions. These links should be useful when you are programming, since you will typically be working on one of the class files, but will need information about various other classes or utility procedures.

Once you have copies of the files made and loaded in, you are to do exercises 14.33, 14.34, and 14.35, on pages 568 through 570. In coming up with ideas for the open-ended exercise 14.35, you may also want to look at exercise 14.42 on pages 572 and 573.

For the open-ended exercise, be sure to make changes which require some change or addition to the class hierarchy, some additional method, and some additional instance variable.

Our implementation of the object-oriented programming system contains two useful procedures, not mentioned in the text, called oops-display and oops-describe. Calling (oops-describe arg) will give a reasonable representation of arg even if arg recursively contains itself. The procedure oops-display is the one that the object/describe method uses for displaying each of the instance variables values in a summary form -- for example [an object of class witch] or [a 3421 element vector]. The procedure oops-describe, by contrast, will oops-display the first few elements of a 3421 element vector followed by ...

Both procedures are useful when debugging, when you don't know for sure in advance what type of value you are going to encounter (because the bug may be precisely that you have the wrong type, for example the person object rather than the symbolic name of the person).

Postlab

Focus your report on the open ended exercise 14.35. The warm-up exercises need not be mentioned in the body of your report. You'll be electronically submitting the code, so you'll only need to include excerpts as needed in the project report.

Your audience for this report is a fellow programmer (or team of programmers) who will be extending your game. You can assume the audience knows Scheme and the OOPS implementation from the book. All aspects of your report, including the introduction, should be addressed to this audience. (If there are comments that you wish to make to the grader, you can put those in an appendix.) As always, your report should focus on what the final product is, and not on the assigment. Sentences starting, ``We were asked to...'' and ``The first thing we did in lab is...'' should not appear in your project report.

You'll want to briefly describe your game to the audience (with emphasis placed on those parts that differ from the original version.) One thing I'll be looking for is a clear description of your final class hierarchy early in the report. (A diagram helps!) As always, emphasize the final product rather than each incremental change you made. Make sure that your English text provides context for the Scheme code rather than echoing it; after all, the reader can read Scheme code.

Suggest one or two specific further improvement(s) to the audience. Clearly explain how components of the program will need to be adapted to incorporate these improvements. I'd rather you explain one suggested improvement in detail rather than explain several vague ideas. For instance, the programmer may need to

  1. expand the class hierarchy,
  2. adapt the interface,
  3. add new instance variables, or
  4. change or write new methods.

One way to sketch your idea is to specify the information required by define-class in any new classes, or changes required to define-class in existing classes. You should specify any arguments and return values for new methods.

Although you need not provide explicit testing information in this report, you are expected to adequately test the code you wrote. If your program has bugs, provide a bug report.

The gradesheet for the project is available in PostScript or PDF format. (If you print a copy out, you can staple it to the front of your project report to save paper.)

Submitting your code

To submit your code when it's ready, go to your project directory and type:
  ~wolfe/public/178/submit *.scm
Please print out your project report and submit it in class. Your project report should not include all your code.