Inform 7 Home Page / Documentation
§19.8. New rulebooks
Creating a new rulebook is also straightforward, as we see in the following modest example story:
The Passage is east of the Tomb. The green-eyed idol is in the Tomb. A Speak-Your-Progress machine is in the Passage.
An appraisal rule: say "Click... whirr... the score is [the score in words] points."
An appraisal rule:
if we have taken the idol, say "Most importantly of all, the idol has been found."
Instead of switching on the machine, follow the appraisal rules.
The creation of the rulebook is all very well, but without the final sentence it would never be used. The crucial new phrase here is:
follow (rule)
This phrase causes the rule to be obeyed immediately (rather than simply at predetermined times such as when a particular action is being tried, or at the end of every turn, and such). Example:
follow the advance time rule;
follow the appraisal rulebook;
Like "number" or "text", "rule" and "rulebook" are kinds of value built into Inform: "the blossom rule" is a value whose kind is "rule", whereas "the every turn rules" is a value whose kind is "rulebook". In fact, Inform considers a rulebook to be a special case of a rule, so that whenever a rule is required it is legal to name a rulebook instead, but not vice versa. The "follow" phrase here...
Instead of switching on the machine, follow the appraisal rules.
...expects to be applied to a value of kind "rule"; "the appraisal rules" is in fact a rulebook, but since that counts as a rule the phrase makes sense to Inform. To follow a rulebook means to run through all its rules in turn, stopping when one rule reaches an outcome; to follow a single rule means just that one, of course.
When created, a rulebook starts out with no rules in it - in this example, of course, we quickly defined a couple of rules to go into it. But it's often the case in Inform that a rulebook exists without ever being stocked up, especially if the rulebook is for some obscure purpose never needed. The built-in adjectives "empty" and "non-empty", applied to a rulebook, test whether any rule is present or not.
Start of Chapter 19: Rulebooks | |
Back to §19.7. The preamble of a rule | |
Onward to §19.9. Basis of a rulebook |
ExampleSolitude |
Observation of novice IF players suggests that they often have a hard time figuring out how to get started, especially if they are encountering the game in a context where they don't have time to settle in and read instructions. Here we provide some training wheels to help them learn to communicate.
This is divided into several parts. The first part is the system of rules for general guidance, which could be excerpted and used anywhere. The second part is a scenario using these rules.
When play begins:
say "Have you played interactive fiction before? >";
now novice mode is whether or not the player consents.
The rationale for asking the question this way, and not another, is that novices asked whether they would like instructions very often say no, even if they need them.
Novice mode is a truth state that varies. Novice mode is true.
Stopping novice mode is an action out of world.
Starting novice mode is an action out of world.
Understand "novice mode off" or "novice off" as stopping novice mode.
Understand "novice mode on" or "novice on" as starting novice mode.
Carry out stopping novice mode: now novice mode is false.
Carry out starting novice mode: now novice mode is true.
Report stopping novice mode: say "Novice mode is now off."
Report starting novice mode: say "Novice mode is now on."
Before reading a command when novice mode is true:
say "[line break]Some options to try:[line break]";
follow the novice suggestion rules.
A novice suggestion rule (this is the suggestion that he look rule):
if not looking and not going, say " [bold type]look[roman type]".
A novice suggestion rule (this is the suggestion that he check inventory rule):
if the player carries something and we are not taking inventory, say " [bold type]inventory[roman type] (I)".
A novice suggestion rule (this is the suggestion that he put things on rule):
if the player carries something and a free-standing supporter is relevant, say " [bold type]put[roman type] something [bold type]on[roman type] [the list of relevant supporters]".
A novice suggestion rule (this is the suggestion that he take things rule):
if a gettable thing is relevant, say " [bold type]take[roman type] [the list of gettable relevant things]".
A novice suggestion rule (this is the suggestion that he examine things rule):
if an unexamined thing is relevant, say " [bold type]examine[roman type] (X) [the list of unexamined relevant things]".
A novice suggestion rule (this is the suggestion that he enter things rule):
if a relevant thing is worth entering, say " [bold type]enter[roman type] [the list of worth entering relevant things], or [bold type]get out[roman type]".
A novice suggestion rule (this is the suggestion that he open things rule):
if an unlocked openable thing is relevant, say " [bold type]open[roman type] or [bold type]close[roman type] [the list of unlocked openable relevant things]".
A novice suggestion rule (this is the suggestion that he lock things rule):
if a closed lockable thing is relevant, say " [bold type]lock[roman type] or [bold type]unlock[roman type] [the list of closed lockable relevant things]".
A novice suggestion rule (this is the suggestion that he eat things rule):
if the player carries an edible relevant thing, say " [bold type]eat[roman type] [the list of edible relevant things carried by the player]".
A novice suggestion rule (this is the suggestion that he wear things rule):
if the player carries a wearable relevant thing, say " [bold type]wear[roman type] [the list of wearable relevant things carried by the player]".
A novice suggestion rule (this is the suggestion that he turn things on rule):
if a device is relevant, say " [bold type]turn on[roman type] or [bold type]turn off[roman type] [the list of relevant devices]".
A novice suggestion rule (this is the suggestion that he go places rule):
if a room is adjacent, say " [bold type]go[roman type][exit list][if in darkness] or try other directions in the dark[otherwise]".
A novice suggestion rule (this is the suggestion that he enter doors rule):
if an open door is relevant, say " [bold type]go through[roman type] [the list of relevant open doors]".
A novice suggestion rule (this is the suggestion that he interact with people rule):
if another person is relevant, say " [bold type]kiss[roman type] or [bold type]wake[roman type] [the list of relevant other people][if the player carries something], or [bold type]give[roman type] things [bold type]to[roman type] someone[end if]".
A novice suggestion rule (this is the suggestion that he ask for help rule):
say " [bold type]help[roman type] to see a more complete set of instructions".
A novice suggestion rule (this is the suggestion that he turn off help rule):
say " [bold type]novice mode off[roman type] to turn off this guidance".
The suggestion about asking for help is no good unless we provide some. This might take any of a number of forms, but for the sake of example we'll use an easy way out:
Include Basic Screen Effects by Emily Short. Include Menus by Emily Short. Include Basic Help Menu by Emily Short.
After taking inventory when novice mode is true: say "To get rid of any of these objects, [bold type]drop[roman type] it."
A thing can be examined or unexamined. Carry out examining something: now the noun is examined.
Definition: a thing is relevant if it is seen and it is visible. Before printing the name of something (called the target): now the target is seen; if novice mode is true, say "[bold type]". After printing the name of something: say "[roman type]".
Definition: a supporter is worth entering:
if the player carries it, no;
if it is enterable, yes.
Definition: a container is worth entering:
if the player carries it, no;
if it is enterable and it is open, yes.
Definition: a person is other if it is not the player. Definition: a person is another if it is other.
To say exit list:
let place be location;
let count be 0;
repeat with way running through directions:
let place be the room way from the location;
if place is a room:
increment count;
say "[if count is greater than 1] or[end if] [bold type][way][roman type]".
Definition: a thing is gettable:
if it is scenery, no;
if it is fixed in place, no;
if it is a person, no;
if the player is carrying it, no;
if the player is wearing it, no;
yes.
Antarctic Research Station is a room. "Though not always the most stimulating of environments, the station is far from your ex-wife and most of the things in the world that annoy you, namely the other 6+ billion people. There is a second room to the south." The station contains a radio. The radio is a device. It is fixed in place.
South of the Station is Sitting Room. The description of the Sitting Room is "Just big enough for a very [comfortable chair]." The Sitting Room contains an enterable supporter called a comfortable chair. The chair is scenery. A monograph about penguins is in the Sitting Room.
Blistering Cold is a room. "It is white out here and very very very cold." The white door is a door. "[The white door] leads to [the other side of the white door]." It is west of the Blistering Cold and east of the Antarctic Research Station.
Test me with "i / x radio / x door / s / i / x chair / x monograph / sit in chair / get up / n / open door / enter door".
ExampleIn Fire or in Flood |
Heat is a kind of value. The heats are whole, damp, and flaming. A thing has a heat. A thing is usually whole.
A thing has a number called endurance. The endurance of a thing is usually 5. A thing has a number called turns of burning. A thing can be flammable or flame-retardant.
Before printing the name of something flaming:
say "flaming ".
Before burning something when the player is not carrying something flaming:
if a flaming portable thing (called the lighter) is touchable:
say "(with [the lighter], which you first take)[command clarification break]";
try taking the lighter.
Instead of burning something when the player is not carrying something flaming:
say "You would first need a fire source."
Instead of burning something flame-retardant:
say "[The noun] is not the sort of thing that catches fire."
Instead of burning something flammable when the player is carrying something flaming (called the flame source):
say "You light [the noun] with [the flame source].";
now the heat of the noun is flaming.
Instead of burning something when the player is in the noun:
say "That seems dangerous given that you yourself are in [the noun]."
Instead of burning something when the player is on the noun:
say "That seems dangerous given that you yourself are on [the noun]."
Instead of examining something:
say "Hm, the [printed name] appears to be [heat]."
Before taking a flaming thing:
let turns remaining be the endurance of the noun minus the turns of burning of the noun;
if turns remaining is less than two, say "There's no portion of [the noun] sufficiently cool for you to pick up." instead.
But that's only a small part of the battle. The thing about fire is that it keeps on doing fiery things even when the player is otherwise occupied: destroying items that are on fire, and spreading to other things nearby. So we need a set of rules for the fire's behavior.
Every turn when something is flaming:
follow the fire rules.
A fire rule (this is the can't hold flaming objects rule):
repeat with item running through flaming things:
if the item is held by the player:
let turns remaining be the endurance of the item minus the turns of burning of the item;
if turns remaining is less than two:
say "[The item] becomes too hot to hold! ";
try dropping the item;
if the item is held by the player, say "This is certainly painful."
A fire rule (this is the flames spread rule):
repeat with item running through flaming things:
if the turns of burning of the item is one:
spread the flames from the item.
A fire rule (this is the fire destroys things rule):
now started printing is false;
repeat with item running through flaming things:
increment the turns of burning of the item;
if the turns of burning of the item is greater than the endurance of the item, destroy the item;
if started printing is true, say "[paragraph break]";
now started printing is false.
Because we've labelled all the fire rules, we could swap their order, or turn some of them off, while allowing the others run as usual. For instance, if there were a pair of fireproof gloves in the game, we might want to turn off the "can't hold flaming objects rule" whenever the player is wearing them.
This sort of flexibility is especially useful in the context of extensions. Someone writing an extension about burning would have no way of anticipating the need for a Fireproof Gauntlet of Thog, but the author would nonetheless be able to implement one easily.
Definition: a thing is vulnerable if it is flammable and it is whole.
The contact between things is a critical factor when it comes to fire, so we might add a couple of conditional relations do determine what is touching what.
Reliance relates a thing (called X) to a thing (called Y) when X is part of Y or X is in Y or X is on Y. The verb to be relying on means the reliance relation.
Contact relates a thing (called X) to a thing (called Y) when X is relying on Y or Y is relying on X. The verb to be joined to means the contact relation.
Having these at our disposal makes it much tidier to write what happens next:
To spread the flames from (item - a thing):
now started printing is false;
if the item is joined to a flammable whole thing (called the sacrifice):
if the sacrifice is visible:
now started printing is true;
say "Flames engulf [the list of flammable whole things which are joined to the item].";
now all the flammable whole things joined to the item are flaming.
Started printing is a truth state that varies. Started printing is false.
To destroy (item - a thing):
let home be the holder of the item;
if the item is part of something (called the superstructure), let home be the holder of the superstructure;
if the item is visible:
now started printing is true;
say "[The item] burns away[if something is relying on the item], leaving [a list of things which are relying on the item] behind[end if]. ";
if something is relying on the item,
now all the things which are relying on the item are in the home;
now the item is nowhere;
now the item is damp;
now every flaming thing which is part of the item is damp.
To destroy (item - a door):
let home be the holder of the item;
if item is visible:
now started printing is true;
say "[The item] burns away[if something flame-retardant is part of the item], leaving [a list of flame-retardant parts of the item] behind[end if]. ";
if home is a room, now all of the flame-retardant parts of the item are in the home;
now the item is damp;
now the item is open;
now the item is unopenable.
Before printing the name of a damp door:
say "burnt-out frame of ".
Instead of opening or closing a damp door:
say "[The noun] can no longer be opened or closed in any meaningful sense."
Instead of doing something other than examining or dropping to a flaming thing when the turns of burning of the noun is greater than 1:
say "Fire has too thoroughly engulfed [the noun] for that to be a good idea."
Instead of taking something when the noun is in a flaming thing (called the receptacle):
say "You don't quite dare reach into [the receptacle]."
Instead of touching something which is within a flaming thing (called the receptacle):
say "It seems a little risky since [the receptacle] is on fire."
Instead of turning something when the noun is contained in a flaming thing (called the receptacle):
say "It seems a little risky since [the receptacle] is on fire."
Instead of pushing or pulling something when the noun is inside a flaming thing (called the receptacle):
say "[The receptacle] deters you."
Before burning something which is in a container when the holder of the noun contains the player:
say "This could make things toasty for you..."
And that completes the rules which cover burning: things can catch fire, fire will spread, and gradually consume the world in flames. All of that was general and could be used in any setting, but we now provide a small game to show it off.
The Library of the Dead is a room. "This room -- little, dank, stone -- is filling with some miasma you do not quite dare breathe. It is imperative that you get out."
The desk is a flammable supporter in the Library. A drawer is part of the desk. The drawer is a flammable closed container. It is openable, lockable, and locked. The desk is scenery.
A box is in the Library. A metal hinge is part of the box. The hinge is flame-retardant. The box is open, flammable, and openable. The shroud of Laertes is a flammable thing in the box.
Instead of examining something when something is part of the noun:
say "You note [the list of things which are part of the noun]."
The world's last manuscript of the Psychagogoi by Aeschylus is on the desk. The manuscript is flammable. The manuscript has endurance 1.
The torch is a flammable flaming thing carried by the player. It has endurance 60. The asbestos sack is a flame-retardant player's holdall in the drawer.
The trapdoor is up of the Library and east of the Plaza. The trapdoor is a door. It is flammable, closed, lockable, and locked. "A trapdoor in the ceiling is your only hope of escape[if flaming]. Fortunately, it is rapidly burning through[end if]." The trapdoor has endurance 15.
Instead of going through the closed trapdoor, say "[The trapdoor] is closed."
We can then add a special fire rule to handle the trapdoor, which will be called as part of the same sequence. Again, this would be most important if the fire rules were part of a standard extension, and the trapdoor fire rule the author's own addition.
A fire rule:
if the trapdoor is flaming and a random chance of 1 in 3 succeeds:
let the caught thing be a random flammable whole thing which can be touched by the trapdoor;
if the caught thing is a thing:
say "A spark from [the trapdoor] catches [the caught thing]!";
now the caught thing is flaming.
Instead of going to the Plaza:
say "Out at last!";
end the story finally.
Test me with "get manuscript / get shroud / light desk / look / g / open drawer / look / g / g / g / get sack / put shroud in sack / put manuscript in sack / close sack / light trapdoor / look / g / g / g / g / g / g / g / g / g / g / g / g / g / g / up".
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: