Inform 7 Home Page / Documentation
§7.13. Traveling Characters
There are a number of ways we can make characters navigate our map. We might reasonably want them to approach and follow the player (as in Van Helsing); or to allow the player to follow characters who have left the room (as in Actaeon).
Characters who are less interested in the player will more likely follow their own courses around the available geography, however. A character may move randomly from room to room, as demonstrated in Mistress of Animals; he may follow a path that we have specifically written in advance, as Odyssey shows; or, most elegantly, he may use the "best route" calculation to find the best possible way to a given target room, as seen in Latris Theon.
This final method is arguably the neatest solution to character movement, allowing for characters to act in sophisticated ways; if we incorporate the Locksmith extension, other characters will even unlock and open doors that are in their way. The chief catch is that it should not be used too profligately with large numbers of characters, since on slow machines the processing power required to plan all their travel will make a noticeable difference to the running speed of the story.
All the same, the constraints are not so severe as to preclude having a moderate number of route-finding characters all wandering around at once. This does introduce a new problem, however: movement descriptions can become hard to follow if every turn produces long reams of reports such as
Joe enters the room from the south.
Lawrence opens the gate.
Lawrence departs to the west.
Lucy comes in from above.
Ted enters the room from the south.
Bill departs to the west.
Patient Zero tackles this problem by calculating all of the character movement without printing any text; it then combines similar or related events into coherent paragraphs, as in
Rhoda and Antony walk into the Post Office. Rhoda could have been rolling in chocolate and Antony looks as though dipped in french vanilla.
or
See Doors, Staircases, and Bridges for some technical details of allowing other characters to interact with doors when they're in rooms that don't contain the player
Start of Chapter 7: Other Characters | |
Back to §7.12. Characters Following a Script | |
Onward to §7.14. Obedient Characters |
ExampleMistress of Animals |
Suppose we want a restless sort of character always pacing from room to room. It is quite easy to use adjacency to achieve this effect:
Corinth is a room. Athens is east of Corinth. Epidaurus is southeast of Corinth and east of Mycenae. Mycenae is south of Corinth. Olympia is west of Mycenae. Argos is south of Mycenae. Thebes is northwest of Athens. Pylos is south of Olympia. Sparta is east of Pylos and south of Argos. Delphi is northwest of Thebes.
Every turn:
if Artemis is in a room (called the current space):
let next space be a random room which is adjacent to the current space;
if Artemis is visible, say "Artemis heads to [the next space].";
move Artemis to next space;
if Artemis is visible, say "Artemis arrives from [the current space]."
Of course, it helps that Artemis is the sort to like open spaces. The implementation would become more complicated if there were doors which might block transit between these locations.
ExampleVan Helsing |
Suppose we want to write a character who tries to be in the same room as the player. We will do this by testing every turn whether the character's location and the player's location are the same; if the answer is no, the character will look for a path to the player's location, then try to move along that path. (We will learn more about finding paths and giving characters instructions later.)
The result will be that if the player ever moves to another location, the character will automatically pursue him.
The Drawbridge is a room. North of the Drawbridge is the Immensely Enormous Entry Hall. West of the Entry Hall is the Vast Dining Area. North of the Vast Dining Area is the Colossal Kitchen. The Spooky Guano-filled Attic is above the Entry Hall.
In the following condition, we could also have written "if the location of Count Dracula is not the location", because "location" by itself is always understood to be the player's location. But it seemed better for clarity to write it this way:
Every turn:
if the location of Count Dracula is not the location of the player:
let the way be the best route from the location of Count Dracula to the location of the player, using doors;
try Count Dracula going the way;
otherwise:
say "'Muhahaha,' says Count Dracula."
ExampleOdyssey |
Corinth is a room. Athens is east of Corinth. Epidaurus is southeast of Corinth and east of Mycenae. Mycenae is south of Corinth. Olympia is west of Mycenae. Argos is south of Mycenae. Thebes is northwest of Athens. Pylos is south of Olympia. Sparta is east of Pylos and south of Argos. Delphi is northwest of Thebes.
Athena will proceed, unless delayed, through a list of locations stored in a simple table. Rather than using Inform's route-finding abilities ("the best route from..."), we simply move Athena from one location to the next, not even using the going action: she moves in mysterious ways, as befits a goddess.
Table of Athena's Movement
destination
Thebes
Delphi
Thebes
Athens
Corinth
Mycenae
Every turn when Athena is active:
repeat through the Table of Athena's Movement:
let last space be the location of Athena;
if Athena can be seen by the player, say "Athena heads to [the destination entry].";
move Athena to destination entry;
if Athena can be seen by the player, say "Athena arrives from [the last space].";
blank out the whole row;
break.
By blanking out the table line by line, we make sure that we never lose our place in the path.
Since we want the player to be able to talk to Athena, we need a way to stall her in her path, as well.
Before doing something to Athena:
now Athena is passive;
say "Athena waits around patiently, though you can tell she would like to leave..."
Instead of telling Athena about something:
say "She watches you patiently as though to say that she already knows."
Instead of asking Athena about something:
say "Her response is inscrutably ancient and Greek. Afterwards you remember only the flash of bright eyes."
Finally, we do need to wake Athena up again if she has become passive. The following rule will occur after the movement rule just because of code ordering, though we could make matters more explicit if we needed to:
Test me with "east / northwest / wait / examine athena / wait".
ExampleActaeon |
Suppose we want the player to be able to go after characters who are moving around the map. The trick, of course, is that once characters are gone they are no longer visible to "follow [person]", so we need "follow [any person]" to find them.
Understand "follow [any person]" as following. Understand the commands "chase" and "pursue" as "follow".
Check following:
if the noun is the player, say "Wherever you go, there you are." instead;
if the noun is visible, say "[The noun] is right here." instead;
if the last location of the noun is not the location, say "It's not clear where [the noun] has gone." instead.
Here again the best route comes in handy:
Carry out following:
let the destination be the location of the noun;
if the destination is not a room, say "[The noun] isn't anywhere you can follow." instead;
let aim be the best route from the location to the destination;
say "(heading [aim])[line break]";
try going aim.
Corinth is a room. Athens is east of Corinth. Epidaurus is southeast of Corinth and east of Mycenae. Mycenae is south of Corinth. Olympia is west of Mycenae. Argos is south of Mycenae. Thebes is northwest of Athens. Pylos is south of Olympia. Sparta is east of Pylos and south of Argos. Delphi is northwest of Thebes.
We do also have to make sure that whenever we move a person from room to room, we record where they were moved from; otherwise, our clever restrictions about whom the player can pursue will not work properly.
To move (pawn - a person) tidily to (target - a room):
now the last location of the pawn is the holder of the pawn;
move the pawn to the target.
Every turn:
let current location be the location of Artemis;
let next location be a random room which is adjacent to the current location;
if Artemis is visible, say "Artemis heads to [the next location].";
move Artemis tidily to next location;
if Artemis is visible, say "Artemis arrives from [the current location]."
Test me with "wait / follow artemis / follow artemis / follow artemis".
ExampleLatris Theon |
To begin with, we create an action for going to a named place. All that this action will do is to change that person's hoped-for destination: the actual moving around comes later.
Carry out someone going vaguely:
now the destination of the person asked is the noun.
Report someone going vaguely:
say "[The person asked] looks amused, but accepts the commission to go to [the noun]."
It stands to reason the player plays Zeus or at the very least Apollo, but let's not let this go to the player's head. Note that the following rule applies to the player, but not to anyone else, so HERMES, GO TO ATHENS will work but GO TO ATHENS will not.
And finally we recreate Greece and one of its heroes.
Corinth is a room. Athens is east of Corinth. Epidaurus is southeast of Corinth and east of Mycenae. Mycenae is south of Corinth. Olympia is west of Mycenae. Argos is south of Mycenae. Thebes is northwest of Athens. Pylos is south of Olympia. Sparta is east of Pylos and south of Argos. Delphi is northwest of Thebes.
Hermes is a man in Corinth. The destination of Hermes is Corinth. [So he is initially happy where he is.] Persuasion rule for asking Hermes to try going vaguely: persuasion succeeds. [But he is open to suggestions.]
Every turn when the destination of Hermes is not the location of Hermes:
let the right direction be the best route from the location of Hermes to the destination of Hermes;
try Hermes going the right direction.
It simplifies matters that our map of Greece makes it possible to reach any location from any other location, by some sequence of movements: if there were an isolated location -- say, Crete -- with no map connection to the mainland, then we would have to worry about the "right direction" not being a direction at all. The following version of Hermes' trekking rule is protected against the possibility:
Every turn when the destination of Hermes is not the location of Hermes:
let the right direction be the best route from the location of Hermes to the destination of Hermes;
if the right direction is a direction, try Hermes going the right direction.
ExamplePatient Zero |
Understand "about" as asking for information. Asking for information is an action out of world.
Carry out asking for information: say "An implementation of the following creative brief:
People wander around some small map, on errands. One, sad to tell, has Gelato's Syndrome, a tragic condition turning one's skin the colour of a random flavour of ice cream (raspberry ripple, neapolitan, etc.). When two people are in the same room, there's a 1/3 chance that an infected person will infect a non-infected one. The player can cure any single person: victory condition - to stamp out the disease."
When play begins:
say "Gelato's Syndrome. It's struck, and it's struck hard. In these sticky summer months, there's no telling who will contract the disease next.";
now the command prompt is "[if the destination of the player is not blank](heading to [destination of the player]) [end if]>".
The current actor is a person which varies. The current owner is a person which varies.
Every turn:
if player is active, follow the character movement rules.
Every turn:
now the last person named is the player;
now the last thing named is the player;
now every person is active.
The first character movement rule:
now group size is 1;
now the last person named is the player;
now the last thing named is the player;
now the player is passive.
A character movement rule:
repeat with mover running through innocent people:
now the current actor is the mover;
follow the shopper rules;
now the current actor is passive;
follow the movement reporting rule.
A character movement rule:
repeat with next mover running through mercantile people:
now the current owner is the next mover;
follow the shopowner rules;
now the current owner is passive;
follow the infection rule.
To decide whether movement has not yet occurred:
if the player is passive, no;
yes.
Definition: a person is mercantile if it owns a room. Definition: a person is innocent if it is not mercantile and it is not the player.
A shopowner rule:
let the shop be a random room owned by the current owner;
if the shop is air-conditioned and an open door (called the escape) protects the shop, try the current owner closing the escape instead.
Report someone closing a door when the person asked owns the location:
say "[The person asked], muttering darkly about air-conditioning and electricity, closes [the noun]." instead.
Report Vanessa closing the metal door when the metal door is visible:
if Vanessa is visible, say "Vanessa watches serenely as the metal door slides automatically back in place, sealing Cold Comfort." instead;
otherwise say "The metal door slides heavily back into place." instead.
A shopowner rule:
if the location of the current owner encloses a submitted artwork (called the target):
try the current owner filing the target.
Before someone filing something which is not carried by the person asked:
try the person asked taking the noun instead.
Carry out someone filing:
if the person asked does not carry the noun and the person asked is visible, say "[The person asked] tries unsuccessfully to get [the noun]." instead;
now the noun is nowhere.
Report someone filing:
say "[The person asked] registers [the noun] and files it away."
A shopper rule:
if the current actor carries something (called the problem), try the current actor resolving the problem instead.
A shopper rule:
if the current actor is not in the pool hall and the air conditioner is switched on:
try the current actor approaching the pool hall;
otherwise:
let way be a random direction;
try the current actor going the way.
Definition: a room is air-conditioned:
if it is outdoors, no;
if it is the Pool Hall and the air conditioner is switched off, no;
if it is protected by a door, yes;
no.
Protection relates a door (called X) to a room (called Y) when the front side of X is Y or the back side of X is Y. The verb to protect means the protection relation.
Ownership relates one person to various rooms. The verb to own means the ownership relation.
An artwork is a kind of thing. Before printing the name of an artwork, say italic type. After printing the name of an artwork, say roman type. An artwork can be submitted or reserved.
Before someone resolving a book when the person asked is not in the Public Library:
try the person asked approaching the Public Library instead.
Carry out someone resolving a book:
move the noun to the Public Library;
now the noun is submitted.
Report someone resolving a book:
say "[The person asked] turns in [the noun]."
Before someone resolving a stamped envelope when the person asked is not in the Post Office:
try the person asked approaching the Post Office instead.
Carry out someone resolving a stamped envelope:
now the noun is nowhere.
Report someone resolving a stamped envelope:
say "[The person asked] slips [a noun] into the outgoing mail slot."
Instead of someone resolving a stamped envelope when the person asked carries at least two stamped envelopes:
if the person asked is visible, say "[The person asked] shoves into the mail slot [a list of stamped envelopes carried by the person asked].";
repeat with item running through stamped envelopes carried by the person asked:
now the item is nowhere.
Before someone resolving a DVD when the person asked is not in the Rental Store:
try the person asked approaching the Rental Store instead.
Carry out someone resolving a DVD:
now the noun is submitted;
move the noun to the Movie Rental Store.
Report someone resolving a DVD:
say "[The person asked] returns [the noun]."
Instead of someone resolving a DVD when the person asked carries at least two DVDs:
if the person asked is visible, say "[The person asked] turns in [a list of DVDs carried by the person asked].";
now every DVD carried by the person asked is submitted;
now every DVD carried by the person asked is in the location of the person asked.
Carry out someone approaching:
let the way be the best route from the location of the person asked to the noun, using doors;
if the way is a direction, try the person asked going the way;
otherwise stop the action.
Carry out someone resolving a coupon:
try the person asked giving the noun to Vanessa.
Check giving something to someone (this is the block player giving rule):
abide by the block giving rule.
Before someone resolving a coupon when the person asked is not in Cold Comfort:
try the person asked approaching Cold Comfort instead.
After someone giving a coupon to Vanessa:
let the reward be a random ice cream cone;
let the new flavor be a random infection color;
now the infection color of the reward is the new flavor;
move the reward to the person asked;
now the noun is nowhere;
if Vanessa is visible, say "[The person asked] trades in [the noun] and receives [a reward] from Vanessa."
Infection color is a kind of value. The infection colors are french vanilla, whole-bean vanilla, mint, chocolate, dark chocolate, chocolate chip, chocolate fudge, mint chocolate chip, chocolate chocolate chip, triple chocolate, white chocolate, white chocolate chip, aztec cocoa-chili, raspberry ripple, neapolitan, rum raisin, dulce de leche, strawberry chunk, rocky road, blackberry sorbet, lemon sherbet, lime ice, caramel swirl, mango, saffron silk, and cookie dough cream.
To say list of flavors:
let current color be french vanilla;
while current color is not cookie dough cream:
say "[current color], ";
now current color is the infection color after the current color;
say "and [current color]".
Understand "ask vanessa for [flavored ice cream]" as buying the flavor. Understand "buy [flavored ice cream]" as buying the flavor.
Buying the flavor is an action applying to one infection color.
Check buying the flavor:
unless the player can see Vanessa:
say "It would help if you were in the presence of an ice cream salesperson." instead.
Carry out buying the flavor: say "'Do you have a coupon?' Vanessa demands. You admit you do not. 'No [infection color understood] for you!'"
Understand "ice cream" or "cream" or "ice" or "sherbet" or "sorbet" as "[ice cream]".
Understand "[infection color]" or "[infection color] [ice cream]" as "[flavored ice cream]".
An ice cream cone is a kind of thing. An ice cream cone is always edible. An ice cream cone has an infection color. An ice cream cone can be half-eaten or fresh. Understand the infection color property as referring to an ice cream cone.
Carry out someone resolving an ice cream cone:
try the person asked eating the noun instead.
Instead of someone eating a fresh ice cream cone:
now the noun is half-eaten;
if the person asked is visible, say "[The person asked] licks [the noun]."
Report someone eating an ice cream cone:
say "[The person asked] pops the end of [the noun] into [if the person asked is female]her[otherwise]his[end if] mouth and swallows." instead.
Before printing the name of an ice cream cone:
say "[if half-eaten]half-eaten [end if][infection color] ".
This is the infection rule:
if an infected person (called typhoid mary) can see a clean person (called random bystander) and a random chance of 1 in 3 succeeds:
try typhoid mary sneezing on the random bystander.
A person can be infected or clean. A person has an infection color.
Every turn:
if the player is infected, say "You feel itchy."
Definition: a person is other if it is not the player. Definition: a person is another if it is other.
When play begins: now right hand status line is "Sick: [number of infected people]/[number of people]".
Every turn:
if every person is infected, end the story saying "Everyone succumbs";
if every person is clean, end the story finally saying "The Syndrome is eradicated".
Understand "sneeze on [something]" as sneezing on. Sneezing on is an action applying to one thing.
Check sneezing on:
if the player is clean, say "You're not sickly." instead;
if the noun is the player, say "Ew." instead;
if the noun is not a person, say "[The noun] cannot be infected." instead.
Carry out sneezing on:
now the noun is infected;
now the infection color of the noun is a random infection color.
Carry out someone sneezing on:
now the noun is infected;
now the infection color of the noun is a random infection color.
Report sneezing on:
say "Unable to control yourself, you sneeze on [noun].".
Report someone sneezing on:
say "[The person asked] sneezes on [if the noun is the player]you[otherwise][noun][end if]!".
Understand "inject [someone] with [something]" as injecting it with. Understand "inject [someone] with [syringe]" as injecting it with. Understand "use [syringe] on [someone]" as injecting it with. Understand the commands "innoculate" and "vaccinate" as "inject".
Check injecting it with:
if the second noun is not the syringe, say "[The second noun] cannot inject anything." instead;
if the noun is clean:
if the noun is the player, say "You're not infected yet." instead;
say "[The noun] is not infected, and the syringe contains a cure, not a vaccine." instead.
After injecting the player with something: say "You inject yourself, wincing at the sting. But the itching fades almost at once."
Report injecting it with: say "You inject [the noun], who is now cured (but could easily be reinfected)."
Understand "go to/toward/into [any room]" as going toward. Understand "enter [any room]" as going toward.
Check going toward:
if the noun is the location, say "You're already in [the location]." instead.
Carry out going toward:
now the destination of the player is the noun;
let heading be the best route from the location to the noun, using even locked doors;
if heading is not a direction, say "You can't think how to get there from here." instead;
try going heading;
if the location is the destination of the player, now the destination of the player is blank.
Instead of waiting when the destination of the player is not blank:
if the destination of the player is the location:
now the destination of the player is blank;
otherwise:
try going toward destination of the player;
if the location is the destination of the player, now the destination of the player is blank.
Understand "stop" or "cease" as stopping. Stopping is an action applying to nothing. Carry out stopping: now the destination of the player is blank. Report stopping: say "You stop in your tracks."
After going to an air-conditioned room:
say "You step into the mercifully air-conditioned surroundings of...";
continue the action.
After going from an air-conditioned room:
say "You emerge from the air-conditioning into heat like a wall...";
continue the action.
Instead of listening to an air-conditioned room:
say "The air-conditioning hums softly."
The Alfred Cralle Pool Hall is a room. "The town's most popular gathering-place, the pool hall is decorated in honor of the inventor of the ice cream scoop." The air conditioner is a device in the Pool Hall. "[if switched off]An air conditioner sits in the corner, unhappily inert[otherwise]The air conditioner hums briskly[end if]."
The felt door is west of the Pool Hall. The felt door is a door. The felt door is open. The felt door is lockable and unlocked. The key to the city unlocks the felt door. The description of the felt door is "It has a prominent lock, designed for an old-fashioned key."
After locking a door with something in the presence of an other person (called audience):
say "[The audience] looks a little non-plussed when you lock [the noun], but shrugs."
Nancy Johnson Memorial Square is west of the felt door. The description of Nancy Johnson Memorial Square is "Waves of August heat rise from the pavement: more than once you've had the fancy that your shoes are simply going to stick. At the center of the square, rubbed to a brownish polish by many adoring hands, is the statue of Mrs. Nancy Johnson of New Jersey."
The statue is scenery in Memorial Square. Understand "nancy" or "johnson" or "mrs" as the statue. The description of the statue is "Mrs. Johnson is pictured with a hand-cranked ice cream freezer tucked under one arm. Her other hand grips an ice cream scoop, ready to serve frozen dessert to the huddled masses." A hand-cranked ice cream freezer is part of the statue. The description is "The hand-cranked ice cream freezer was Mrs. Johnson's invention in 1846, though it was William Young who had the sense to patent the thing in 1848." The scoop is part of the statue. The description of the scoop is "An anachronism: Alfred Cralle would not invent the tool until 1897."
The Post Office is northwest of Nancy Johnson Memorial Square. "Service at the post office is on the slow side since everything went automated." The slot is scenery in the post office. The slot is a container. Carry out inserting something into the slot: now the noun is nowhere. Report inserting something into the slot: say "[The noun] falls out of sight, and you know you will never see it again."
Hamwi Street is northeast of an iron gate. "A U-shaped street running from Main Street around to the Memorial Square, Hamwi Street was recently added by ambitious city planners. The small and straggly line of trees has yet to grow enough to provide perceptible shade, so the street is even hotter and more unforgiving than the other parts of town."
The iron gate is northeast of Nancy Johnson Memorial Square. The iron gate is a door. It is lockable and unlocked.
Before printing the name of the iron gate while not opening or closing or locking or unlocking:
if the person asked is the player:
if the gate is open, say "open ";
otherwise if the gate is locked:
say "locked ";
otherwise if the gate is closed:
say "closed ".
Cold Comfort Ice Cream is north of a metal door. The metal door is north of Hamwi Street. A poster is fixed in place in Cold Comfort. "A poster fills one wall with the blazing promise of treats to come." The description of the poster is "Coming soon! Thai ice creams! Durian, jackfruit, taro, and coconut flavors!"
The metal door is a door. "A frosty metallic door separates [the location] from [the other side of the metal door]." The metal door is lockable and unlocked. The key to the city unlocks the metal door.
Marciony Street is southeast of Nancy Johnson Memorial Square. "A semi-circular terrace, named somewhat fancifully after one claimant to the invention of the ice cream cone -- though Hamwi Street competes for the same honor. There are wedges of cool shadow here and there thanks to the buildings, but for the most part the southern exposure keeps Marciony unpleasantly hot."
The Movie Rental Store is west of a glass door. The glass door is a door. It is west of Marciony Street. The glass door is lockable and unlocked. The key to the city unlocks the glass door.
Main Street is southeast of Hamwi Street. Main Street is northeast of some bronze gates.
The emergency box is in Main Street. The emergency box is fixed in place. "A fire-red box with a glass front faces the sidewalk, with 'In case of emergency, BREAK GLASS' lettered on it." The emergency box is closed and transparent. Understand "glass" as the box. Instead of attacking the closed emergency box: say "You hit the emergency box, which shatters open."; now the emergency box is open. Instead of attacking the open emergency box: say "The glass has already been thoroughly broken."
The syringe is in the emergency box. The description of the syringe is "It contains the cure for Gelato's Syndrome. You can inject anyone you like with it."
The bronze gates are northeast of Marciony Street. The bronze gates are a door. The bronze gates are lockable and unlocked. The description of the bronze gates is "Erected during the milk-taint revolution of 1937, they were designed to keep Main Street safe from the depredations of dairy-starved rioters."
The Public Library is east of Main Street. "Built in the 1920s during the height of the dairy boom, the public library has lush pink velvet seats, marble walls the color of fresh cream, and a motif of cherries carved around every doorframe. An incongruous sign hangs from the ceiling." The incongruous sign is scenery in the Public Library. The description of the incongruous sign is "Eating and drinking in the library is STRICTLY PROHIBITED."
Town Hall is southeast of Main Street. "Town Hall was built during the slow days of the ice-cream bust, and therefore it is as joyless and utilitarian as the Public Library is ridiculous. Unwilling to be reminded of their pain, the inhabitants steered clear of any decoration that might remotely be construed to resemble a scoop of anything: so there are no curves, only disciplined right angles." The key to the city is in Town Hall. It unlocks the iron gate. It unlocks the bronze gates. The description of the key to the city is "A skeleton key."
A room can be indoors or outdoors. The Post Office, the Alfred Cralle Pool Hall, the Store, Cold Comfort, Town Hall, and the Library are indoors.
After looking in an outdoors room:
let started printing be false;
now every proximate door is not mentioned;
if an indoors room is adjacent:
let started printing be true;
say "From here you can head into [the list of adjacent indoors rooms][if a proximate door is not mentioned], or go through [the list of proximate doors which are not mentioned][end if]. [run paragraph on]";
if an outdoors room is adjacent:
say "You could[if started printing is true] also[end if] go ";
let count be the number of adjacent outdoors rooms;
let index be count;
repeat with next room running through adjacent outdoors rooms:
let way be the best route from the location to the next room;
say "[way] to [the next room]";
decrement index;
make delimiter index of count, continuing;
if a proximate door is not mentioned:
let started printing be true;
say "[if started printing is true]Also available[otherwise]Your available exits[end if] [is-are the list of proximate doors which are not mentioned].";
otherwise:
if started printing is true, say paragraph break.
Definition: a door is proximate:
if the front side of it is the location, yes;
if the back side of it is the location, yes;
no.
Before exiting when the player is in an indoors room:
if the player can see a door (called nearest exit), try entering the nearest exit instead;
repeat with way running through directions:
let next room be the room way from the location;
if the next room is a room, try going way instead.
Blank is a room. The destination of the player is Blank. Blank contains 15 ice cream cones.
Vanessa is a woman in Cold Comfort. Vanessa owns Cold Comfort.
Francine is a woman in the Public Library. Francine carries a book called Phlox for Phyllis. Francine carries a stamped envelope called a pink stamped envelope.
Lewis is a man in the Alfred Cralle Pool Hall. Lewis carries 3 stamped envelopes. Lewis carries a book called Idiot's Guide to Dating. Lewis carries a book called How to Meet Women. Lewis carries a book called Seduction in Three Easy Steps. Lewis carries a DVD called Sleepless in Seattle.
Gene is a man in Nancy Johnson Memorial Square. Gene carries a stamped envelope. Gene carries a DVD called Casablanca. Gene carries a coupon.
Rhoda is a woman in Marciony Street. Rhoda carries a book called The Marciony Street Murders. Rhoda carries a DVD called Unsolved Serial Killings XVIII. Rhoda carries a stamped envelope called a squashy package.
Martin is a man in Main Street. Martin carries a DVD called The Lifecycle of the South Sea Tortoise. Martin carries a coupon.
Antony is a man in Movie Rental. Antony carries a coupon. Antony carries a stamped envelope called a postcard.
Shelby is a man in the Town Hall. Shelby carries a DVD called Conducting An Orderly Meeting. Shelby carries 5 stamped envelopes. Shelby carries an ice cream cone. Shelby carries a coupon.
Christopher is a man in the Library. Christopher owns the Library.
Linnea is a woman in the Alfred Cralle Pool Hall. Linnea owns the Alfred Cralle Pool Hall.
Ned is a man in the Movie Rental Store. Ned owns the Movie Rental.
After printing the name of someone (called target) while listing contents: if the target owns the location of the target, say " (the owner)".
The description of a person is usually "[The noun] [if the noun is clean]looks healthy[otherwise]is the color of [infection color of the noun][end if]."
After examining another person who is carrying something: say "[if the noun is female]She[otherwise]He[end if] is carrying [a list of things carried by the noun]."
When play begins: let Patient Zero be a random other person; now patient zero is infected.
This is a light variation of a previous example, but we use it here because it is convenient:
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 "You have already heard that [summary entry].";
otherwise:
now turn stamp entry is the turn count;
now the character entry is the noun;
say "[reply entry][paragraph break]";
otherwise:
say "[The noun] stares at you blankly.".
Instead of telling someone about something:
try asking the noun about it.
Understand "recap" or "recall" or "review" as recalling conversations.
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 and the speaker is character entry:
let index be 1;
say " [summary entry][line break]";
if index is 0, say " absolutely nothing[line break]";
say line break.
The conversation of a person is usually Table of General ChitChat.
topic |
reply |
summary |
turn stamp |
character |
"weather/heat/warmth" |
"'It's appalling, isn't it? You'd think we didn't pay our taxes.'" |
"that the weather is appalling" |
a number |
a person |
"sun/sunlight" |
"'Good thing the town mostly switched to solar power, har, har.'" |
"that the town is mostly relying on solar power" |
||
"rain" |
"'Nope, there isn't going to be rain for 132 days,' replies [the noun]." |
"that rain is not expected for another 132 days" |
||
"snow/hail/ice" |
"This hilarious sally is greeted with hoots of laughter only." |
"that the concept of snow is downright laughable" |
||
"disease/sickness/illness/syndrome" |
"You get a cold, fixed stare in response. 'That's not funny,' [the noun] replies finally." |
"that discussing the disease is more or less taboo" |
||
"cold comfort" |
"'If you haven't tried it, you should,' says [the noun]. 'Best ice cream in town, and that's saying something, you bet.'" |
"that Cold Comfort has the best ice cream in town" |
||
"town/city/village" |
"'Yeah, it's a mite odd,' allows [the noun]. 'Not to everyone's taste, like...' [the noun as pronoun] considers for a moment. 'Like ginger ice cream. Big pieces of crystallized ginger... not everyone likes that.'" |
"that the town is a mite odd" |
||
"forecast/weatherman" or "weather forecast/man" |
"'Oh, the weather man's gotten a lot more reliable since the gummint started making it for us,' says [the noun]. 'Now he just reads off the schedule on the air every morning. Pretty much takes the fun right out of the news, if you ask me.'" |
"that the weather is all generated by schedule" |
||
"taxes/tax" or "weather tax" |
"A snort. 'You'd think for the rates we pay we'd get something a little pleasanter, don't you?'" |
"that the weather tax really ought to be paying for something nicer than what you get" |
||
"job/employment/work" |
"'[if the noun owns a room (called the shop)]I own [the shop],' replies [the noun][otherwise]Work at the creamery, like most folk around here,' answers [the noun]." |
"this and that about employment in town" |
||
"book/books/reading" |
"'The Public Library has a good selection, excepting only the cookbook section,' says [the noun]. 'That got censored way back when-- well, way back.'" |
"that the Public Library has a good collection, except for the cookbook section" |
The conversation of Vanessa is the Table of Vanessa Chatter.
topic |
reply |
summary |
turn stamp |
character |
"ice cream" or "sorbet/sherbet/flavor/flavors/flavour/flavours/ice/ices" |
"'The flavors are [list of flavors],' she responds promptly, without needing to draw breath." |
"that the flavors are [list of flavors]" |
a number |
a person |
After reading a command:
while player's command includes "the":
cut the matched text.
This strips 'the' out of the command, so that ASK PERSON ABOUT THE RAIN will be understood as well as ASK PERSON ABOUT RAIN.
Now we try something a bit unusual. Inform on its own will report each action on its own line, so that each character who walks into or out of a room will be described in a separate paragraph. This is usually fine, but in a game with a lot of characters moving around simultaneously, it can become a bit overwhelming. Instead, we may want to condense these reports into a single line, such as "Ben and Jerry enter from the south". The following accomplishes that goal by replacing some of the reporting rules, storing the information in a table, and then reading the table back later, once all the character movement has been resolved and the reports can usefully be collated:
A person has some text called walk style. The walk style of a man is usually "stride". The walk style of a woman is usually "strut". The walk style of Gene is "[one of]wander[or]stroll[purely at random]". The walk style of Francine is "waddle". The walk style of Antony is "scamper". The walk style of Rhoda is "sashay".
character |
second |
third |
heading chosen |
total |
a person |
a person |
a person |
a direction |
a number |
with 10 blank rows. |
character |
second |
third |
heading chosen |
total |
a person |
a person |
a person |
a direction |
a number |
with 10 blank rows. |
To clear (current table - a table name):
repeat through current table:
blank out the whole row.
To tidy departures of (current table - a table name):
let next direction be up;
repeat through current table:
if heading chosen entry is next direction:
let accomplice be character entry;
choose row with heading chosen of next direction in the current table;
if total entry is 1:
now second entry is accomplice;
now total entry is 2;
if total entry is 2:
unless the second entry is accomplice:
now third entry is accomplice;
now total entry is 3;
choose row with character of accomplice in the current table;
blank out the whole row;
otherwise:
let next direction be heading chosen entry.
Report someone opening a door:
now group size is 1;
now the last opener of the noun is the person asked;
if the person asked is visible, say "[The person asked] opens [the noun]. [run paragraph on]" instead;
otherwise say "[The noun] opens from the other side. [run paragraph on]" instead.
Report someone going through a door (called route):
if the person asked is not the last opener of the route, continue the action;
if the person asked is the last person named, say "[The person asked as pronoun]";
otherwise say "[The person asked]";
say " [if the person asked is in the location]comes[otherwise]goes[end if] through[if the last thing named is not the route] [the route][end if]." instead.
The last thing named is a thing that varies. Before printing the name of something (called target) which is not a person: now the last thing named is the target.
Report someone going a direction:
if the person asked is in the location,
choose a blank row in the table of visible entrances;
otherwise choose a blank row in the table of visible exits;
now character entry is the person asked;
now total entry is 1;
if the person asked is in the location,
now heading chosen entry is the opposite of the noun;
otherwise now heading chosen entry is the noun;
stop the action.
This is the movement reporting rule:
sort the Table of Visible Entrances in heading chosen order;
tidy departures of the table of visible entrances;
sort the Table of Visible exits in heading chosen order;
tidy departures of the table of visible exits;
let total row count be the number of filled rows in the Table of Visible Entrances plus the number of filled rows in the Table of Visible Exits;
if total row count is 0, rule succeeds;
generate descriptions from the Table of Visible Entrances;
generate descriptions from the Table of Visible Exits;
clear the Table of Visible Entrances; clear the Table of Visible Exits.
To generate descriptions from (current table - a table name):
let count be the number of filled rows in the current table;
if count is 0, rule succeeds;
let index be count;
repeat through the current table:
let accomplice be character entry;
if character entry is a person, now character entry is marked for listing;
if there is a second entry and second entry is a person, now second entry is marked for listing;
if there is a third entry and third entry is a person, now third entry is marked for listing;
let target be the room the heading chosen entry from the location;
if total entry is 3, say "[The character entry], [the second entry][optional comma] and [the third entry] ";
if total entry is 2, say "[The character entry] and [the second entry] ";
if total entry is 1:
if the character entry is the last person named, say "[The character entry as pronoun] ";
otherwise say "[The character entry] ";
if total entry is 1, say "[walk style of the character entry]s ";
otherwise say "walk[if total entry is 1]s[end if] ";
if the character entry is in the location:
if location is indoors and target is indoors, say "over from ";
if location is outdoors and target is indoors, say "out of ";
if location is indoors and target is outdoors, say "in from ";
if location is outdoors and target is outdoors, say "over from ";
otherwise:
if location is indoors and target is indoors, say "over to ";
if location is outdoors and target is indoors, say "into ";
if location is indoors and target is outdoors, say "out [if a door is visible][the random visible door][end if] to ";
if location is outdoors and target is outdoors, say "over to ";
if target is outdoors, say "[the heading chosen entry]";
otherwise say "[the target]";
if the total entry is 1 and count is 1 and accomplice carries something, say ", carrying [a list of things carried by the accomplice]";
decrement index;
make delimiter index of count, continuing;
now group size is total entry;
if a marked for listing person is infected:
[eliminate the case in which we have already seen this description because we just typed LOOK and the patient was in the room at the time]
if looking and a marked for listing person is not in the location:
clear marked people;
say paragraph break;
otherwise:
describe patients;
otherwise:
clear marked people;
say paragraph break.
The last person named is a person that varies. Before printing the name of a person (called target): now the last person named is the target. Group size is a number that varies. Group size is 1.
To clear marked people:
repeat with named party running through people:
now the named party is not marked for listing.
Before listing nondescript items:
if the number of people who are marked for listing is 0, make no decision;
say "You can see [a list of people who are marked for listing] here. ";
now group size is the number of people who are marked for listing;
describe patients;
now every marked for listing person is not marked for listing.
To describe patients:
if every marked for listing person is infected and at least three people are marked for listing:
say "They are all sick as dogs, every one.";
clear marked people;
rule succeeds;
otherwise:
if the number of people who are marked for listing is greater than two and the number of infected people who are marked for listing is greater than the number of clean people who are marked for listing:
say "Only [the list of clean people who are marked for listing] currently remain[if the number of clean people who are marked for listing is 1]s[end if] untainted.";
clear marked people;
rule succeeds;
let count be the number of marked for listing other people who are infected;
if count is 0:
say paragraph break;
make no decision;
let index be count;
repeat with patient running through marked for listing other people who are infected:
if index is count:
if count is 1 and the patient is the last person named:
say "[The patient as pronoun]";
otherwise:
say "[The patient]";
otherwise:
say "[the patient]";
say " [looks as though dipped in for index] [infection color of the patient]";
decrement index;
make delimiter index of count;
clear marked people.
To say (named character - a man) as pronoun:
if group size is 1, say "He"; if group size is 2, say "The latter"; if group size is greater than 2, say "The last".
To say (named character - a woman) as pronoun: if group size is 1, say "She"; if group size is 2, say "The latter"; if group size is greater than 2, say "The last".
To say looks as though dipped in for (index - a number):
let divider be the number of filled rows in the Table of Dipping Phrases;
if index is greater than 4, let index be the remainder after dividing index by divider;
choose row index in the Table of Dipping Phrases;
say dipping entry.
Table of Dipping Phrases
dipping
"looks as though dipped in"
"could have been rolling in"
"has a bad case of"
"suffers from"
"contracted a virulent"
The next part could be simpler, but for rigor we will write it in such a way that it will work whether or not the serial comma is in use. This requires some extra work.
To make delimiter (index - a number) of (count - a number), continuing or halting:
if index is 0:
if continuing, say ". [run paragraph on]";
otherwise say ".";
otherwise if index is 1:
if count is 2, say " and ";
otherwise say "[optional comma] and ";
otherwise:
say ", ".
To say optional comma:
if the serial comma option is active:
say ",".
Test me with "go to cold comfort / z / z / z / z / ask vanessa for french vanilla / ask vanessa for chocolate / ask vanessa about flavors / ask vanessa for chocolate chocolate chip".
Because so much of this game is randomized, it will not be possible to provide a test command that systematically solves it. A good strategy is to go to Main Street, get the syringe; go to the Town Hall and get the key; then visit the shops, inject everyone, and lock them in when they've all been injected. Then go to the Pool Hall, turn on the air conditioner, and wait for the remaining parties to show up.
This is also something that could get fairly slow if we added many more rooms and characters to it. In that case, we might want to select fast route-finding so that character movement won't take as long. This will cost memory, possibly forcing the game into Glulx format if it isn't already, but significantly reduce the run-time for large maps with numerous people moving each turn: