| 16.14. 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; change the printed name of the pot to "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. 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; change the printed name of the noun to "broken flowerpot"; change the printed plural name of the noun to "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.
 | At present, the implementation of this feature has a restriction: if we define a new kind of value (say, colour) and give it to something as a property, then define a new textual form of one of those values (say making "crimson" a synonym for "red"), this new textual form will not be understood when used adjectivally in the above way.
|
|  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. |
|  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. |
Understand the property... runs into limitations when the property is itself a numerical value of arbitrary components. Even so, it is possible to work around this limitation and allow the player to refer to such entities as "the 10 inch piece of string", even though "10 inch" is not a permanent part of the string's name. First, to echo the string example we had earlier:
"Snip Snip!"
Length is a kind of value. 30 inch specifies a length. 20 in specifies a length. 50 inches specifies a length.
A string is a kind of thing. A string has a length. The length of a string is usually 36 inches.
Before printing the name of a string, say "[length] piece of ". Rule for printing the plural name of a string: say "[length] pieces of string".
Understand the command "cut" as something new. Understand "cut [length] from/off [something]" as trimming it by (with nouns reversed). Understand "cut [something] by [length]" as trimming it by. Understand the command "trim" as "cut".
Trimming it by is an action applying to one thing and one length.
Check trimming it by:
if the length understood is 0 inches, say "You're approaching Zeno's string at this point." instead;
if the length understood is greater than the length of the noun, say "[The noun] is only [length of the noun] long to start with." instead;
if the length understood is the length of the noun, say "[The noun] is already exactly [length of the noun] long." instead.
Carry out trimming it by:
change the length of the noun to the length of the noun minus the length understood;
let the other half be a random string in the string repository;
change the length of the other half to the length understood;
move the other half to the player.
Report trimming it by:
assign comparatives;
say "You now have [a list of strings carried by the player]."
Understand "cut [something] in half" as halving. Halving is an action applying to one thing.
Carry out halving:
let half measure be the length of the noun divided by 2;
change the length understood to half measure;
try trimming the noun by half measure.
The player carries a string.
The Scissors Room is a room.
The string repository contains 35 strings.
Ordinariness is a kind of value. The ordinarinesses are longest, medium, shortest. A string has an ordinariness. Understand the ordinariness property as referring to a string.
Definition: a string is small if its length is 2 in or less. Definition: a string is large if its length is 20 in or more.
Before reading a command:
assign comparatives.
To assign comparatives:
let upper measure be the length of the largest visible string;
let lower measure be the length of the smallest visible string;
repeat with item running through strings
begin;
change the selection of the item to unselected;
change the ordinariness of the item to medium;
if the length of the item is the upper measure, change the item to longest;
if the length of the item is the lower measure, change the item to shortest;
end repeat.
Here enters the trick. We are going to create a property that is basically irrelevant to the player, and use it to tag the items we want:
Selection is a kind of value. The selections are selected, next, or unselected. A string has a selection. Understand the selection property as referring to a string.
Understand "string" or "piece" or "piece of string" as "[string]".
And now we intervene after the command has been read but before it is translated by Inform into a command. (For more about "after reading a command", see the activities chapter.)
After reading a command:
if the player's command includes "shorter", replace the matched text with "shortest";
if the player's command includes "longer", replace the matched text with "longest";
while the player's command includes "[length] [string]"
begin;
if a visible string (called target) measures length understood
begin;
if a string is selected
begin;
now the target is next;
replace the matched text with "next string";
otherwise;
now the target is selected;
replace the matched text with "selected string";
end if;
otherwise;
replace the matched text with "unknown string";
now every string is unselected;
end if;
end while.
The while repetition is necessary because it is possible that the player will refer to two different strings, one as the first noun and one as the second, as for instance in a "tie X to Y" command. If we only had "if the player's command includes...", only the first such string would be recognized and tagged.
Carry out doing something to a string:
now every string is unselected.
The verb to measure (it measures, they measure, it is measuring) implies the length property.
Instead of tying a string to a string:
move the second noun to the string repository;
change the length of the noun to the length of the noun plus the length of the second noun;
decrease the length of the noun by 1 inch;
say "You end up with [a noun], as some is taken up by the knot."
Test me with "trim string by 5 inches / cut 31 inch string by 2 inches / tie 5 inch string to 29 inch string / drop longest string".
As it stands this is little more than an exploration of simulation for its own sake, but one could imagine implementing, say, fuses that needed to be cut a certain length for timing devices...
|