| Chapter 16: Understanding |

| 16.16. Does the player mean...

When the player types an ambiguous reference, we need to work out what is meant. Consider the following source text:

> The Champs du Mars is a room. The great Eiffel Tower is here. "The great Tower stands high over you." The souvenir model Eiffel Tower is here. "Comparatively tiny is the souvenir version."

Now suppose the player types GET TOWER. The response will be:

> Which do you mean, the great Eiffel Tower or the souvenir model Eiffel Tower?

Which is a silly question, exposing our work of IF as something artificial. It's obvious to the author of the source text, and to the player, that the souvenir must be what is meant: but this is not obvious to the computer program running the game. Works of IF gain a subtle feeling of quality from being able to understand ambiguous references of the kind above, and Inform provides us with a way to do this by giving the parser clues in the form of "Does the player mean..." rules. For instance, if we add:

> Does the player mean taking the great Eiffel Tower: it is very unlikely.

then the response to GET TOWER will now be:

> (the souvenir model Eiffel Tower)
> Taken.

"Does the player mean..." rules look at the actions which are possible interpretations of what the player typed, and grade them according to how likely they seem. (Note that these rules are only ever used to handle ambiguities: if the player unambiguously types GET GREAT EIFFEL TOWER, that will be the action.) Rules in this rulebook can either decide nothing, or come up with one of the following verdicts:

> it is very likely
> it is likely
> it is possible
> it is unlikely
> it is very unlikely

If there are no "does the player mean" rules, or the rules make no decision on a given possible action, it will be ranked as "it is possible".

Notice that we can also make rules about actions that apply to two objects, so for instance:

> Does the player mean throwing the can of shoe polish at the shoe polish vending machine: it is likely.

which nicely clarifies THROW POLISH AT POLISH, but does not comment on the likelihood of throwing the can at other things or of throwing other things at the vending machine. Moreover, the (suspected) identity of the first item will be known when the rule is consulted; thus

> Does the player mean tying the noun to the noun: it is very unlikely.

will tell Inform to prefer not to tie something to itself if other interpretations are available.

Finally, we may use these rules to affect all sorts of interaction with a specific object or kind of object, as in

> Does the player mean doing something with the cursed dagger of Thog: it is very unlikely.
> Does the player mean doing something with the cursed dagger of Thog when the player is hypnotized: it is likely.

...and so on.

243
| Example Masochism Deli Multiple potatoes, with rules to make the player drop the hot potato first and pick it up last.

Here the player has several potatoes; we would like to make him more likely to drop the hot one, and more likely to pick up the cold one, all else being equal. At the same time, we want to phrase our rules so that they don't make the player try to take something he's already holding, or drop something he isn't. So: "Masochism Deli" The Masochism Deli is a room. "Recent restructurings of corporate policy restrict the 'lunch hour' to exactly thirty-two minutes, which means that no one has time to go out. Instead, you and your coworkers eat here, in the company's very own themed lunch room." The plural of potato is potatoes. A potato is a kind of thing. A potato is edible. Temperature is a kind of value. The temperatures are hot and cold. A potato has a temperature. A potato is usually cold. Understand the temperature property as describing a potato. Before printing the name of a potato (called subject): say "[temperature of subject] ". Before printing the plural name of a potato (called subject): say "[temperature of subject] ". Does the player mean dropping a hot potato which is carried by the player: it is very likely. Does the player mean taking a cold potato which is not carried by the player: it is very likely. The player carries three potatoes. After dropping a hot potato: say "The guy from Cube B sneers at your lack of potato-holding stamina." When play begins: now a random potato is hot. Test me with "inventory / drop potato / g / g / get potato / g / i / get potato".

Previous | Contents | Next