16.15. Understanding things by their properties

| Chapter 16: Understanding |

| 16.15. Understanding things by their properties

Items are ordinarily understood only by their original given names. For instance, if we have:

> In the Herb Garden is a china pot.

then the player could refer to this as "pot", "china pot" or "china". We can embellish this by adding extra forms:

> Understand "chinese pot" or "chinese vase" as the china pot.

But suppose the pot changes its nature in the course of play? If we have:

> The china pot can be unbroken or broken. The china pot is unbroken.

> After dropping the china pot:
> say "Crack!";
> now the china pot is broken;
> now the printed name of the pot is "broken pot".

So now the player would reasonably expect to call it "broken pot", a wording which would have been rejected before. We can achieve this by writing:

> Understand the unbroken property as describing the pot.

which allows "unbroken" or "broken" to describe the pot, depending on its state. And, since the player might well use a different adjective but with the same idea in mind, we can even add:

> Understand "shattered" or "cracked" or "smashed" as broken. Understand "pristine" as unbroken.

This is something of a toy example, but the feature looks rather more useful when there are more pots than just one:

> "Terracotta"

> A flowerpot is a kind of thing. A flowerpot can be unbroken or broken. Understand the broken property as describing a flowerpot.

> After dropping an unbroken flowerpot:
> say "Crack!";
> now the noun is broken;
> now the printed name of the noun is "broken flowerpot";
> now the printed plural name of the noun is "broken flowerpots".

> The Herb Garden is a room. In the Herb Garden are ten unbroken flowerpots.

We then have the dialogue:

> Herb Garden
> You can see ten flowerpots here.
> >get two flowerpots
> flowerpot: Taken.
> flowerpot: Taken.
> >drop all
> flowerpot: Crack!
> flowerpot: Crack!
> >look
> Herb Garden
> You can see two broken flowerpots and eight flowerpots here.
> >get an unbroken flowerpot
> Taken.

and so on and so forth.

There are in fact two slightly different forms of this kind of sentence:

> Understand the broken property as describing a flowerpot.
> Understand the broken property as referring to a flowerpot.

The only difference is that in the "describing" case, the property's name alone can mean the thing in question - so "take unbroken" will work; whereas, in the "referring to", the property's name can only be used as an adjective preceding the name of thing itself - so "take unbroken flowerpot" will work but "take unbroken" will not.

300
| Example Aspect Understanding aspect ratios (a unit) in the names of televisions. |
RB

301
| Example Hymenaeus Understanding "flaming torch" and "extinguished torch" to refer to torches when lit and unlit. |
RB

302
| Example Terracottissima The flowerpots once again, but this time arranged so that after the first breakage all undamaged pots are said to be "unbroken", to distinguish them from the others. |
RB

303
| Example Peers The peers of the English realm come in six flavours - Baron, Viscount, Earl, Marquess, Duke and Prince - and must always be addressed properly. While a peerage is for life, it may at the royal pleasure be promoted. |
RB

304
| Example Channel 1 Understanding channels (a number) in the names of televisions. |
RB

305
| Example Channel 2 Understanding channels (a number) in the names of televisions, with more sophisticated parsing of the change channel action. |
RB

306
| Example Tilt 1 A deck of cards with fully implemented individual cards, which can be separately drawn and discarded, and referred to by name. |
RB

> We've simulated a deck of cards before, but only as entries in a table. This time we're going to do it more completely, with card objects that can be drawn and discarded, and referred to by name. The tedious way to do this would be to make 52 objects by hand and laboriously write out their names and understand rules. A more sensible way is to make 52 identical card objects, assign them ranks and suits, and allow Inform to generate and parse their names automatically. So: "Tilt" Section 1 - Cards Suit is a kind of value. The suits are hearts, clubs, diamonds, and spades. Understand "heart" as hearts. Understand "club" as clubs. Understand "diamond" as diamonds. Understand "spade" as spades. [Providing the singular forms means that Inform will also understand >EXAMINE SPADE, >DISCARD CLUB, and so on.] A card is a kind of thing. A card has a suit. A card has a number called rank. Understand the suit property as describing a card. Understand the rank property as describing a card. 52 cards are in the card repository. Now, we're going to describe the higher numbers as face cards, so it helps to write a new "to say" phrase, just as we did in Jokers Wild. (A subsequent version of this example shows how to print card values with red and black symbols representing the different suits; see "Tilt 3".) To say (count - a number) as a card value: choose row count in the Table of Value Names; say "[term entry]". Rule for printing the name of a card (called target): say "[rank of the target as a card value] of [suit of the target]" Table of Value Names
> term | value | topic
> "ace" | "1" | "ace/A/one"
> "deuce" | "2" | "deuce/two"
> "three" | "3" | "three"
> "four" | "4" | "four"
> "five" | "5" | "five"
> "six" | "6" | "six"
> "seven" | "7" | "seven"
> "eight" | "8" | "eight"
> "nine" | "9" | "nine"
> "ten" | "10" | "ten"
> "jack" | "11" | "jack/knave/J"
> "queen" | "12" | "queen/Q"
> "king" | "13" | "king/K"
This is enough already to let inform understand things like "ten clubs", but we want to add a couple of refinements. For one thing, we'd like to accept "of" when it appears in phrases such as "ten of clubs" (but not generically otherwise); for another, we'd like the player to be able to use various names for ranks. To this end, we need to borrow from the Activities chapter and modify the player's command before attempting to understand it: After reading a command: if the player's command includes "of [suit]": while the player's command includes "of": cut the matched text; repeat through the Table of Value Names: while the player's command includes topic entry: replace the matched text with value entry. [This allows Inform to understand "ace", "deuce", "king", etc., as numerical ranks.] It may be a bit confusing that the Table of Value Names has both a topic column and a term column, to all appearances essentially identical. But items in the topic column can be matched against the player's input, whereas items in other kinds of text column can be printed out; the two kinds of text are not treated identically by Inform, so we need to have both. Notice that the topic column contains entries like "jack/knave," which will match either "jack" or "knave" in the player's input. Now to set up the deck at the outset. With some intelligent looping, we avoid having to declare every combination of suit and number individually: When play begins: reconstitute deck. To reconstitute deck: let current suit be hearts; now every card is in the card repository; while a card is in the card repository: repeat with current rank running from 1 to 13: let item be a random card in card repository; now rank of item is current rank; now suit of item is current suit; now item is in the deck of cards; now current suit is the suit after the current suit. And now we need a simple setting and some actions to manipulate the deck with: Section 2 - The Deck and the Discard Pile The Empty Room is a room. "Nothing to see here." The deck of cards is in the Empty Room. It is a closed unopenable container. The description is "A standard poker deck." The discard pile is a closed unopenable container. The description is "Cards in this game are discarded face-down, so the discard pile is not very interesting to see. All you can observe is that it currently contains [if the number of cards which are in the discard pile is less than ten][the number of cards which are in the discard pile in words][otherwise]about [the rounded number of cards which are in the discard pile in words][end if] card[s]." To decide what number is the rounded number of (described set - a description of objects): let N be the number of members of the described set; let R be N divided by 5; let total be R times 5; decide on total. The above phrase rounds a number to the nearest five, so that the player is not autistically able to count a large number of cards in the discard pile at a single glance. This next bit is an optional borrowing from the Activities chapter: we want to prevent Inform printing things like "You can see a discard pile (closed) here.", since we don't want the player to think of the piles as containers, even though Inform thinks of them in those terms. Rule for printing room description details of something: do nothing instead. Finally, we want the player to use "draw" and "discard" to manipulate his hand of cards: Section 3 - Drawing and Discarding Actions Understand the commands "take" and "carry" and "hold" and "get" and "drop" and "throw" and "discard" as something new. Understand "take [text]" or "get [text]" or "drop [text]" as a mistake ("Here, you only draw and discard. Nothing else matters at the moment."). Understand "draw" or "draw card" or "draw a card" as drawing. Drawing is an action applying to nothing. The drawing action has an object called the card drawn. Setting action variables for drawing: now the card drawn is a random card which is in the deck of cards. Check drawing: if the card drawn is nothing, say "The deck is completely depleted." instead. Check drawing: if the number of cards carried by the player is greater than four, say "This is a five-card game; you must discard something before drawing anything further." instead. Carry out drawing: move the card drawn to the player. Report drawing: say "You draw [a card drawn]." Understand "discard [card]" as discarding. Discarding is an action applying to one thing. Check discarding: if the player does not carry the noun, say "You can only discard cards from your own hand." instead. Carry out discarding: now the noun is in the discard pile; if the discard pile is not visible, move the discard pile to the location. Report discarding: say "You toss [the noun] nonchalantly onto the discard pile." Seeding is an action out of world. Understand "seed" as seeding. Carry out seeding: seed the random-number generator with 5681. Test me with "seed / draw / g / g / g / g / i / discard seven of spades / draw / discard six / draw / i / discard hearts / discard six of diamonds card / draw / draw / i / discard spades card / draw / discard king card".

307
| Example Terracottissima Maxima Flowerpots with textual names that might change during play. |
RB

Previous | Contents | Next