6.17. Clarification and Correction

| Chapter 6: Commands |

| 6.17. Clarification and Correction

Some commands and some objects raise special challenges when it comes to working out the player's intention.

Sometimes this can be done with good rules about the assumptions Inform should make. Alpaca Farm demonstrates a USE command, always a challenge because USE can mean very different actions with different items.

There are also times when we need to ask the player for more information. Apples demonstrates how sensibly to use properties to disambiguate between similar objects, while Walls and Noses rephrases the disambiguation question when special objects are involved: examining one of the walls of the room will make the game ask "In which direction?" and EXAMINE NOSE will lead to "Whose nose do you mean, Frederica's, Betty's, Wilma's or your own?"

At other times, the player types something that is wrong in a predictable way: for instance, we might want to remove all the "with..." phrases from commands like

> HIT DOOR WITH FIST
> KICK DRAGON WITH FOOT
> LOOK WEST WITH EYES

and merely parse the remainder of the command. (That last command may be unlikely, but novice players do quite often type commands that refer unnecessarily to body parts.) Cave-troll demonstrates how.

WXPQ demonstrates how to modify the error message the parser gives in response to a command it doesn't understand; this particular example focuses on the "That noun doesn't make sense in this context" message that arises from using the "[any thing]" or "[any room]" tokens, but the techniques could be adapted to handling other parser errors as well.

For catching typing errors, Cedric Knight's extension Mistype may also be of use: it provides an automatic typo-correction function that the player can turn on or off.

279
| Example Alpaca Farm A generic USE action which behaves sensibly with a range of different objects. |
WI

355
| Example Apples Prompting the player on how to disambiguate otherwise similar objects. |
WI

356
| Example Walls and Noses Responding to "EXAMINE WALL" with "In which direction?", and to "EXAMINE NOSE" with "Whose nose do you mean, Frederica's, Betty's, Wilma's or your own?" |
WI

Suppose we want our game to respond to "EXAMINE WALL" with "In which direction?", and to "EXAMINE NOSE" with "Whose nose do you mean, Frederica's, Betty's, Wilma's or your own?" For the case of EXAMINE WALL, we need a way to determine whether every item being disambiguated is a direction. We'll start by making a "matched" adjective which will identify items being disambiguated: "Walls and Noses" Eight-Walled Chamber is a room. "A perfectly octagonal room whose walls are tinted in various hues." Understand "wall" as a direction. Definition: a direction is matched if it fits the parse list. Definition: a room is matched if it fits the parse list. Definition: a thing is matched if it fits the parse list. Rule for asking which do you mean when everything matched is direction: say "In which direction?" Checking the parse list requires a bit of behind-the-scenes work with Inform 6. Fortunately, you don't have to understand this entirely in order to use the rest of the example: To decide whether (N - an object) fits the parse list: (- (FindInParseList({N})) -) Include (- [ FindInParseList obj i k marker; marker = 0; for (i=1 : i<=number_of_classes : i++) { while (((match_classes-->marker) ~= i) && ((match_classes-->marker) ~= -i)) marker++; k = match_list-->marker; if (k==obj) rtrue; } rfalse; ]; -) Now that we've defined our "matched" adjective, we can use it for other purposes as well -- even generating our own lists. Our second challenge was to respond to EXAMINE NOSE with "Whose nose do you mean, Frederica's, Betty's, Wilma's or your own?" Here we need to change the way the question is worded (not "which do you mean" but "whose nose do you mean"). We also have to the names of the noses as they're printed in this particular context, so that they don't repeat the word "nose" over and over. And -- as a point of good English style -- we also want "your own" nose always to be last on the list. For this purpose we may want to use the built-in "Complex Listing" extension, which allows us to print specially ordered lists. So: Include Complex Listing by Emily Short. Wilma, Betty, and Frederica are women in the Eight-Walled Chamber. Understand "lady" or "woman" as a woman. A nose is a kind of thing. A nose is part of every person. Rule for asking which do you mean when everything matched is a nose: prepare a list of matched things; if your nose is an output listed in the Table of Scored Listing: choose row with an output of your nose in the Table of Scored Listing; now the assigned score entry is -1; say "Whose nose do you mean, [the prepared list delimited in disjunctive style]?" Rule for printing the name of a nose (called target) while asking which do you mean : if everything matched is a nose: if the target is part of a person (called owner): if the owner is the player, say "your own"; otherwise say "[the owner][apostrophe]s"; otherwise: make no decision. Understand "own" or "mine" as your nose. Test me with "x wall / north / x nose / mine".

413
| Example Cave-troll Determining that the command the player typed is invalid, editing it, and re-examining it to see whether it now reads correctly. |
WI

366
| Example WXPQ Creating a more sensible parser error than "that noun did not make sense in this context". |
WI

Previous | Contents | Next