§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.
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.").
Inform's included extension Complex Listing allows us more control over the order and presentation of lists of items.
We can use these substitutions to put together fairly complicated variations within a single piece of text:
"Fifty Ways to Leave Your Larva"
The Beekeeper's Palace is a room. Wasp is a woman in the palace. Drone is a man in the palace.
Instead of kissing someone:
say "'[denial], [insult]! [boast]!'";
In this context, [denial] is understood to refer to the denial property of the noun -- but we could spell it out with "denial of the noun" if we wanted to.
A person has some text called denial. The denial of a person is usually "Stand back". The denial of Drone is "You forget yourself"
A person has some text called insult. The insult of a person is usually "Grasshopper". The insult of Wasp is "Larva".
A person has some text called boast. The boast of a person is usually "I am ferocious". The boast of Drone is "I have ferocious allies".
And then it would be trivial to insert further rules using these responses:
Instead of attacking someone:
say "'Get away, [insult]!'"
Test me with "kiss wasp / hit wasp / hit drone / kiss drone".
|
ExampleAhem
Writing a phrase, with several variant forms, whose function is to follow a rule several times.
|
|
As we see in the example here, it is possible to use slashed variations in more than one place in a phrase, and to offer a number of separate forms. The main rule of thumb to remember is that value inputs for the phrase should always be separated by some text; so
To do/follow (chosen rule - a rule) exactly/precisely/just/-- (N - a number) time/times:
....
would cause a problem when we tried to call it with
follow the throat-clearing rule 2 times.
In general, we probably don't need to make our phrase definitions quite so flexible as this, but it's a good idea to account for "a" vs. "the", and for the possibility of using singular and plural forms, especially when writing extensions or other source to be shared.
"Ahem"
To do/follow (chosen rule - a rule) exactly/precisely/just (N - a number) time/times:
repeat with index running from 1 to N:
follow chosen rule.
This is the throat-clearing rule:
say "'Ahem,' says [a random visible person who is not the player]."
After waiting:
do the throat-clearing rule just one time.
Instead of listening:
follow the throat-clearing rule precisely three times.
Instead of smelling:
follow the throat-clearing rule exactly 2 times.
Chateau Marmont is a room. Tom, Jack, Zsa-Zsa, and Wilma-Faye are people in the Chateau. Zsa-Zsa and Wilma-Faye are women.
Test me with "wait / smell / listen".
|
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.
|
|
"Numberless"
The Rambling Warren is a room.
When play begins:
let N be a random number between 1 and 5;
if N is 1:
say "N is one.";
otherwise if N is 2:
say "N is two.";
otherwise if N is 3:
say "N is three.";
otherwise:
say "N is more than the number of your toes."
The final "otherwise" here will fire only if none of the earlier conditions applies; we could leave it out and print nothing in the case that N is 4 or 5.
The more compact way to do this is to create a list of values that our number could match; in many programming languages this is called a switch statement. For example:
When play begins:
let Y be a random number between 6 and 10;
if Y is:
-- 6: say "Six is the magic number!";
-- 7: say "The number of the day is seven!";
-- otherwise: say "Today's magic number is boring."
As a final option, we can use a construction we've seen only briefly before now: a table. The use of tables will be explained more fully in their own chapter, but here we see in brief that we can assign a number of values to one column of a table and then use that table to look up output:
When play begins:
let X be a random number between 11 and 14;
if X is a number listed in the Table of Switching, say "[output entry][paragraph break]";
otherwise say "X is greater than the number of your noses!"
Table of Switching
number
|
output
|
11
|
"X is eleven!"
|
12
|
"X is twelve!"
|
13
|
"X is thirteen!"
|
Test me with "z".
As we shall see, things other than text can be stored in tables, so we could also use a table as a way to look up objects or even rules to carry out.
"M. Melmoth's Duel"
Saint-Germain-des-Prés is a room. "Haunt of artists, of the coffee-drinking sort, and of cafés, of the artist-haunted sort, you once again find yourself outside M. Melmoth's hotel. Today [one of]the recently-fallen rain runs down the gutters of the 6th[or]sunlight glints even off the blackened windows of the Abbey[or]crowds of vulgar children play chase around the lampposts[at random], and you long to be indoors."
The Hôtel d'Alsace is inside from Saint-Germain-des-Prés. "Typical. Oscar writes you a letter announcing his own imminent demise - 'My wallpaper and I are fighting a duel to the death. One or other of us has got to go.' - and then you get there and he's out, no doubt procuring paint the colour of absinthe, if he isn't procuring the painter."
Tint is a kind of value. The tints are green, aquamarine and darkish purple.
The wallpaper is fixed in place in the Hôtel. The wallpaper has a tint. "In this light, the wallpaper has a distinctly [tint of the wallpaper] wash. [if the tint of the wallpaper is darkish purple]You particularly dislike purple.[end if]"
Before going to the Hôtel: now the wallpaper is a random tint.
After going from the Hôtel, say "You leave, shaking your head. But within twenty-four hours, you are back, as you always knew you would be."
Test me with "in / out / look / in / out / look".
While this isn't very interesting as IF, it runs through most of the adaptive-text tricks.
"Olfactory Settings"
The Doghouse is a room. "Not so much a place as a state of being."
The player carries a ticket to the opera, some papers, and a bouquet of flowers. The bouquet is ambiguously plural.
Instead of eating something inedible, say "[The noun] [don't] seem likely to agree with [us] at all. [We][']d be wiser to leave [regarding the noun][them] alone."
Instead of touching something: say "[regarding the noun][Those] [are] all prickly."
Instead of smelling something: say "[Our] nose [regarding nothing][are] too weak to get much smell from [regarding the noun][those]."
Instead of smelling the bouquet: say "[regarding the noun][They]['re] lovely."
Instead of tasting something:
say "Whew, [regarding the noun][are] [those] ever nasty!"
Test me with "x ticket / eat it / eat them / touch it / touch them / smell it / smell them / taste it / taste them / x papers / eat it / eat them / touch them / smell them / taste them / x bouquet / eat it / eat them / touch them / smell them / taste them".
|
ExampleResponsive
Altering the standard inventory text for when the player is carrying nothing.
|
|
The most straightforward way to alter the response text for something in the standard rules is to select the Index tab, then select Actions, then pick the particular action whose text we'd like to alter. Under action details, there will be icons that look like speech bubbles.
Clicking on the speech bubble will show what the current response text is, and give us an option called "set".
If we click "set", this will automatically paste in the response name that we need to change. We can put this inside a "when play begins" rule in order to make that change take effect from the start of the game, like so:
"Responsive"
An Anonymous B613 Cell is a room. "There isn't much to see in this bare room. What there is, you've already seen sometime in the last twenty years."
When play begins:
now print empty inventory rule response (A) is "[We] [have] absolutely nothing.".
Test me with "i".
|
ExampleProlegomena
Replacing precise numbers with "some" or other quantifiers when too many objects are clustered together for the player to count at a glance.
|
|
Room descriptions often make the player character out to be a bit of a savant, able to count whole stacks of items at a glance: "You see 27 paper clips here."
We can adjust this behavior to our liking, though, with the printing a number... activity, as follows:
"Prolegomena"
The Editor's Office is a room. The desk is a supporter in the Editor's Office.
A red pencil is a kind of thing. 12 red pencils are on the desk.
A letter is a kind of thing. 12 letters are on the desk. Understand "correspondence" as a letter.
Rule for printing the plural name of a letter:
if the listing group size is greater than 7, say "correspondence";
otherwise say "letters".
Rule for printing a number of something (called the target) when the listing group size is greater than 7:
say "[one of]some [or]various [or]an assortment of [at random]";
carry out the printing the plural name activity with the target.
This general rule can of course be overridden by more specific ones; for instance, if we want to take the opportunity to comment on the viewpoint character's appetite for instruments of correction:
Rule for printing a number of red pencils (called the target) when the listing group size is greater than 10:
carry out the printing the plural name activity with the target;
say " in nearly-sufficient quantity".
Test me with "get two letters / look / get a pencil / i / get pencil / g / g / look / i / get all / i".
If we want to change individual responses to player action, then the best thing to do is to use the response facility to modify those selections, as shown in the chapter on Responses.
However, suppose what we want is to give the parser a speech impediment that slightly alters all of the responses it issues. For this purpose, we might need to do a bit of text replacement...
"Wesponses"
The Office is a room. Barry Kripke is a man in the Office.
The response inhibition is initially false.
Rule for issuing the response text of a response (called R) when response inhibition is false:
now response inhibition is true;
let output be "[text of R]";
now response inhibition is false;
replace the text "r" in output with "w";
replace the text "R" in output with "W";
say "[output]".
Test me with "i / x barry / listen / waffle / jump"
Notice that this doesn't affect the printed names of objects in the room description or other kinds of output text -- only those that are issued by the response mechanism.
It would also not work to try to give our parser a nervous personality by simply adding "Um, " to the beginning of each response, because responses are not guaranteed to be full standalone sentences. For example, we could imagine writing
Rule for issuing the response text of a response (called R) when response inhibition is false:
now response inhibition is true;
let output be "Um, [text of R]";
now response inhibition is false;
say "[output]".
but here is what the room description would say as a result:
Office
Um, You Um, can see Barry KripkeUm, here
We can now change the case of any text produced by a "to say..." phrase. This is often useful when we would like to make use of a standard say phrase in some new context. Say, for instance, that we would like to "[is-are the list...]" in a context that needs the first letter to be capitalized.
We could write a new say phrase, such as "to say is-are the list of (N - a description of objects) in sentence capitalization"; but there is an easier way, and that is to set a text variable to the output of the to say phrase, and then print that text in the case of our choice.
For example:
"Rocket Man"
Instead of going somewhere from the spaceport when the player carries something:
let N be "[is-are the list of things carried by the player] really suitable gear to take to the moon?" in sentence case;
say "[N][paragraph break]".
The Spaceport is a room. North of the Spaceport is the Rocket Launch Pad. The player carries a stuffed bear, a chocolate cookie, and a book.
The description of the book is "It is entitled [italic type]Why Not To Take [sentence cased inventory] To The Moon[roman type]."
To say sentence cased inventory:
let N be "[a list of things carried by the player]" in title case;
say "[N]".
Test me with "n / x book".
In this example, we want the names of rooms to be asterisked out if the player wanders around without the benefit of a candle. We can do this by treating the room names as text, then replacing every letter:
"Blackout"
Tiny Room is a dark room. Absurdly Long-Named Room is a dark room. It is west of Tiny Room.
The Candle Factory is north of Tiny Room. It contains a beeswax candle. The beeswax candle is lit.
Rule for printing the name of a dark room:
let N be "[location]";
replace the regular expression "\w" in N with "*";
say "[N]".
Test me with "w / look / e / n / get candle / s / w".
Notice that the hyphen in the Absurdly Long-Named Room does not get replaced. We could replace even that, if we liked, with
replace the regular expression "\S" in N with "*";
which would catch every character that is not a space.
|
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.
|
|
"Curare"
A thing has a number called the last use. The last use of a thing is usually 0.
Definition: a thing is old if its last use is 12 or less.
The actual number chosen in this definition is pretty much irrelevant: the main thing is that we want to establish relative values. The lower the "last use" number of an item, the older that item should be understood to be, as we see here:
To decide which thing is cyclically random (collection - a description of objects):
let choice be the oldest member of the collection;
now the last use of the choice is the turn count;
decide on choice.
This phrase will select, from the collection of objects passed to it, the one that has been mentioned least recently. This means that if we consult it repeatedly about the same collection, it will begin to cycle predictably; but if new items are added to the collection, it will mention these first before returning to the previous cycle. Now we can use this:
After taking inventory:
say "You stare morosely at [the cyclically random thing carried by the player], wondering what you're ever going to find to do with it."
We could have said "You stare morosely at [the oldest thing carried by the player]" here, but doing so would not have set the "last use" property correctly, so we would not get the cycling behavior that we're looking for.
The Evidence Room is a room. Some shelves are scenery supporters in the Evidence Room. A box is a kind of container which is open and not openable. On the shelves is a box. It contains a deformed bullet and a driver's license.
The player carries a steel fish hook, a Chinese passport, a tube of synthetic curare, and an envelope full of Euros.
Test me with "i / i / i / i / i / i / get all from box / i / i / i".
|
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]".
|
|
Suppose we are writing a game in which the mood of the piece changes, and we would like to have lots of descriptions that vary according to its current state. We might in that case want to create our own "by atmosphere" token, to control text variations, like this:
"Blink"
Atmosphere is a kind of value. The atmospheres are normal, melancholy, and creepy.
The current atmosphere is an atmosphere that varies.
The current atmosphere variable translates into I6 as "current_atmosphere".
To say by atmosphere -- ending say_one_of with marker I7_SOO_ATM:
(- {-close-brace} -).
Since we're operating within the untyped Inform 6, we can make use of the fact that kinds of value are (internally) just constants, enumerated in the same order in which they were originally defined. In other words, "normal" at the I6 level translates to 1, "melancholy" to 2, and "creepy" to 3; so we can return the value of the current atmosphere, and thereby select option 1, 2, or 3:
Include (-
Global current_atmosphere = 1;
[ I7_SOO_ATM oldval count;
if (count < current_atmosphere) return count;
return current_atmosphere; ];
-)
And that concludes the hard part. Now to test that it works:
The Flat is a room. "A small [one of]but cozy[or]depressing[or]imprisoning[by atmosphere] flat. Outside the window, the sun is [one of][or][or]apparently [by atmosphere]shining and there is a brisk breeze through the leaves of the birch trees. [one of]It would be quite nice weather for a walk[or]The rest of the world apparently has no appreciation of what you suffer[or]It all looks deceptively normal[by atmosphere]."
Instead of waiting when the current atmosphere is normal:
say "Everything stretches wide and flat for just a moment, as though all the world around you were painted on a thin rubber sheet that is being [italic type]stretched[roman type]. Then it snaps back into place, leaving your ears ringing. But that little glitch was enough to warn you. Someone is tampering with space-time again. Someone very close by.";
now the current atmosphere is creepy.
Test me with "look / z / look".
|
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.
|
|
Mostly the Standard Rules use verbs adapted to finite forms ("he jumped", "we take the hammer", and so on). But Inform can also produce participles to describe actions that are ongoing: "he is carrying the fedora" or "taking the hammer..."
In this example, we give non-player characters actions to perform and then have Inform dynamically describe what they're doing when the player chooses to look.
We start by establishing the idea that a verb can describe a particular action:
"Fun with Participles"
Section 1 - Descriptive Functionality
Describing relates various verbs to various action names. The verb to describe means the describing relation.
To look around is a verb. The verb look around describes the looking action.
To stand about is a verb. The verb stand about describes the waiting action. To look bored is a verb. The verb look bored describes the waiting action. To waste time is a verb. The verb waste time describes the waiting action.
To jump is a verb. To leap is a verb. To pirouette is a verb. The verb jump describes the jumping action. The verb leap describes the jumping action. The verb pirouette describes the jumping action.
Now we need to give every character some sort of idle activity. By default, we'll have people just be waiting, but allow for that idle activity to change into something more interesting if the player has told them to do something else.
A person has an action name called the current idle. The current idle of a person is usually the waiting action.
Rule for writing a paragraph about someone (called chosen person) when a verb describes the current idle of the chosen person:
say "[The chosen person] [are] here, [present participle of a random verb that describes (the current idle of the chosen person)]."
Instead of someone doing something:
now the current idle of the person asked is (the action name part of the current action);
continue the action.
A persuasion rule:
persuasion succeeds.
Section 2 - Scenario
Lab is a room. The fedora is a wearable thing in the Lab. Clark is a man in the Lab.
And just to give past participles a test-drive as well, let's make Clark a bit of a drama king:
After Clark doing something when a verb describes (the action name part of the current action):
say "'Fine, have it your way!' Clark exclaims. 'But I have [past participle of a random verb that describes (the action name part of the current action)] for the last time!'";
rule succeeds.
Test me with "look / Clark, jump / look / Clark, look / look / Clark, wait".
|
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.
|
|
Verbs can be related to other things by relations. We've seen that it's possible for a verb to "mean" a relationship. But we can also create a relation between verbs and actions. For instance, we can tell Inform that "take", "get", and "acquire" are all valid ways to describe the action of taking, and then allow it to pick a verb randomly to describe whatever action just occurred.
"Variety"
Section 1 - Descriptive Functionality
Describing relates various verbs to various action names. The verb to describe means the describing relation.
To take is a verb. To acquire is a verb. To get is a verb.
The verb take describes the taking action. The verb acquire describes the taking action. The verb get describes the taking action.
To drop is a verb. To put down is a verb. To discard is a verb. The verb drop describes the dropping action. The verb put down describes the dropping action. The verb discard describes the dropping action.
To sniff is a verb. To smell is a verb. The verb sniff describes the smelling action. The verb smell describes the smelling action.
To jump is a verb. To leap is a verb. To pirouette is a verb. The verb jump describes the jumping action. The verb leap describes the jumping action. The verb pirouette describes the jumping action.
After an actor doing something when the noun is nothing and a verb describes (the action name part of the current action) (this is the apply random verbs to describing nounless actions rule):
say "[The actor] [verb rendering applied to a random verb that describes (the action name part of the current action)].";
rule succeeds.
After an actor doing something to something when a verb describes (the action name part of the current action) (this is the apply random verbs to describing actions rule):
say "[The actor] [verb rendering applied to a random verb that describes (the action name part of the current action)] [the noun].";
rule succeeds.
To decide which text is the rendering of (V - verb) (this is verb rendering):
decide on "[adapt V]".
Section 2 - Scenario
Lab is a room. The table is here. The bat and the ball are on the table.
Test me with "get ball / drop ball / get bat / drop bat / smell ball".
|
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.
|
|
Some of our default actions establish relations between items in the world, and reporting on the relation ("You are now carrying the fedora") can be a valid response alongside reporting on the action itself ("You take the fedora").
To do this, we need to teach Inform explicitly which relations are the results of actions, then check this when reporting on actions:
"Variety 2"
Section 1 - Descriptive Functionality
Describing relates various verbs to various action names. The verb to describe means the describing relation.
Table of Action Results
related action
|
relation
|
the taking action
|
the carrying relation
|
the wearing action
|
the wearing relation
|
the taking off action
|
the carrying relation
|
To take is a verb. To acquire is a verb. To get is a verb.
The verb take describes the taking action. The verb acquire describes the taking action. The verb get describes the taking action.
To drop is a verb. To put down is a verb. To discard is a verb. The verb drop describes the dropping action. The verb put down describes the dropping action. The verb discard describes the dropping action.
To sniff is a verb. To smell is a verb. The verb sniff describes the smelling action. The verb smell describes the smelling action.
To jump is a verb. To leap is a verb. To pirouette is a verb. The verb jump describes the jumping action. The verb leap describes the jumping action. The verb pirouette describes the jumping action.
To don is a verb. The verb don describes the wearing action.
To doff is a verb. The verb doff describes the taking off action.
After an actor doing something when the noun is nothing and a verb describes (the action name part of the current action) (this is the apply random verbs to describing nounless actions rule):
say "[The actor] [verb rendering applied to a random verb that describes (the action name part of the current action)].";
rule succeeds.
After an actor doing something to something when a verb describes (the action name part of the current action) (this is the apply random verbs to describing actions rule):
let current action name be the action name part of the current action;
if a random chance of 1 in 2 succeeds and the current action name is a related action listed in the Table of Action Results:
choose a row with the related action of current action name in the Table of Action Results;
let R be the relation entry;
let subject be the actor;
let chosen object be the noun;
say "[The subject] [are] now [present participle of a random verb that means R] [the chosen object].";
else:
say "[The actor] [verb rendering applied to a random verb that describes (the action name part of the current action)] [the noun].";
rule succeeds.
To decide which text is the rendering of (V - verb) (this is verb rendering):
decide on "[adapt V]".
To say infinitive of (V - a verb): (- {V}(1); -).
To say past participle of (V - a verb): (- {V}(2); -).
To say present participle of (V - a verb): (- {V}(3); -).
Section 2 - Scenario
Lab is a room. The fedora is a wearable thing in the Lab.
Test me with "wear the fedora / take off the fedora / wear fedora / take off fedora".
|
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.
|
|
Suppose that we wanted authors to be able to indicate which relations should or should not be included in room descriptions, and have the system dynamically honor that instruction.
Inform already knows about verbs for describing supporting, containment, carrying, and wearing, so we could write a set of instructions to handle such cases. To do this, we're using the "writing a paragraph about" activity, which is described in the chapter on activities.
The following uses what is, strictly speaking, a piece of internal machinery not really intended for public use: a variable called "prior named object" which keeps track of what noun other words should agree with. It is not safe to use this variable except to clear it: "now the prior named object is nothing". In a few situations, this prevents glitches in adaptive text.
"Relevant Relations"
Section 1 - Procedure
Rule for writing a paragraph about something (called item):
now the current paragraph is { };
say "[one of][regarding item]There [are] [an item] here[or][We] [can see] [an item] here[at random]. [run paragraph on]";
follow the descriptive rules for the item;
repeat with new item running through the current paragraph:
now the prior named object is nothing;
if new item is not the item:
follow the descriptive rules for the new item;
say paragraph break.
Rule for writing a paragraph about someone (called chosen person):
now the current paragraph is { };
say "[one of][regarding chosen person][The chosen person] [are] here[or][We] [can see] [a chosen person] here[at random]. [run paragraph on]";
follow the descriptive rules for the chosen person;
repeat with new item running through the current paragraph:
now the prior named object is nothing;
if new item is not the chosen person:
follow the descriptive rules for the new item;
say paragraph break.
The descriptive rules are an object-based rulebook.
Definition: a container is see-through:
if it is transparent:
yes;
if it is open:
yes;
no.
A descriptive rule for a see-through container (called item) (this is the describe contents rule):
describe the containment relation for item.
A descriptive rule for a supporter (called item):
describe the support relation for item.
A descriptive rule for a person (called item):
describe the wearing relation for the item.
A descriptive rule for a person (called item):
describe the carrying relation for the item.
The current paragraph is a list of things that varies.
Before printing the name of something (called mentioned target) while writing a paragraph about something:
add the mentioned target to the current paragraph, if absent.
To describe (R - a relation of objects) for (item - a thing):
if a thing to which item relates by R is a thing:
say "[The item with pronoun] [verb rendering applied to a random verb that means R] [the list of things to which item relates by R with indefinite articles]. [run paragraph on]"
To decide which text is the rendering of (V - verb) (this is verb rendering):
decide on "[adapt V]".
To say (T - a thing) with pronoun:
if T is the prior named object:
say "[regarding T][They]";
else:
say "[The T]"
Section 2 - Scenario
The Space Elevator is a room. "Mercifully, there aren't any windows. The ability to see how far up you are would almost certainly make you ill."
The luggage rack is a supporter in the Space Elevator. The suitcase is a closed openable container on the luggage rack. The bouquet is on the luggage rack.
Clark is a man in the Space Elevator. Clark is carrying a box of cupcakes. Clark is wearing a t-shirt. The description of the box of cupcakes is "They're the latest confection from Red Velvet Planet, the Martian bakery."
Persuasion rule: persuasion succeeds.
We can if we like then add alternate names for these relations that will be randomly swapped in some of the time. For instance:
To sport is a verb. The verb to sport means the wearing relation.
To hold up is a verb. The verb to hold up means the support relation.
Test me with "clark, drop the box / look / clark, take the suitcase / look / clark, get bouquet".
One might, hypothetically, imagine going even further than this and simply designating relations as either "important" or "unimportant" -- perhaps changing the relation's designation at runtime. Relations are not themselves allowed to have properties, however.
Sometimes it is more sensible to describe numbers roughly than in exact terms. For instance, we might want to have our player perceive "many people" rather than "forty-two people" on entering a room. To achieve this, we might write our own "to say" phrase.
"Ballpark"
To say (count - a number) in round numbers:
repeat through the Table of Numerical Approximation:
if count is less than threshold entry:
say "[approximation entry]";
rule succeeds.
Phrases will be explained more thoroughly in a later chapter, but as we have already seen in the examples, we can make a "To say..." phrase that will allow us to create our own text substitutions. In this case, we are going to replace the specific number with a vaguer one chosen from a chart, so:
Table of Numerical Approximation
threshold
|
approximation
|
1
|
"no"
|
2
|
"one"
|
3
|
"a couple of"
|
6
|
"a few"
|
11
|
"some"
|
21
|
"many"
|
1000
|
"lots and lots of"
|
The idea here is that we will work our way through the table until we hit a line where the threshold number is higher than the number we want to express, and then print that output: so if we have less than one item, we'll print "no"; if we have more than none but less than two, we'll print "one"; if we have less than three, we'll print "a couple of"; if we have three, four, or five (but not six), we'll print "a few."
A room has a number called the population. The population of a room is usually 0. The description of a room is usually "You observe [population of the location in round numbers] [if population of the location is 1]person [otherwise]people [end if]here.".
The Stadium is a room. The Hot Dog Stand is west of the Stadium. The Women's Restroom is south of the Stadium.
The population of the Stadium is 500. The population of the Hot Dog Stand is 3. The population of the Restroom is 750.
Test me with "w / e / s".
There is only so much we can cram into a text property, so being able to swap in properties is useful but limited. Fortunately, we can also, if we want, create new phrases for how to say things in brackets:
"Fifty Times Fifty Ways"
The Beekeeper's Palace is a room. Wasp is a woman in the palace. Drone is a man in the palace.
A person can be fierce or mellow. Wasp is fierce. Drone is mellow. A person can be calm or angry. A person is usually calm. A person has some text called insult. The insult of a person is usually "Grasshopper". The insult of Wasp is "Larva".
Instead of kissing someone:
say "'[denial for the noun], [insult for the noun]! [boast]!'";
Now to provide some meaning to these bracketed forms. We'll start with the easy one:
To say boast:
say "I have ferocious allies".
This is a "to say" phrase; we will learn more about phrases in a later chapter, but for now it may be enough to observe that whatever we write after "to say..." becomes a valid substitution in bracketed speech. In this particular case there is no advantage to using the boast token rather than spelling the text out in the quotation, but we might in theory add further instructions to randomize the output, for instance.
To say phrases can be more complex, as well, since we can have them incorporate extra information:
To say insult for (speaker - a person):
if speaker is angry, say "[the insult of the noun]";
otherwise say "small one".
Here where we have (speaker - a person), we are leaving a slot which we can later fill in, madlibs-like, with any person we like. That is why we can write "insult for the noun": we are summoning the To say phrase and telling it to fill in the identity of the unknown speaker with the noun.
This differs from "insult of the noun" in the previous example; in that case, each person had his own insult property, and were merely printing that property out. Here we are actually telling Inform to calculate anew what the insult should be, and giving it some instructions about how to do that.
Our instructions can also get arbitrarily complex:
To say denial for (speaker - a person):
if speaker is calm:
say "You must not";
otherwise if speaker is female:
say "Stand back";
otherwise:
say "You forget yourself".
Instead of attacking someone:
now the noun is angry;
say "'Get away, [insult]!'"
Test me with "kiss wasp / hit wasp / kiss wasp / kiss drone / hit drone / kiss drone".
So the effects we can get with text substitutions are quite flexible. We could even, if we wanted, fill in the substitutions by random choice, or by selecting items from a long list or table, should we have so bellicose a set of characters that they cannot make do with one or two insulting remarks apiece.
As we saw in "Variety", we can associate verbs with particular actions and call them up as needed. If we do that, though, we can also store additional information about those verbs and use that information to select the ideal verb to use in a particular situation.
In this example, we create a table of verbs and their meanings, together with some connotative information. Each time we report an action, we then score all the available verbs to decide which is the most suitable to use at the moment. This allows us to change the narrator's diction change mid-game and have the action descriptions change as well.
Moreover, because we're using adaptive verbs, these responses will automatically inflect properly even if we change the story tense and viewpoint.
"Narrative Register"
Section 1 - Descriptive Functionality
Describing relates various verbs to various action names. The verb to describe means the describing relation.
To take is a verb. To acquire is a verb. To get is a verb. To gain is a verb. To obtain is a verb. To pick up is a verb. To bag is a verb. To procure is a verb. To score is a verb. To grab is a verb. To snag is a verb. To snatch is a verb. To collect is a verb.
To drop is a verb. To put down is a verb. To discard is a verb. To throw away is a verb. To dispose of is a verb. To set down is a verb. To toss aside is a verb. To ditch is a verb. To abandon is a verb. To dump is a verb. To jettison is a verb. To abjure is a verb. To foresake is a verb. To dispense with is a verb.
After an actor doing something to something when a verb describes (the action name part of the current action) (this is the apply random verbs to describing actions rule):
score the relevant verbs;
sort the Table of Verb Meanings in reverse relevance order;
choose row 1 in the Table of Verb Meanings;
let top score be the relevance entry;
sort Table of Verb Meanings in random order;
repeat through the Table of Verb Meanings:
if relevance entry is top score:
say "[The actor] [verb rendering applied to (word entry)] [the noun].";
erase relevance;
rule succeeds.
To decide which text is the rendering of (V - verb) (this is verb rendering):
decide on "[adapt V]".
To score the relevant verbs:
repeat through the Table of Verb Meanings:
if the meaning entry is (the action name part of the current action):
increase relevance entry by 1;
repeat with chosen connotation running through connotations entry:
if the chosen connotation is listed in the current register:
increase relevance entry by 1;
otherwise:
decrease relevance entry by 1.
To erase relevance:
repeat through Table of Verb Meanings:
now relevance entry is 0.
A tonality is a kind of value. The tonalities are pompous, archaic, slangy, upbeat, downbeat.
Connoting relates various verbs to various tonalities. The verb to connote means the connoting relation.
The current register is a list of tonalities that varies. The current register is { }.
When play begins:
repeat through the Table of Verb Meanings:
now the word entry describes the meaning entry;
now relevance entry is 0;
repeat with chosen tone running through the connotations entry:
now the word entry connotes the chosen tone.
Table of Verb Meanings
word
|
meaning
|
connotations
|
relevance ( a number )
|
the verb take
|
the taking action
|
{ }
|
the verb acquire
|
the taking action
|
{ pompous }
|
the verb get
|
the taking action
|
{ }
|
the verb gain
|
the taking action
|
{ }
|
the verb obtain
|
the taking action
|
{ pompous }
|
the verb pick up
|
the taking action
|
{ }
|
the verb bag
|
the taking action
|
{ slangy }
|
the verb score
|
the taking action
|
{ slangy, upbeat }
|
the verb procure
|
the taking action
|
{ archaic }
|
the verb grab
|
the taking action
|
{ slangy }
|
the verb snag
|
the taking action
|
{ slangy }
|
the verb snatch
|
the taking action
|
{ slangy }
|
the verb collect
|
the taking action
|
{ }
|
the verb discard
|
the dropping action
|
{ pompous }
|
the verb drop
|
the dropping action
|
{ }
|
the verb put down
|
the dropping action
|
{ }
|
the verb toss aside
|
the dropping action
|
{ }
|
the verb ditch
|
the dropping action
|
{ slangy }
|
the verb throw away
|
the dropping action
|
{ }
|
the verb dispose of
|
the dropping action
|
{ }
|
the verb set down
|
the dropping action
|
{ }
|
the verb abandon
|
the dropping action
|
{ downbeat }
|
the verb dump
|
the dropping action
|
{ downbeat }
|
the verb abjure
|
the dropping action
|
{ archaic }
|
the verb foresake
|
the dropping action
|
{ archaic }
|
the verb jettison
|
the dropping action
|
{ pompous }
|
the verb dispense with
|
the dropping action
|
{ pompous }
|
Section 2 - Changing Tone Mid-Game
Understand "new tone" as changing the tone. Changing the tone is an action out of world.
Carry out changing the tone:
now the current register is { };
if a random chance of 1 in 4 succeeds:
say "Your narrator will now adopt an ordinary tone.";
rule succeeds;
let rando be a random tonality;
add rando to the current register, if absent;
say "Your narrator will now be [rando]."
Section 3 - Scenario
Lab is a room. The table is here. The bat and the ball are on the table.
Test me with "get ball / drop ball / get bat / drop bat / new tone / get all / drop all / new tone / get all / drop all".
"Straw Into Gold"
The Cell is a room. Rumpelstiltskin is an improper-named man in the Cell. Rumpelstiltskin can be identified or unidentified. Rumpelstiltskin is unidentified.
R-name is a kind of value. The R-names are dwarf, guy, dude, and man-thing. Rumpelstiltskin has an R-name. Understand "[R-name]" as Rumpelstiltskin.
Our example is slightly complicated by the fact that "man" is a name already known to Inform, so we can't re-use it as a kind of value. This is possible to work around, though:
Understand "man" as man-thing.
Now we borrow from the Activities chapter to look at the exact wording of the player's command:
After reading a command:
if the player's command includes "[R-name]",
now the R-name of Rumpelstiltskin is the R-name understood;
if the player's command includes "Rumpelstiltskin":
now Rumpelstiltskin is identified;
now Rumpelstiltskin is proper-named.
Rule for printing the name of Rumpelstiltskin when Rumpelstiltskin is unidentified:
if the R-name of Rumpelstiltskin is man-thing:
say "man";
otherwise:
say "[R-name]".
Test me with "x dwarf / x guy / x dude / look / x rumpelstiltskin / look / x man".