Chapter 11: Phrases
11.13. Phrases which use descriptions

In the chapter on Descriptions, we saw that a description can be any source text which describes one or more objects: it might be as simple as "the Corn Market", or as complicated as "open containers which are in dark rooms". (More or less the only restriction is that it must be unambiguous as to what counts and what does not: "three containers" is ambiguous as a description because it does not say which three.)

In the last section, we saw that it is possible to repeat phrases with a temporary name running through all the things matching a description. Other tricks with descriptions have also turned up: in fact, if D is a description, then

say "You gaze mournfully at [the list of D].";
let the tally be the number of D;
let the surprise prize be a random D;
repeat with item running through D:
    ...

are all standard things to do. These examples make it look as if it must be possible to define phrases which act on descriptions, and in fact it is. For instance:

To enumerate (collection - a description):
    repeat with the item running through the collection:
        say "-- [The item]."

This makes "enumerate lighted rooms" run off a list of lighted rooms in a textual format different from the standard one produced by "say the list of lighted rooms". Inside the definition, "collection" can be used wherever a description might be used: here, for instance, we use it as the range for the repeat loop. These must, however, be descriptions of objects, not values.

Purely as a convenience, we can also write "member of" or "members of" in this context. For instance, in the enumerate definition, it would have been just as good to write "...running through the members of the collection..." in the repeat. (Similarly, we could write "number of members of the collection" or "a random member of the collection", which looks grammatically tidier than writing "number of the collection" or "random of the collection" - though in fact both of these do work.)


175
* Example  Curare
A phrase that chooses and names the least-recently selected item from the collection given, allowing the text to cycle semi-randomly through a group of objects.

RB

"Curare"

A thing has a number called the last use. The last use of a thing is usually 0.

Definition: a thing is old if its last use is 12 or less.

The actual number chosen in this definition is pretty much irrelevant: the main thing is that we want to establish relative values. The lower the "last use" number of an item, the older that item should be understood to be, as we see here:

To decide which thing is cyclically random (collection - a description):
    let choice be the oldest member of the collection;
    change the last use of the choice to the turn count;
    decide on choice.

This phrase will select, from the collection of objects passed to it, the one that has been mentioned least recently. This means that if we consult it repeatedly about the same collection, it will begin to cycle predictably; but if new items are added to the collection, it will mention these first before returning to the previous cycle. Now we can use this:

After taking inventory:
    say "You stare morosely at [the cyclically random thing carried by the player], wondering what you're ever going to find to do with it."

We could have said "You stare morosely at [the oldest thing carried by the player]" here, but doing so would not have set the "last use" property correctly, so we would not get the cycling behavior that we're looking for.

The Evidence Room is a room. Some shelves are scenery supporters in the Evidence Room. A box is a kind of container which is open and not openable. On the shelves is a box. It contains a deformed bullet and a driver's license.

The player carries a steel fish hook, a Chinese passport, a tube of synthetic curare, and an envelope full of Euros.

Test me with "i / i / i / i / i / i / get all from box / i / i / i".


PreviousContentsNext