Inform 7 Home Page / Documentation
§14.3. More on adapting verbs
If we need an adaptive message with a verb which doesn't belong to Inform's built-in set, all we need do is define it. In the previous chapter we defined verbs by giving them meanings, but in fact that's optional. For example:
defines a verb without telling Inform what it means. Inform will throw a Problem message if we try to write text like:
because, after all, it doesn't know what "retrofit" means. But it does still know how to print it, so this works:
which might come out as "Dale retrofits the Mecha-Mole", or "Barin's archers retrofitted the Mecha-Mole", and so on.
This is especially neat for writing a single response to an action which works regardless of who the actor was. For example, the Standard Rules include:
And this can make either:
You put the revolver on the table.
General Lee puts the revolver on the table.
Start of Chapter 14: Adaptive Text and Responses | |
Back to §14.2. Adaptive text | |
Onward to §14.4. Adapting text about the player |
ExampleFun with Participles |
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:
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.
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 |
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.
Describing relates various verbs to various action names. The verb to describe means the describing relation.
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]".
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 |
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:
Describing relates various verbs to various action names. The verb to describe means the describing relation.
related action |
relation |
the taking action |
the carrying relation |
the wearing action |
the wearing relation |
the taking off action |
the carrying relation |
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]".
Test me with "wear the fedora / take off the fedora / wear fedora / take off fedora".
ExampleNarrative Register |
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.
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.
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 } |
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]."
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".