In this simple game, there will only be three different locations: a house with a living room and an attic, along with a garden. Let's define a new variable, called `map` that describes this mini world:

      (setq map '((living-room (you are in the living room
                    of a wizards house - there is a wizard
                    snoring loudly on the couch -)
                    (west door garden)
                    (upstairs stairway attic))
                  (garden (you are in a beautiful garden -
                    there is a well in front of you -)
                    (east door living-room))
                  (attic (you are in the attic of the
                    wizards house - there is a giant
                    welding torch in the corner -)
                    (downstairs stairway living-room))))

This map contains everything important that we'd like to know about our three locations: a unique name for the location (i.e., living room, garden, and attic) a short description of what we can see from there (stored in its own list within the bigger list), plus the where and how of each path in to/out of that place. Notice how information-rich this one variable is and how it describes all we need to know but not a thing more. Lispers love to create small, concise pieces of code that leave out any fat and are easy to understand just by looking at them.

Now that we have a map and a bunch of objects, it makes sense to create another variable that says where each of these objects are on the map:

      (setq object-locations '((whiskey-bottle living-room)
                               (bucket living-room)
                               (chain garden)
                               (frog garden)))

<< begin < previous - next > end >>