We begin with the idea that each person comes with his own table of things to say:
"Farewell"
A person has a table name called conversation.
Instead of asking someone about something:
let the source be the conversation of the noun;
if topic understood is a topic listed in source:
if there is a turn stamp entry:
say "[The noun] has already told you that [summary entry].";
otherwise:
now turn stamp entry is the turn count;
say "[reply entry][paragraph break]";
otherwise:
say "[The noun] stares at you blankly."
For the sake of simplicity, we'll conflate asking and telling here, though it would certainly be possible to have a more complex implementation if we want the characters to be told things as well.
Instead of telling someone about something:
try asking the noun about it.
Now we might want to add a recap command to review conversation that has already occurred.
Definition: a person is other if it is not the player.
Understand "recap" or "recall" or "review" as recalling conversations.
Recalling conversations is an action applying to nothing.
Since we've been recording the turn count of each conversation bit, we can even present these in order by sorting the tables first.
Carry out recalling conversations:
repeat with speaker running through other people:
let source be the conversation of the speaker;
sort source in turn stamp order;
say "[The speaker] has so far told you: [line break]";
let index be 0;
repeat through source:
if there is a turn stamp entry:
let index be 1;
say " [summary entry][line break]";
if index is 0, say " absolutely nothing[line break]";
say conditional paragraph break.
Now it remains only to create a couple of characters and provide them both with something to say:
The Farewell Bend Cafe is a room. "Beautiful Farewell Bend, Idaho -- or is it Oregon? An almost-abandoned truckstop, in any case, on one of those interminable American east-west highways."
Tina is a woman in the Farewell Bend Cafe. The conversation of Tina is the Table of Tina's Chatter. "Tina the waitress is slowly pouring coffee from the pot with a black neck into the pot with an orange neck."
George is a man in the Farewell Bend Cafe. The conversation of George is the Table of George's Chatter. "There is also a large man at table five. The tattoo on his arm says George. For the moment we will assume that it is his own name and not someone else's."
Table of Tina's Chatter
topic
|
reply
|
summary
|
turn stamp
|
"aasvogel"
|
"'Oh, it's a vulture.'"
|
"that an aasvogel is a vulture"
|
a number
|
"acaudate"
|
"She shrugs, mid-pour. 'Means something doesn't have a tail.'"
|
"that acaudate means 'tailless'"
|
--
|
"absorptiometer"
|
"'It's a thing that measures the solubility of gases in a liquid,' she explains gently, as to a child."
|
"that an absorptiometer measures solubility of gasses in a liquid"
|
--
|
Table of George's Chatter
topic
|
reply
|
summary
|
turn stamp
|
"baccaceous"
|
"'Something that has or bears berries,' says George, without looking up."
|
"that baccaceous means berry-bearing or berry-like"
|
a number
|
"bagheera"
|
"'Oh, that'd be a velvet-like textile.'"
|
"that bagheera is a velvet-like textile"
|
--
|
"balistarius"
|
"'That's a crossbow-man,' George replies instantly."
|
"that a balistarius is a crossbow-man"
|
--
|
A word of warning: this system does assume that every person in the game has a conversation table defined. If that were not the case, we would have to be a bit more careful.
As always, we can override specific words, too:
Instead of asking Tina about "advertisement" for the first time:
say "Tina looks embarrassed. 'Of course! I almost forgot.' She hands you a brochure.";
move the brochure to the player.
The encyclopedia sales brochure is a thing. The description is "A glossy flyer indicating that you can receive a free Volume A-Aalto of the New Idahoan Encyclopedia Set if you send back the business reply card, and then have the option of purchasing the remaining volumes at a very very reasonable price."
Test me with "recap / ask tina about aasvogel / recap / ask george about baccaceous / ask tina about absorptiometer / recap / ask tina about advertisement / read brochure".
"Sweeney"
A subject is a kind of thing. Some subjects are defined by the Table of Conversation Subjects.
Table of Conversation Subjects
subject
|
conversation
|
pies
|
Table of Pie Queries
|
employment
|
Table of Job Queries
|
Understand "job" as employment. Understand "meat" or "food" as pies.
Table of Job Queries
quip
|
discussion
|
label
|
subtopics
|
"whether there is a job available here"
|
"'Say, are you hiring?' you ask, as casually as you can manage. [The interlocutor] looks you over dubiously. 'I might be hiring someone, but I can't say it would necessarily be you.'"
|
0
|
--
|
"what happened to that boy that worked here"
|
"'Tell me, didn't you used to have a young assistant working here?' She shrugs. 'Young men these days are so unstable. He left-- who knows where he's gone? I haven't seen hair or fingernail of him for weeks.'"
|
0
|
--
|
with 3 blank rows.
|
Table of Pie Queries
quip
|
discussion
|
label
|
subtopics
|
"what pie fillings are available"
|
"'What pies do you have in today, Mrs Lovett?' you ask. She starts, then smiles. 'Meat pies, of course.'"
|
0
|
Table of Pie Flavor Queries
|
with 3 blank rows.
|
Table of Pie Flavor Queries
quip
|
discussion
|
label
|
subtopics
|
"what kind of meat"
|
"'What kind of meat goes into these pies, Mrs Lovett?' you ask pressingly. She looks shifty. 'Whatever the butcher brings this week,' she says. 'With the price of meat what it is, when you get it, you have to be glad of what you can get. If you get it.'"
|
0
|
--
|
To copy (first table - a table name) to (second table - a table name):
repeat through first table:
let copied quip be "blank";
if there is a quip entry, now the copied quip is the quip entry;
let copied discussion be "blank";
if there is a discussion entry, now the copied discussion is the discussion entry;
let copied subtopics be second table;
if there is a subtopics entry, now the copied subtopics are the subtopics entry;
choose a blank row in the second table;
if copied quip is not "blank", now quip entry is copied quip;
if copied discussion is not "blank", now discussion entry is copied discussion;
if copied subtopics is not second table, now subtopics entry is copied subtopics.
Current conversation table is a table name that varies. Current conversation table is Table of Job Queries.
Interlocutor is a person that varies.
Understand "ask [someone] about [any subject]" as asking it about the subject.
Asking it about the subject is an action applying to two visible things.
Carry out asking it about the subject:
say "You can't think of anything to say."
Instead of asking someone about the subject a subject listed in the Table of Conversation Subjects:
now interlocutor is noun;
now current conversation table is the conversation of the second noun;
if the number of filled rows in the current conversation table is 1:
repeat through current conversation table:
now label entry is 1;
now number understood is 1;
try selecting 1 instead;
if the number of filled rows in the current conversation table is 0:
say "You can think of nothing further to say on that topic.";
stop the action;
otherwise:
let index be 0;
let total be the number of filled rows in the current conversation table;
say "Do you mean ";
repeat through current conversation table:
now index is index + 1;
now label entry is index;
say "([index]) [quip entry]";
if index is total, say "?";
if index is total - 1, say ", or ";
if index is less than total - 1, say ", ".
Understand "[number]" as selecting.
Selecting is an action applying to one number.
Carry out selecting:
say "No such option is available."
Instead of selecting a label listed in the current conversation table:
say "[discussion entry][paragraph break]";
if there is a subtopics entry:
copy subtopics entry to current conversation table;
choose row with label of number understood in the current conversation table;
blank out the whole row.
Mrs Lovett's Meat Pies is a room. Mrs Lovett is a woman in Meat Pies.
Test me with "ask lovett about pies / ask lovett about employment / 1 / 2 / ask lovett about pies".
As we have seen, there are a number of different ways of controlling conversation in interactive fiction, and the best choice of way will depend quite a lot on what kind of work we're writing.
One common model is to replace Inform's default ASK and TELL commands with a TALK TO command. This gives the player less control than he would otherwise have: instead of asking a character about any topic under the sun, he's restricted to seeing (or not seeing) a single sequence of text that the author has written in advance. On the other hand, such a system is harder for the player to break (since he can never ask about a topic that the author hasn't implemented), and easier for the author to tie into plot developments. If we give TALK TO different output at each scene, we get conversation that is always tied to the current state of the plot.
This is a design approach that works best in a game with a large number of short, focused scenes. For other kinds of conversation system design, compare the other examples listed in the Recipe Book.
"The Cheese-makers" by Phrynichus.
Chapter 1 - Replacing old talk commands and making a new one
Here, using some techniques that will be discussed in the chapter on Understanding, we get rid of Inform's default handling of ASK and TELL, and create our own TALK TO action instead:
Understand the commands "ask" and "tell" and "say" and "answer" as something new.
Understand "ask [text]" or "tell [text]" or "answer [text]" or "say [text]" as a mistake ("[talk to instead]").
Instead of asking someone to try doing something:
say "[talk to instead][paragraph break]".
Instead of answering someone that something:
say "[talk to instead][paragraph break]".
To say talk to instead:
say "(To communicate in [story title], TALK TO a character.) "
Understand "talk to [someone]" as talking to. Understand "talk to [something]" as talking to. Talking to is an action applying to one visible thing.
Chapter 2 - Specific scenes and talking
Now, suppose we have a situation -- say, a stage play -- in which it is appropriate to talk to different characters at different times. During the prologue of the play, no one else is on-stage, and the player is to address the audience directly:
Section 1 - Prologue
When play begins:
now right hand status line is "416 BC";
now left hand status line is "[location]".
Prologue is a scene. Prologue begins when play begins.
The Theater of Dionysus is a room.
The audience is a person in the Theater. "The usual audience looks on: the priests and judges in the front row, and then Athenians, metics, and foreigners." The audience can be prepared or unprepared. The description is "Have you ever seen such a company of perjurers, pathics, and thieves?" Understand "priest" or "priests" or "priest of dionysus" or "judge" or "judges" or "athenians" or "metics" or "foreigners" as the audience.
Instead of talking to the player when the Prologue is happening:
say "There will be plenty of occasion for muttered asides later in the play, but for now you must prepare the audience for things to come."
Instead of talking to the audience when the Prologue is happening:
say "Drawing breath, you turn to the audience, and offer them a genial, witty, colorful, and of course crude synopsis of what they are about to see; describing all the characters in unmistakable terms and not omitting the most important of them all, your august self.";
now the audience is prepared.
Instead of talking to the audience when the Prologue has happened:
say "You may only direct monologues to the audience when the other actors are off-stage. Otherwise, their characters might have to notice."
Prologue ends when the audience is prepared.
But there might follow a scene in which the player shouldn't talk at all:
Section 2 - Parodos
Parodos is a scene. Parodos begins when Prologue ends.
When Parodos begins:
move the chorus to the theater.
Instead of talking to someone during Parodos:
say "Sssh: this moment belongs to the chorus. They've worked so hard on it, after all."
Parodos ends when the time since Parodos began is 4 minutes.
The chorus is a person. The description is "They are dressed in exaggerated rural costume and feminine masks, as they are meant to represent a company of female cheese-makers from the Spartan-occupied deme of Dekeleia." Understand "cheesewives" or "cheese-makers" or "chorus-leader" as the chorus.
Every turn during Parodos:
repeat through Table of Choral Events:
say "[output entry][paragraph break]";
blank out the whole row;
make no decision.
Table of Choral Events
output
"The chorus now begins its entry, accompanying with anapestic song its march up the eisodos."
"The chorus draws nearer, stomping and clomping and swinging their baskets of cheese."
"You stand aside as the chorus fills the orchestra and dances to and fro."
"The tune of the aulos-player grows more and more frenzied and then breaks off."
This last rule is a refinement borrowing from the Activities chapter, which gives characters different appearances in room descriptions depending on when we happen to look; because of the action of the play, we want to show the chorus and audience doing different things during different scenes.
Rule for writing a paragraph about the chorus during Parodos:
say "The chorus are dancing and singing their way[if the time since Parodos began is less than 3 minutes] up the long walkways onto the stage[otherwise] into position in the orchestra[end if]. [The audience] appear to be pricing their costumes to the nearest obol: woe to the producer who cheats them of their due share of spectacle."
And now a scene in which the player can talk several times to a character (Heracles) but has no useful dialogue with the chorus, the audience, or himself. The prohibition from talking to the audience after the Prologue is already written, but we'll supply some appropriate responses for talking to the player or the chorus during this scene:
Section 3 - Episode
Episode is a scene. Episode begins when Parodos ends.
When Episode begins:
move Heracles to the theater;
say "The chorus falls silent, which is the cue: Heracles bursts out of the scene building."
Heracles is a man. The description is "Hard to mistake in his lion skin and boots, and carrying a formidable club." Heracles wears a lion skin and boots. He carries a formidable club. Heracles can be placid or annoyed. Heracles is placid. Heracles can be satisfied, intrigued, or unsatisfied. Heracles is unsatisfied.
Instead of talking to the chorus during Episode:
say "Your improvised flirtation with the chorus raises no response but a crude gesture from the chorus-leader, who seems to be modeling the role on Iambe."
Instead of talking to the player during Episode:
if Heracles is annoyed:
say "You mutter to yourself about men with more appetite than brain. The actor playing Heracles ignores you, but it's good odds he's scowling under his mask. He hates it when anyone but himself ad-libs for attention.";
otherwise:
now Heracles is annoyed;
say "'By the dog, he'll eat me if he gets a chance,' you mutter aside. [paragraph break]'What's that you say, my ignoble friend?' demands Heracles, hefting his club. He's not entirely joking: you've left the script just now."
Instead of talking to Heracles when Heracles is unsatisfied during Episode:
say "'Dear Heracles, friendly Heracles,' you begin, cringing out of the way as he responds with one of his affectionate ox-killing punches to the shoulder. [paragraph break]But Heracles falls still, and looks almost thoughtful, as tell him you know how he may rout the Spartans, woo all twenty-four lactic ladies, and tame his savage gut with a bathtubful of porridge. [paragraph break]'Speak on, little man,' he says.";
now Heracles is intrigued.
Instead of talking to Heracles when Heracles is intrigued during Episode:
say "It takes several exchanges for him to wrap his one-inch brain around your ten-inch plan; but in the end he embraces the scheme, the women, and your humble self.";
now Heracles is satisfied.
Every turn when not talking to someone during Episode:
repeat through Table of Episodic Events:
say "[output entry][paragraph break]";
blank out the whole row;
make no decision.
Table of Episodic Events
output
"With a fart and a roar, Heracles asks the world at large, and you in particular, where his dinner might be."
"In epic diction, Heracles invites the dairy-mistresses, whey-matrons, and concubines of curd to supply him a supper from their ample baskets."
"Heracles and the chorus banter about the proclivities of cheese-wives. The chorus suggest that Heracles, as a son of Zeus, must know something about the appetites of which they speak."
"Heracles boasts that a man like himself can perform any feat, but only when his belly is full. Coyly, the matrons prance and dance, skip and gambol out of his grasp, singing mockingly about heads of garlic and loaves of sesame-crusted bread."
"The song of the feta fanciers now turns to pots of honey and new-made wine, borrowing verses from last year's Lenaia winner, 'The Bees'. With a jolt, you realize that you've missed your cue and the chorus are filling in for you."
"Playing for time, the chorus-leader elaborates a whole banquet: rabbit stew, shanks of lamb, spitted quails, eels from lake Copais. Heracles looks as near swooning as any girl fresh from Brauron."
"The chorus-leader extends the list of delicacies to include ox-brains, ham-hocks, barley, mullet, carrots, pigeons, lentils, radishes, peas, and apples both wine-dark and golden. The audience shifts on the benches. An expression of gloom settles over the Priest of Dionysus in the front row."
"Inspired by Euripides['] own Muse, the chorus-leader invents a mock-Alcaean hymn on the merits of chervil. This is clearly his swan-song: if you don't speak at last, the play will come to a halt."
"Silence descends."
Rule for writing a paragraph about Heracles during Episode:
say "[Heracles] stands at the center of the orchestra, with members of [the chorus] ranged on either side. [paragraph break][The audience] appear to be reserving their judgement, though they show signs of restiveness at the usual jokes: must there be a Heracles in [italic type]every[roman type] play?"
Episode ends successfully when Heracles is satisfied.
When Episode ends successfully:
say "That, of course, is your cue: you're to come back on as Pan thirty verses from now, and it takes time to put on the hooves and the woolly-legged trousers.";
end the story saying "You exit".
Episode ends disastrously when the number of filled rows in the Table of Episodic Events is 0.
When Episode ends disastrously:
end the story saying "The production has crashed to a halt".
Test me with "ask audience about me / tell audience about me / audience, hello / audience, jump / talk to me / talk to audience / g / talk to chorus / look / x heracles / talk to me / talk to audience / z / look / talk to heracles / g".
The "reading a command" activity is not the only point at which we can interact with snippets, as it happens; it is merely the most useful. "The player's command" can be consulted at other points, however, as in this example of your somewhat deaf (or distracted, or simply cussed) Aunt:
"Complimentary Peanuts"
Instead of asking Aunt Martha to try doing something:
repeat through Table of Aunt Martha's Commentary:
if player's command includes topic entry:
say "[commentary entry][paragraph break]";
rule succeeds;
say "'Hmmf,' says Aunt Martha."
The topic understood is also a snippet, so that whenever one has been generated, we can treat it in the same way as "the player's command":
Asking someone about something is speech.
Telling someone about something is speech.
Answering someone that something is speech.
Asking someone for something is speech.
Instead of speech when the noun is Aunt Martha:
repeat through Table of Aunt Martha's commentary:
if the topic understood includes topic entry:
say "[commentary entry][paragraph break]";
rule succeeds;
say "'Hmmf,' says Aunt Martha."
This is superior to checking "the player's command" because we do not want ASK MARTHA ABOUT FRENCH FRIES to trigger the "Martha" keyword, only the "french fries" keywords.
The Empyrean Shuttle Bay is a room. "From here you have an excellent view of the colony world, which looks... well, it looks discouragingly orange. But terraforming is in progress."
Aunt Martha is a woman in the Empyrean Shuttle Bay. A gleaming shuttle and a stack of rations are in the Shuttle Bay. The shuttle is a vehicle. "Your shuttle awaits."
Table of Aunt Martha's Commentary
topic
|
commentary
|
"shuttle"
|
"'Shuttles! I hate shuttles,' Aunt Martha grumbles. 'Give me an airplane! AIRPLANE.'"
|
"airplane/airport"
|
"'Those were the days,' Aunt Martha agrees, plainly reliving the days when she wore a blue-and-white uniform and passed out packets of salted pretzels."
|
"rations"
|
"'Do you think there are any peanuts in there?' she asks in a wistful tone."
|
Test me with "martha, get in the shuttle / martha, for pity's sake, do you see an airplane around here? / martha, pass me the rations".
This means that Martha will respond to keywords regardless of the setting in which they occur. For instance:
>martha, get in the shuttle
"Shuttles! I hate shuttles," Aunt Martha grumbles. "Give me an airplane! AIRPLANE."
>martha, for pity's sake, do you see an airplane around here?
"Those were the days," Aunt Martha agrees, plainly reliving the days when she wore a blue-and-white uniform and passed out packets of salted peanuts.
>martha, pass me the rations
"Do you think there are any peanuts in there?" she asks in a wistful tone.
This is not the stuff of which Loebner-winning chatbots are made, admittedly, but it is occasionally a useful alternative to stricter modes of command-parsing.