Chapter 2: Adaptive Prose
§2.1. Varying What Is Written; §2.2. Varying What Is Read; §2.3. Using the Player's Input
§2.1. Varying What Is Written
Before getting to actual recipes, many recipe books begin with intimidating lists of high-end kitchen equipment (carbon-steel pans, a high-temperature range, a Provencal shallot-grater, a set of six pomegranate juicers): fortunately, readers who have downloaded Inform already have the complete kitchen used by the authors. But the other traditional preliminaries, about universal skills such as chopping vegetables, boiling water and measuring quantities, do have an equivalent.
For us, the most basic technique of IF is to craft the text so that it smoothly and elegantly adapts to describe the situation, disguising the machine which is never far beneath the surface. This means using text substitutions so that any response likely to be seen more than once or twice will vary.
M. Melmoth's Duel demonstrates three basic techniques: an ever-changing random variation, a random variation changing only after the player has been absent for a while, and a message tweaked to add an extra comment in one special case. (Random choices can be quite specifically constrained, as Ahem shows in passing.) Fifty Ways to Leave Your Larva and Fifty Times Fifty Ways show how a generic message can be given a tweak to make it a better fit for the person it currently talks about. Curare picks out an item carried by the player to work into a message, trying to make an apt rather than random choice. Straw Into Gold demonstrates how to have Inform parrot back the player's choice of name for an object.
Another reason to vary messages is to avoid unnatural phrasing. Ballpark turns needlessly precise numbers - another computerish trait - into more idiomatic English. (Likewise Numberless, though it is really an example demonstrating how to split behaviour into many cases.) Prolegomena shows how to use these vaguer quantifiers any time Inform describes a group of objects (as in "You can see 27 paper clips here.").
Blink, a short but demanding example from the extreme end of Writing with Inform, shows how the basic text variation mechanisms of Inform can themselves be extended. Blackout demonstrates text manipulation at a lower level, replacing every letter of a room name with "*" when the player is in darkness.
Inform's included extension Complex Listing allows us more control over the order and presentation of lists of items.
For how to change printed text to upper, lower, sentence, or title casing, see Rocket Man.
| ExampleAhem Writing a phrase, with several variant forms, whose function is to follow a rule several times.
|
|
| ExampleNumberless A simple exercise in printing the names of random numbers, comparing the use of "otherwise if...", a switch statement, or a table-based alternative.
|
|
| ExampleResponsive Altering the standard inventory text for when the player is carrying nothing.
|
|
| ExampleProlegomena Replacing precise numbers with "some" or other quantifiers when too many objects are clustered together for the player to count at a glance.
|
|
| ExampleCurare 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.
|
|
| ExampleBlink Making a "by atmosphere" token, allowing us to design our own text variations such as "[one of]normal[or]gloomy[or]scary[by atmosphere]".
|
|
|  ExampleVariety 2 This builds on the Variety example to add responses such as "You are now carrying the fedora" that describe relations that result from a given verb, as alternate responses.
|
|
|  ExampleVariety Suppose we want all of our action responses to display some randomized variety. We could do this by laboriously rewriting all of the response texts, but this example demonstrates an alternative.
|
|
|  ExampleFun with Participles Creating dynamic room descriptions that contain sentences such as "Clark is here, wasting time" or "Clark is here, looking around" depending on Clark's idle activity.
|
|
The examples Variety and Narrative Register show how verbs can be associated with particular actions. Here, we use the same principle so that we can report to the player what was last done to a particular object, either by the player or by someone else.
To do this, we need to use the idea of stored actions from the Advanced Actions chapter.
"History Lab"
Section 1 - Procedure
An object has an action called the last action.
Describing relates various verbs to various action names. The verb to describe means the describing relation.
To take is a verb. The verb take describes the taking action.
To drop is a verb. The verb drop describes the dropping action.
To look at is a verb. The verb look at describes the examining action.
To examine is a verb. The verb examine describes the examining action.
After an actor doing something to something:
if a verb describes the action name part of the current action:
now the indefinite article of the noun is "the";
now the last action of the noun is the current action;
continue the action.
After printing the name of something (called item):
if the last action of the item is not waiting and the last action of the item is not the current action:
let chosen action-name be the action name part of the last action of the item;
let chosen actor be the actor part of the the last action of the item;
if a verb describes the chosen action-name:
let the chosen verb be a random verb that describes the chosen action-name;
say " [if the chosen actor is the player][we][else][chosen actor][end if] [adapt chosen verb in past tense]";
Section 2 - Scenario
Lab is a room. It contains a box. The box contains a newspaper. Clark is a man in the Lab.
A persuasion rule:
persuasion succeeds.
Test me with "x box / look / x newspaper / look / clark, x newspaper / clark, get box / clark, drop box / look / take box / i / smell box / i".
Notice that smelling the box does not change the box's description because we haven't gotten around to defining a smell or sniff verb.
|  ExampleHistory Lab We create phrases such as "the box we took" and "the newspaper Clark looked at" based on what has already happened in the story.
|
The examples Variety and Narrative Register show how verbs can be associated with particular actions. Here, we use the same principle so that we can report to the player what was last done to a particular object, either by the player or by someone else.
To do this, we need to use the idea of stored actions from the Advanced Actions chapter.
"History Lab"
Section 1 - Procedure
An object has an action called the last action.
Describing relates various verbs to various action names. The verb to describe means the describing relation.
To take is a verb. The verb take describes the taking action.
To drop is a verb. The verb drop describes the dropping action.
To look at is a verb. The verb look at describes the examining action.
To examine is a verb. The verb examine describes the examining action.
After an actor doing something to something:
if a verb describes the action name part of the current action:
now the indefinite article of the noun is "the";
now the last action of the noun is the current action;
continue the action.
After printing the name of something (called item):
if the last action of the item is not waiting and the last action of the item is not the current action:
let chosen action-name be the action name part of the last action of the item;
let chosen actor be the actor part of the the last action of the item;
if a verb describes the chosen action-name:
let the chosen verb be a random verb that describes the chosen action-name;
say " [if the chosen actor is the player][we][else][chosen actor][end if] [adapt chosen verb in past tense]";
Section 2 - Scenario
Lab is a room. It contains a box. The box contains a newspaper. Clark is a man in the Lab.
A persuasion rule:
persuasion succeeds.
Test me with "x box / look / x newspaper / look / clark, x newspaper / clark, get box / clark, drop box / look / take box / i / smell box / i".
Notice that smelling the box does not change the box's description because we haven't gotten around to defining a smell or sniff verb.
|
|  ExampleRelevant Relations An example of how to create room descriptions that acknowledge particular relations using their assigned verbs, rather than by the heavily special-cased code used by the standard library.
|
|