next up previous
Next: 1. The Object Simulation

MASSACHVSETTS INSTITVTE OF TECHNOLOGY
Department of Electrical Engineering and Computer Science
6.001--Structure and Interpretation of Computer Programs
Spring Semester, 1998

Problem Set 7

Word to the wise: This problem set is the most difficult one so far this semester. But, perhaps paradoxically, it involves only a small amount of programming. The trick lies in knowing which programs to write, and for that, you must understand the attached code, which is considerable. You'll need to understand the general ideas of object-oriented programming and the implementation provided of an object-oriented programming system (in objsys.scm). Then you'll need to understand the particular classes (in objtypes.scm) and world (in setup.scm) that we've constructed for you. Finally, you'll need to review the searching strategy (in search-rooms.scm), which is a variation of the code you used last week in problem set 6. In truth, this assignment in much more an exercise in reading and understanding code than in writing code, because reading significant amounts of code is a skill that you should master if you intend to go on in computer science. The tutorial exercises will require you to do considerable digesting of code before you can start on them. And we strongly urge you to study the code before you begin trying the programming exercises themselves. Diving in starting to program without understanding the code is a good way to get lost, will virtually guarantee that you'll be spending more time on this assignment than necessary.

A maze of twisty little passages, all alike

In this problem set we will try to master a powerful strategy for building simulations possible worlds, as discussed in lecture on March 19. The strategy will enable us to make modular simulations with enough flexibility to allow us to expand and elaborate the simulation as our conception of the world expands and becomes more elaborate.

One way to organize our thoughts about a possible world is to divide it up into discrete objects, where each object will have a behavior by itself, and it will interact with other objects in some lawful way. If it is useful to decompose a problem in this way then we can construct a computational world, analogous to the ``real'' world, with a computational object for each real object.

Each of our computational objects has some independent local state, and some rules (or programs) that determine its behavior. One computational object may influence another by sending it messages. The program associated with an object describes how the object reacts to messages, and how its state changes as a consequence.

You may have heard about this idea in the guise of ``Object-Oriented Programming''(OOPs!). Languages such as C++ and Java are organized around OOP. Although OOP is helpful in many circumstances it has been oversold as a panacea for the software-engineering problem. What we will try to understand here is the essence of the idea, rather than the accidental details of their expression in particular languages.




next up previous
Next: 1. The Object Simulation

Hal Abelson
Wed Mar 11 23:54:42 EST 1998