RB §5.1. The Human Body

By default, Inform gives the player character (and every other person) a simple unitary body, one without hands or feet or any other defined parts. In many games this is adequate; but in others it is not enough, and we may want to endow all people with some more specific physical features, as in

A face is a kind of thing. A face is part of every person.

Once we've done this, we may invite ambiguities if the player types LOOK AT FACE; it is this challenge that is addressed in The Night Before ★★★.

rBGH gives the player a random height and then uses this to determine how the room should be described around him.

Slouching ★★ lets the player (and other characters as well) take different sitting, standing, and lying down positions.

Examples

254. rBGH

As with ordinary numbers, we can choose random units when this is useful:

paste.png "rBGH"

The Pharmaceutical Testing Facility is a room. "A [if the player is short]large [end if][if the player is tall]cramped [end if]white space with sterile counters and a[if the player is tall]n uncomfortable little[end if] stool. There is also a mirror, behind which someone must be watching you. But you can't see through to that."

A counter, a one-way mirror, and a stool are scenery in the Facility. The stool is an enterable supporter. The counter supports a plate.

Height is a kind of value. 5 feet 11 inches specifies a height. 5'11 specifies a height. A person has a height.

Definition: a person is tall if its height is 6 feet 0 inches or more.

Definition: a person is short if its height is 5 feet 4 inches or less.

When play begins:
    now the height of the player is a random height between 5 feet 2 inches and 6 feet 4 inches;
    now the right hand status line is "[height of player]".

Instead of examining the player:
    say "You, Test Subject, are [height of the player] tall."

The growth pill is a kind of thing. A growth pill is always edible. The description is usually "It is leaf-green and has a reassuring logo of a curling vine on the side. Nothing to worry about, nothing at all." Two growth pills are on the plate.

After eating the growth pill:
    increase the height of the player by 0 feet 6 inches;
    say "Your spine does something frightening and painful, and you find yourself looking down on the room from a wholly new angle.";
    try looking.

Test me with "examine me / eat pill / examine me / eat pill / examine me".

397. Slouching ★★

Suppose we want to let the player explicitly sit, stand, or lie down on different enterable objects. (Normally Inform treats all these actions as entering, but there may be cases where we want to distinguish between the player sitting on a chair and the player standing on it.)

Our implementation gives each kind of enterable a range of allowed postures, and one preferred posture. If the player enters the supporter or container without specifying a posture (as in ENTER CHAIR), he will be put in the preferred posture. If he explicitly says, e.g., STAND ON CHAIR, he will be put in the standing position as long as standing is a posture that suits the chair.

paste.png "Slouching"

Section 1 - Posture Rules

A posture is a kind of value. The postures are seated, standing, and reclining.

A person has a posture. The posture of a person is usually standing.

A supporter has a posture. A container has a posture.

Posture-permission relates various things to various postures. The verb to allow means the posture-permission relation.

Understand the commands "stand" and "sit" and "lie" as something new.

Understand "sit on/in [something]" as sitting on.
Understand "lie on/in [something]" as lying on.
Understand "stand on/in [something]" as standing up on.

Sitting on is an action applying to one thing.
Lying on is an action applying to one thing.
Standing up on is an action applying to one thing.

Carry out an actor sitting on:
    if the holder of the actor is not the noun, silently try the actor entering the noun;
    if the holder of the actor is the noun:
        if the actor is not seated, try the actor taking position seated;
        otherwise follow the report taking position rules.

Carry out an actor lying on:
    if the holder of the actor is not the noun, silently try the actor entering the noun;
    if the holder of the actor is the noun:
        if the actor is not reclining, try the actor taking position reclining;
        otherwise follow the report taking position rules.

Carry out an actor standing up on:
    if the holder of the actor is not the noun, silently try the actor entering the noun;
    if the holder of the actor is the noun:
        if the actor is not standing, try the actor taking position standing;
        otherwise follow the report taking position rules.

Understand "lie down" as lying down.
Understand "sit down" or "sit" or "sit up" as sitting down.
Understand "stand" or "stand up" as standing up.

Lying down is an action applying to nothing.
Sitting down is an action applying to nothing.
Standing up is an action applying to nothing.

Taking position is an action applying to one posture.

Instead of an actor lying down:
    try the actor taking position reclining; rule succeeds.
Instead of an actor sitting down:
    try the actor taking position seated; rule succeeds.
Instead of an actor standing up:
    try the actor taking position standing; rule succeeds.

Check an actor taking position:
    if the holder of the actor is not a room and the holder of the actor does not allow the posture understood:
        if the actor is the player:
            say "You can't take that position [in-on the holder of the actor].";
        otherwise if the actor is visible:
            say "[The actor] can't take that position.";
        stop the action.

Check an actor taking position:
    if the posture understood is the posture of the actor:
        if the actor is the player:
            say "You are already [the posture understood].";
        otherwise:
            if the actor is visible, say "[The actor] is already [the posture understood].";
        stop the action.

Carry out an actor taking position:
    now the posture of the actor is the posture understood.

Report someone taking position (this is the position-report rule):
    say "[The actor] is now [the posture of the actor][if the holder of the actor is not the location of the actor] [in-on the holder of the actor][end if]."

Report taking position:
    say "You are now [the posture of the player][if the holder of the player is not the location] [in-on the holder of the player][end if]."

To say in-on (item - a thing):
    if the item is a container, say "in [the item]";
    otherwise say "on [the item]".

Carry out an actor exiting (this is the departure-posture rule):
    let N be the holder of the actor;
    if N is a container or N is a supporter,
        now the posture of the actor is the posture of N;
    otherwise now the posture of the actor is standing.

The departure-posture rule is listed after the standard exiting rule in the carry out exiting rulebook.
The departure-posture rule is listed after the standard getting off rule in the carry out getting off rulebook.

Carry out an actor entering something (this is the arrival-posture rule):
    if the noun is a container or the noun is a supporter,
        now the posture of the actor is the posture of the noun.

The arrival-posture rule is listed after the standard entering rule in the carry out entering rulebook.

Check an actor going somewhere:
    if the actor is in a room and the actor is not standing:
        say "([if the actor is not the player][the actor] [end if]first standing up)[command clarification break]";
        silently try the actor taking position standing;
        if the actor is not standing, stop the action.

Section 2 - Some Generic Kinds

A chair is a kind of supporter. A chair is always enterable. Every chair allows seated and standing. A chair is usually seated.
A sofa is a kind of supporter. A sofa is always enterable. Every sofa allows seated, standing and reclining. A sofa is usually seated.
A hammock is a kind of container. A hammock is always enterable. Every hammock allows seated and reclining. A hammock is usually reclining.

Section 3 - The Scenario

The Resort is a room.

The banana hammock is a hammock in the Resort. The stone bench is a sofa in the resort.

Clark is a man in the Resort. A persuasion rule: persuasion succeeds.

Rule for writing a paragraph about someone (called target):
    say "[The target] is [posture] [if the holder of the target is the location]nearby[otherwise][in-on the holder of the target][end if]."

Rule for writing a paragraph about something which encloses an unmentioned person (called target):
    carry out the writing a paragraph about activity with the target instead.

Test me with "sit on bench / stand on bench / get up / lie on hammock / sit up / g / clark, sit on bench / look / clark, lie down / g / look / clark, get up / look / clark, lie down / look / enter bench".

59. The Night Before ★★★

Suppose that we're going to give every person in the game a nose, but we want references to a nose always to mean the nose of someone *else*, if the player is with one other person. Moreover, on some occasions we're going to be in sight of Rudolph, so actions directed at an unspecified nose should always prefer his.

This relies on a somewhat advanced technique from the Understanding chapter, but since it may become useful with assemblies and body parts, it is worth mentioning here.

paste.png "The Night Before"

The North Pole is a room. "Here it is: the famous Pole. From here you can go south (or south-south, or south-south-by-south); or, alternatively, take refuge inside a red-and-white-striped cabin." The cabin is scenery in the North Pole. Instead of entering the cabin, try going inside.

Santa is a man in the North Pole. "Santa is pacing around in the snow and trying to psych himself up for the big night."

Inside from North Pole is the Candy Cane Cabin. The description of the Cabin is "Striped red and white, but nothing can make this place seem warm and inviting since Mrs. Santa ran off with the Tooth Fairy."

The Ice Shelf is south of North Pole. "The ice here has been smoothed into a kind of runway for easy take-off, and ends in a cliff and cold arctic sea." Donner, Vixen, Blixen, and Rudolph are animals in the Ice Shelf.

A nose is a kind of thing. A nose is part of every person. The description of Santa's nose is "It's a bit ruddy. You don't like to mention it, but Santa's been dipping heavily into the Grey Goose since Mrs. Santa left town." The description of a nose is usually "Not terribly exciting." The description of Rudolph's nose is "See how it glows!"

Next, we'll teach Inform some vocabulary to distinguish between the player and everyone else:

Definition: a person is other if it is not the player.

Definition: a thing is selfish if it is part of the player and the player can see an other person.

Instead of examining a selfish nose:
    say "You cross your eyes, but can't get a good look."

Here is the part that actually determines the preferences. "Does the player mean..." can result in five outcomes: "it is very unlikely", "it is unlikely", "it is possible" (the neutral default), "it is likely", and "it is very likely". This is discussed in greater detail in the Understanding chapter. Here, we want to discourage references to the player's own nose and encourage references to the nose of Rudolph, so:

Does the player mean doing something when the noun is a selfish nose or the second noun is a selfish nose: it is very unlikely.

Does the player mean doing something to Rudolph's nose: it is very likely.

And this part is just for decoration:

Rule for writing a paragraph about Rudolph:
    say "The reindeer are already harnessed and waiting impatiently. The brilliance of [Rudolph]'s nose casts an eerie red glow over [the list of unmentioned animals in the location]."

Test me with "x nose / x my nose / x santa's nose / in / x nose / out / s / x my nose / x nose / x rudolph's nose / x donner's nose".

RB §5.2. Traits Determined By the Player

Some IF tries to make the viewpoint character more congenial to the player by allowing some customization.

Identity Theft demonstrates asking the player to supply the viewpoint character's name.

Pink or Blue ★★★ demonstrates a way to let the player choose a gender at the start of play: this will mostly be interesting if the rest of the story makes some use of the player's choice. Since that example is written expressly to demonstrate included Inform 6 code, however, we may find it more congenial to generalize from the more flexible Baritone, Bass ★★★.

This is not the only way to go - as we'll see in the next section, there's also something to be said for making the viewpoint character a strongly distinct creature with well-defined preferences and attitudes.

Examples

417. Identity Theft

Let's say we want to allow the player to enter any name he likes for his character. Moreover, we want to reject very long names (which are likely to be mistakes anyway), and we want to extract the player's chosen first name from the rest.

paste.png "Identity Theft"

The player's forename is a text that varies. The player's full name is a text that varies.

When play begins:
    now the command prompt is "What is your name? > ".

To decide whether collecting names:
    if the command prompt is "What is your name? > ", yes;
    no.

After reading a command when collecting names:
    if the number of words in the player's command is greater than 5:
        say "[paragraph break]Who are you, a member of the British royal family? No one has that many names. Let's try this again.";
        reject the player's command;
    now the player's full name is the player's command;
    now the player's forename is word number 1 in the player's command;
    now the command prompt is ">";
    say "Hi, [player's forename]![paragraph break]";
    say "[banner text]";
    move the player to the location;
    reject the player's command.

We also want to postpone the proper beginning of the game until we've gotten the name:

Instead of looking when collecting names: do nothing.

Rule for printing the banner text when collecting names: do nothing.

Rule for constructing the status line when collecting names: do nothing.

Your Bedroom is a room. The printed name of Your Bedroom is "[player's forename]'s Bedroom".

The player carries a letter. The description of the letter is "Dear [player's full name], [paragraph break]You have won the Norwegian Daily Lottery! ...".

If we are compiling for Glulx, this is enough to capture not only the player's name but also the capitalization he uses.

If we are compiling for the Z-machine, the player's input will unfortunately be reduced to lower case before we can inspect it. If we would like by default to capitalize the first letter of each word of the name, we might substitute the following after reading a command rule:

paste.png After reading a command when collecting names:
    if the number of words in the player's command is greater than 5:
        say "[paragraph break]Who are you, a member of the British royal family? No one has that many names. Let's try this again.";
        reject the player's command;
    now the player's full name is the substituted form of "[the player's command in title case]";
    now the player's forename is word number 1 in the player's full name;
    now the command prompt is ">";
    say "Hi, [player's forename]![paragraph break]";
    say "[banner text]";
    move the player to the location;
    reject the player's command.

309. Baritone, Bass ★★★

The "reading a command" activity is rather advanced; for the moment, what we need to understand is that we're intervening in commands at the start of play and insisting that the player's first instruction to the game consist of a choice of gender. After that point, the gender will be set and play will proceed as normal.

In order to do the parsing, we define gender as a kind of value, and give several alternate names to each gender.

paste.png "Baritone, Bass"

Getting Started is a room.

Gender is a kind of value. The genders are masculine, feminine, and unknown. Understand "male" or "man" or "M" as masculine. Understand "female" or "woman" or "F" as feminine.

A person has a gender. The gender of the player is unknown.

When play begins:
    now the command prompt is "Please choose a gender for your character. >".

After reading a command when the gender of the player is unknown:
    if the player's command includes "[gender]":
        now the gender of the player is the gender understood;
        if the gender of the player is unknown:
            say "This story requires a selection of male or female. [run paragraph on]";
            reject the player's command;
        if the gender of the player is masculine, now the player is male;
        if the gender of the player is feminine, now the player is female;
        say "[line break]Thank you. We now begin...";
        now the command prompt is ">";
        move the player to Sandy Beach;
        reject the player's command;
    otherwise:
        say "Sorry, we're not ready to go on yet. [run paragraph on]";
        reject the player's command.

Sandy Beach is a room.

Instead of examining the player when the player is female:
    say "Congratulations, you are a girl!"

Instead of examining the player when the player is male:
    say "Congratulations, you are a boy!"

If we had a whole series of things to ask the player about, we might define a whole series of kinds of value

The vocal ranges are soprano, mezzosoprano, contralto...

and use a "construction stage" variable to keep track of the current stage of character-construction, as in

After reading a command when the current construction stage is choosing a vocal range:
    ...

451. Pink or Blue ★★★

Suppose we would like to allow the player to choose a gender for the main character. We'd also like this to happen at the beginning of the game and outside the main parsing sequence. "When play begins" seems like a good place to put this.

paste.png "Pink or Blue"

When play begins:
    say "Should your character be male or female? >";
    if men win, now the player is male;
    otherwise now the player is female;
    say paragraph break.

Now a piece of Inform 6 code handles the unusual input. It's not necessary to understand this to use it, and the code should work for any question you'd like to ask the player. The first three words in quotation marks ('male', 'M', 'man'...) correspond to positive feedback; the later three words correspond to negative feedback. So "to decide whether men win" will be true if the player types one of the first three, and false if he types one of the last three.

To decide whether men win:
    (- Question('male','M//','man','female','F//','woman') -)

Include (-

[ Question pos1 pos2 pos3 neg1 neg2 neg3 first_word_typed;
    while (true) {
        VM_ReadKeyboard(buffer, parse);
        wn = 1; first_word_typed = NextWordStopped();
        if (first_word_typed == pos1 or pos2 or pos3) rtrue;
        if (first_word_typed == neg1 or neg2 or neg3) rfalse;
        print "Please choose ", (address) pos1, " or ", (address) neg1, ". > ";
    }
];

-)

Instead of examining the player when the player is female:
    say "Congratulations, you are a girl!"

Instead of examining the player when the player is male:
    say "Congratulations, you are a boy!"

The Room of Self-Knowledge is a room. "Mirrors cover every available wall-surface of this hexagonal chamber, allowing you to examine yourself from all angles."

RB §5.3. Characterization

Much of the personality of the player character in IF emerges from what he can and cannot (or will and will not) do; part of the pleasure of playing a character arises from this opportunity for role-playing and role-exploration. Some characters are consciousless daredevils, willing to jump off cliffs, crawl through narrow gaps, and rob widows if the player commands it; others are repressed neurotics who barely dare to speak to other characters or touch anything that doesn't belong to them.

Finishing School and Dearth and the Maiden both treat the case of a character constrained by good manners and a sense of polite society: the former forbids only one action, while the latter condemns a whole range of them.

Constraining the character is only the half of it: we might also want to think about what sorts of unusual actions that character might be especially likely to take, and account for these. Of course, major actions that affect the story world will require some thought and implementation work, and we should consider carefully before making the player a character like, say, the Noble of Glamour, a spirit in human form who can charm all comers, transform bespectacled secretaries into divas, and cause spontaneous cloudbursts of scarlet glitter.

But even simple humans have some characteristic traits and gestures. We will probably want to write some characteristic reaction to EXAMINE ME, as demonstrated in Bad Hair Day. We might provide a few pieces of clothing or props that aren't strictly critical in the story, like a policeman's helmet or a feather boa:

The player is wearing a policeman's helmet.

We can liven up the interactive aspect of characterization if we give the player a little scope for role-playing: this may mean responding to gestures, like

Understand "bite nails" as a mistake ("Your only nail remaining is the one on your left thumb, and you're saving it for the AP Calculus exam.").

(Of course, we would need to have hinted to the player that nail-biting is characteristic of his character.)

See also

Clothing for more on dressing characters up
Saying Complicated Things for conversation, another area in which the player character's personality might come into play

Examples

73. Finishing School

It is often useful to write action rules which apply only when the player is observed by a third party. "In the presence of a person", however, will react even if only the player is in the room, because the player is, of course, a person as well.

A convenient way around this problem is to define an "other" adjective:

paste.png "Finishing School"

The apple is an edible thing carried by the player.

The Hall is a room. Miss Wicket is a woman in the Hall.

The Dormitory is south of the Hall.

Definition: a person is another if it is not the player.

Instead of eating something in the presence of another person:
    say "Your mannerly upbringing prevents you from eating without a fork or knife in front of someone."

Test me with "eat apple / south / eat apple".

If we did not have "another" here, Inform would interpret even the player as a possible schoolmarm, leading to such lines as "yourself stares at you coldly...". Clearly not quite the thing.

85. Bad Hair Day

paste.png "Bad Hair Day"

The Foyer is a room. "A mirror hangs over the table, tempting you to check your appearance before going in with all the others."

Instead of examining the player:
    say "Oh, stop fussing. You look fine."

Test me with "examine me".

109. Dearth and the Maiden

The following example, indebted to the late Georgette Heyer, is suggestive:

paste.png "Dearth and the Maiden"

The Chequers Inn is a room. "The room is panelled and ceilinged in oak, with blue curtains to the windows and blue cushions on the high-backed settle by the fire."

An oil painting is in the Inn. "An oil painting hangs upon one wall, a lascivious work from the Indies in which a very bendy, sloe-eyed courtesan - but no."

A man called Mr Carr is in the Inn. "Standing bashfully aside is one Mr Carr, who we have been led to understand is by profession a Highwayman (yet whose visage oddly recalls Lord John Carstares, disgraced eldest son of the Earl of Wyncham)."

Kissing Mr Carr is unmaidenly behaviour. Doing something to the painting is unmaidenly behaviour.

Instead of unmaidenly behaviour in the Inn, say "How unmaidenly! Why, one might just as wantonly strip a rose of its petals, letting each fragrant leaf flutter slowly to the ground."

Test me with "examine painting / take painting / kiss mr carr".

RB §5.4. Background

In IF, as in all interactive storytelling, an essential problem is that the player does not begin the story knowing everything that the player character should, and so may implausibly bumble through situations that the player character should be quite comfortable in. If the player character has friends, an unusual job, a home or environment we're not familiar with, a secret past, these will all be a blank to the player.

Some games get around this by making the player character an amnesiac, or positioning him as a newcomer to a strange world in which his disorientation is explicable; but there are stories that cannot be told this way, and so we need other methods of getting the player to know what the player character already does.

Our first opportunity to inform the player about the player character is in the opening text of a story:

When play begins:
    say "The funeral is exactly a month ago now, but Elise's shoes are still on the shoe tree."

We may also want to write descriptions of objects to give extra background information the first time the player encounters them:

A thing can be examined or unexamined. A thing is usually unexamined. After examining something: now the noun is examined; continue the action.

The description of the newspaper is "A rolled-up newspaper[if unexamined], and thus a symbol of your newly-single state: Elise always had it open and the Local Metro section next to your plate by the time you got out of the shower[end if]."

To expand on this, we could give the player a THINK ABOUT or REMEMBER command, with which he can call up information about people he meets or references he encounters in descriptions, so that he could (for instance) next type REMEMBER ELISE. Merlin demonstrates one way to implement a character with memory; One of Those Mornings puts a twist on this by letting the player FIND things which he knows his character possessed at some time before the story started.

Examples

277. Merlin

paste.png "Merlin"

Understand "remember [text]" as remembering.

Remembering is an action applying to one topic.

Carry out remembering:
    say "Nothing comes to mind.".

Instead of remembering a topic listed in the Table of Recollections:
    say "[response entry][paragraph break]".

Table of Recollections

Topic

Response

"rain/weather"

"You've seen worse, but not often: it's falling so hard now that the tin rattles and the runoff, on the low side of the roof, would be a tenable source of hydroelectric power."

"hydroelectric power" or "power/hydroelectric"

"It's not as though you have any sort of light bulb in here to turn on, even if you could power it."

"light bulb" or "light/bulb"

"Light bulbs, like so much else, are a thing of your past. Or is it your future? Tricky, the way the world loops round on itself."

"past/time/future"

"Living backwards has its drawbacks. A tendency to confuse and annoy your friends, being one; the total inability to maintain a stable relationship; and a deep dissatisfaction with most of the bodily processes people enjoy, since they ultimately make you hungrier, colder, or-- no point dwelling on it, really."

"backwards"

"It's not even exactly *backwards*, now is it? It's more like a series of forwardses stuck back to back. As though someone had taken each track of a CD and put them in the exactly wrong order. You miss that. The music on demand."

The Inadequate Shelter is a room. "A piece of corrugated tin, leaned on two sticks, and pathetically augmented with a tire (on one side) and a cardboard box (on the side towards the wind). And that's what you've got between you and the driving rain.

At the moment rain is all you can remember, in fact."

Test me with "remember rain / remember power / remember light bulb / remember future / remember backwards".

301. One of Those Mornings

Suppose that, contrary to the usual rules of interactive fiction, we want to allow the player to discover the locations of things he hasn't actually seen yet:

paste.png "One of Those Mornings"

Understand "find [any thing]" as finding.

Finding is an action applying to one visible thing.

Carry out finding:
    if the player is carrying the noun:
        say "You're holding [the noun]!";
    otherwise:
        say "You left [the noun] [if the noun is on a supporter]on[otherwise]in[end if] [the holder of the noun]."

The holder of the noun can be a room, a supporter, or a container: the phrase is not picky. We would want to be a little more careful if it were ever possible for an item to have been "removed from play" in our game, since then the holder could be nothing, and that would have odd results. In this particular example, though, that will not arise.

And that's it, as far as the find command goes. The rest is local color.

The Exhibition Room is a room. It contains a closed locked lockable transparent openable container called the display case. The display case contains a priceless pearl. The display case is scenery. The description of the Exhibition Room is "By far the finest thing in the room is a priceless pearl in a glass display case. It should of course be yours[if key is not visible], if only you can remember where you hid the key[end if]."

The silver key unlocks the display case.

A jade vase, a teak chest, a bronze teakettle, and a child's burial casket are openable closed containers in the Exhibition Room.

After taking the pearl:
    say "The pearl rolls into your hand, gleaming in the oblique light; your fortune is made.";
    end the story finally.

If we want to have the key found in different places when the game is replayed:

When play begins:
    let the space be a random container which is not the display case;
    move the silver key to the space.

Every turn:
    say "Your watch ticks with maddening loudness."

The time of day is 1:02 AM.

At 1:08 AM: say "The security guard arrives to find you fumbling about with keys. Curses."; end the story.

Test me with "find pearl / find teakettle / get teakettle / find teakettle / find key".

RB §5.5. Memory and Knowledge

All of us carry around in our heads an (incomplete, imperfect) model of the world around us: an idea of where we left the keys, whether the oven is on or off, how many clean pairs of socks are left in the drawer, what we look like in our best pair of jeans. The differences between that mental model and reality are to some degree a reflection of personal character: our forgetfulness, our wishful thinking, our innocence or cynicism.

By default, Inform does not keep track of the player character's knowledge (or any other character's knowledge, for that matter) as a separate thing from the model world, relying on descriptive prose rather than modeling to introduce these quirks of characterization.

All the same, there are often times when we would like to keep track of discrepancies between the world model and the narrator's mental model. Perhaps the most common way to do this is simply to mark everything that the player encounters as "seen" when the player first examines it, thus:

A thing can be seen or unseen.

Carry out examining a thing:
    now the noun is seen.

or -- to have things remembered from the first moment they're mentioned in a room description:

Rule for printing the name of something (called the target):
    now the target is seen.

The mental model need not always be accurate, of course. We might, for instance, have occasion to keep track of where the player character last saw something, even if the object has since been moved; or keep track of falsehoods the player character has been told in conversation; or make the player refer to a character as "the bearded man" until he is properly introduced.

Included with Inform is the extension Epistemology, by Eric Eve, which provides one way of tracking this kind of information. Epistemology distinguishes between items that the player character has seen, because they're objects in a room the player has been to, and items that are familiar to the player for other reasons, such as a quest item he knows about but hasn't found yet, or an abstract conversation topic. Anything that is either seen or familiar is counted as "known".

Modeling what the player does and does not know is only half the job, of course: we also need that information to affect the behavior of the story in plausible ways.

One obvious occasion to use player character knowledge is in the output of descriptions. We might want to respond to actions differently depending on what the player has previously done, as in Tense Boxing, or change the way we describe objects in light of new knowledge about them, as in Zero ★★★. Casino Banale ★★★ takes that idea much further, with a whole system of facts that can be narrated to the player in a somewhat flexible but interdependent order, as the player looks at relevant objects or notices them in room descriptions.

Along similar lines, we may want an object to change its name for the player depending on what the player knows. That name change should affect both what Inform displays and what it understands about the object. For instance:

An Amherz Amulet is a thing. It can be known or unknown. It is privately-named.

The printed name is "[if known]Amherz Amulet[otherwise]lizard-shaped pewter charm[end if]".

The description is "[if known]It's a unique and magically powerful pewter charm shaped like a lizard[otherwise]It's some cheap tacky pewter charm shaped like a lizard. At least, as far as you can tell -- it's pretty grubby[end if]."

Understand "amherz" or "amulet" as the Amulet when the Amulet is known.

Understand "lizard" or "lizard-shaped" or "pewter" or "charm" as the Amulet when the Amulet is unknown.

Instead of rubbing the amulet when the amulet is unknown:
     say "You rub off a bit of the dirt, and... what do you know? It's actually the priceless and fabulously powerful Amherz Amulet!";
     now the Amherz Amulet is known.

Finally, the player's knowledge may affect how the story interprets commands, in the determining what is called "scope". When Inform tries to make sense of something the player has typed, it makes a list of everything that the player is allowed to refer to at the moment, and then checks whether all of the objects in the player's command refer to items in that list. Only things that are "in scope" are open for discussion.

If the player mentions an object that is not "in scope" -- say, a red hat left behind in the next room -- Inform will issue the response "You can't see any such thing." This is also Inform's reply if the player mentions a nonsense object ("EXAMINE FURSZWIGGLE") or an object that does not exist in the story world at all ("EXAMINE CELL PHONE" in a story set in Carolingian France).

This is not the only possible way for interactive fiction to handle such communication. Some games will respond differently to EXAMINE RED HAT and EXAMINE FURSZWIGGLE, saying in the first case something like "You can't see that now" and in the second "I don't know the word 'furszwiggle'."

The drawback of such behavior is that the player can make premature discoveries. If he hasn't found a sword yet, but thinks there may be a sword later in the story, he can type EXAMINE SWORD and see from the response whether his guess is correct. Nonetheless, there are people who prefer this alternative exactly because it does expose the limits of the story's understanding, preventing fruitless attempts to use a word that is not recognized at all. If it is desirable, there is an extension that will reproduce this behavior in Inform as well.

Using Inform's default behavior, however, scope is an ad-hoc way of keeping a list of things that are common knowledge between the story and the player. The player knows many things that the story might not (like what a cell phone is); the story knows a few things the player may not (like the fact that there is a sword in an as-yet unvisited room). Neither of those things can fruitfully enter into commands because they have no mutually agreed-upon referent.

By default, Inform assumes that "scope" includes only those things that are currently visible by line of sight. This works pretty well for a wide range of situations, but there are still plenty of occasions when we want to admit that the story and the player share a knowledge of things not seen. GO TO THE KITCHEN might be a useful command even when the player can't currently view the kitchen. ASK FRED ABOUT THE FOOTPRINTS should perhaps work even when the footprints are far away in the garden. SMELL STINKY CHEESE might need to work even when the cheese is invisibly locked away in a porous container but is exuding a stench. In a dark room, the player can't see his own inventory, but he should still remember that he's carrying it and be able to mention it. And sometimes we might want the story to acknowledge that the player is referring to an object that he has seen somewhere, even if that thing is now out of sight.

In practice, we have two ways to tinker with scope: we can change the scope for a specific command, using a token with any, as in

Understand "go to [any room]" as approaching.
Understand "find [any thing]" as finding.
Understand "ask [someone] about [any known thing]" as interrogating it about.

Or we can add areas and items to scope for all commands, as in

After deciding the scope of the player when the surveillance camera is switched on:
    place the jail cell in scope.

Puncak Jaya demonstrates understanding references to characters who are currently off-stage.

See also

Helping and Hinting for objects tagged with a "seen" property when the player first encounters them
Getting Acquainted for a character whose name is changed during the course of play as the player gets to know him better
Room Descriptions for more ways to change the description of a room depending on player experience
Going, Pushing Things in Directions for ways to understand the names of distant rooms and move towards them
Character Knowledge and Reasoning for models of knowledge for other characters than the player
Sounds for ways of tracking audible objects separately from visible ones
Lighting for ways to change what the player knows about and can manipulate in dark rooms
Clocks and Scientific Instruments for a telescope that lets the player view objects in another location
Continuous Spaces and The Outdoors for more on seeing into adjacent locations

Examples

149. Tense Boxing

Here we have a box that prints out its current state and its history each time we open and close it:

paste.png "Tense Boxing"

The Temporal Prism is a room. "A room of angled mirrors, in whose surfaces you can see what is now; what just was; what has always been. A final mirror is broken and its frame gapes blackly."

The mysterious box is in the Temporal Prism. It is an openable closed container.

To assess the box:
    if the box was not open, say "The box was not open.";
    if the box was open, say "The box was open.";
    if the box had not been open, say "The box had not been open.";
    if the box had been open, say "The box had been open.";
    if the box is not open, say "The box is not open.";
    if the box is open, say "The box is open.";
    if the box has not been open, say "The box has not been open.";
    if the box has been open, say "The box has been open."

Before opening the mysterious box:
    say "You are about to open the box.";
    assess the box.

Before closing the mysterious box:
    say "You are about to close the box.";
    assess the box.

After opening the mysterious box:
    say "You now open the box.";
    assess the box.

After closing the mysterious box:
    say "You now close the box.";
    assess the box.

Note that "was..." and "was not..." and so on may describe conditions more complicated than simple properties: we could equally well ask "if the box has been in the sack", "if the box had been carried by the player", and so on.

The past ("if the box was...") and past perfect ("if the box had been...") are especially useful for cases where we want to report on an action after the state of the item has changed; so, for instance:

After taking the mysterious box:
    if the box had not been carried by the player, say "You lift the mysterious box for the first time.";
    if the box had been carried by the player, say "You again pick up the mysterious box."

Test me with "open box / close box / open box / take box / drop box / take box".

This is in many respects similar to a rule beginning "After taking the mysterious box for the first time...", but it is superior in most circumstances, for two reasons.

First, it will respond correctly even if the player has somehow carried the box before without taking it explicitly: for instance, if another character gave him the box, if the box were moved into his inventory as a result of another action, or if the player carried the box at the start of play. Inform begins its reckoning of time when the game begins, so if the box is defined as being open at the outset, "if the box has been open" will always be true.

Second, "after taking... for the first time" fires only the first time the player attempts to take something. If the player tried to take the box, failed, and then tried again later, the "for the first time..." rule would not fire; our "if the box has not been carried..." rule would.

320. Puncak Jaya

By default, when something is not present, Inform does not allow a player to refer to it. But there are times when we might like to acknowledge that the thing mentioned in a command does exist somewhere in the game; it just happens not to be on hand right now.

One way to do this is to make an object that appears everywhere and responds to the name of its owner only when the owner itself is not in view.

paste.png "Puncak Jaya"

A ghost is a kind of person. A man-ghost is a kind of ghost. A man-ghost is always male. A woman-ghost is a kind of ghost. A woman-ghost is always female.

We make the ghost a person rather than some other kind of thing so that it will be able to respond to commands such as KISS BOB or (even trickier) BOB, JUMP: if Inform did not recognize the ghost as an animate creature, it would not accept such input.

Representation relates one ghost to one person. The verb to represent means the representation relation.

One man-ghost represents every man. One woman-ghost represents every woman.

This is, technically, an assembly -- except instead of saying that every device has a button part, or that there are three daffodils in every garden room, the assembly is based on a non-physical relation that we just designed.

Based on the "representation" relation, we now devise a conditional relation that applies only when the represented thing is not itself in view:

Indication relates a ghost (called X) to a person (called Y) when X represents Y and Y is not visible.

Understand "[something related by indication]" as a ghost.

When play begins:
    now every ghost is in the concept-repository.

Instead of doing something to a ghost:
    say "You seem to have left [a random person which is represented by the noun] behind."

Instead of doing something when the second noun is a ghost:
    say "You seem to have left [a random person which is represented by the second noun] behind."

The concept-repository is an open unopenable transparent container. It is part of the air. The air is a backdrop. It is everywhere.

Base of Puncak Jaya is a room. Temple, Kippax, and Huizenga are men in Base. Peak of Puncak Jaya is above Base of Puncak Jaya.

Test me with "x kippax / up / x kippax / kiss kippax / kippax, hello".

Further complications of this example might require that the player meet a character before being able to refer to him or her.

148. Zero ★★★

The names of objects might want to change also:

paste.png "Zero"

Weight is a kind of value. The weights are light, manageable, and horribly heavy. Everything has a weight.

A thing is usually manageable.

This does require a rule for an activity (see the chapter on Activities), but it's a fairly straightforward one:

Before printing the name of a horribly heavy thing (called weighty object):
    if we have taken the weighty object, say "[weight] ".

The Nearly Empty Living Room is a room. "Nearly everything is out, all of Helen's possessions and most of yours." A man called Mr Zero is in the Nearly Empty Living Room. "Mr Zero, despite being heavily paid to assist in this operation, is giving you a look that clearly conveys his lack of interest in budging even one more item." The description of Mr Zero is "Many muscles, no hair."

The book box is a horribly heavy thing in the Living Room. The clothing box is a manageable thing in the Living Room. A broom, a dustpan, some packing tape, and a discarded newspaper are light things in the Living Room.

After taking a horribly heavy thing:
    say "Taken. (Oof.)"

Test me with "get clothing / look / get book box / look / i / drop book box / look".

360. Casino Banale ★★★

In a work of interactive fiction that involves many new discoveries, we might want to change the way we narrate room descriptions and describe objects as the player learns new information.

One approach to this is to create a model of the facts we want the player to find out, and attach some narrative text to each. When a fact becomes relevant to the story, that narrative text is shown to the player. So:

paste.png "Casino Banale"

Section 1 - Procedure

First we create the concept of facts, and the idea that facts can make some things more important than others.

A fact is a kind of thing. A fact can be known or unknown. A fact can be ready to learn or hidden. A fact has some text called the narration.

Definition: a thing is narratively significant if it conveys an interesting fact.

Definition: a thing is narratively dull if it is not narratively significant.

Conveyance relates various things to various facts. The verb to convey means the conveyance relation.

Definition: a fact is interesting if it is unknown and it is ready to learn.

Now, we also need a way to tell Inform to introduce certain new facts when the right previous ones have been introduced. We'll create a "following" relation, according to which a new fact can be told to the player when the player has already learned all the facts it follows. This way, we can simulate the effect of putting together several pieces of evidence to come to a conclusion:

Following relates various facts to various facts. The verb to follow means the following relation.

To say (new fact - a fact):
    say "[narration of the new fact]";
    now the new fact is known;
    repeat with possible outcome running through facts which follow the new fact:
        if every fact which is followed by possible outcome is known:
            now the possible outcome is ready to learn.

Next we need a way for the game to introduce these new facts. Let's say we want them to come up when the player examines something appropriate, or sees it in the room:

After examining something which conveys an interesting fact (called discovery):
    say "[discovery][paragraph break]".

After choosing notable locale objects:
    repeat through the Table of Locale Priorities:
        if the notable-object entry is narratively significant:
            set the locale priority of the notable-object entry to 1.

For writing a paragraph about a narratively significant thing (called item):
    now the item is mentioned;
    let chosen fact be a random interesting fact which is conveyed by the item;
    say "[chosen fact][paragraph break]".

The "after choosing notable locale objects" line here handles things so that any interesting conclusions we want to draw are always given first, followed by the less interesting description.

And finally, we need to give the player a little evidence to piece together:

Section 2 - Scenario

The Casino is a room.

Frince is a man in the Casino. The description is "Frince is a friend of yours -- if you reckon friendship on the same terms that one reckons a cat as a pet. He spends time with you when he wants to, but if your wishes or convenience ever run counter to a whim of his, it's the whim that wins. Always. [paragraph break]He's also wearing a somewhat ludicrous shirt."

Frince wears a ludicrous shirt. The description of the ludicrous shirt is "Fine white fabric with satiny white pinstripes: it's that expensive, effeminate look that Frince is so fond of, and which -- combined with his name -- gives people completely the wrong idea about him."

Tim is a man in the Casino. The description is "You don't know Tim well. Kind of wall-flowerish. The only thing that seems to excite him is craps."

Penny is a woman in the Casino. The description is "Loud. Brash. Hot, probably, if you can look past the loud and brash."

Rule for writing a paragraph about a narratively dull person:
    let is-are-n be "is";
    if the number of unmentioned narratively dull people is not 1:
        let is-are-n be "are";
    say "[A list of unmentioned narratively dull people] [is-are-n] [one of]watching the croupier[or]following the spin of the roulette[or]chattering[at random][one of] breathlessly[or] impatiently[or][at random]."

Penny-annoying is a fact.
    It is ready to learn.
    The narration is "[if looking]Penny grimaces at you-- [end if]Penny is the same woman who stepped on your toe in the buffet line. The third time, she blurted, 'You have big shoes, don't you?'"
    Penny conveys penny-annoying.

lipstick-smudges is a fact.
    It is ready to learn.
    The narration is "There are a couple of smudges of coral-colored lipstick on the collar."
    The ludicrous shirt conveys lipstick-smudges.

penny-wears-coral is a fact.
    It follows penny-annoying.
    The narration is "[if looking]Penny catches your eye again. [end if]The bright coral lipstick was really not a wise choice."
    Penny conveys penny-wears-coral.

Affair-with-penny is a fact.
    It follows lipstick-smudges and penny-wears-coral.
    The narration is "You avoid [if examining Frince]his[otherwise]Frince's[end if] eye. You need some time to adjust to the image of him making out with Penny in a storage closet before you can talk to him without appalled giggling."
    Frince conveys affair-with-Penny.

Test me with "x penny / x frince / x shirt / look".

RB §5.6. Viewpoint

Inform automatically creates a character for the player - a bland, personality-free entity at the outset, as we've seen. But there is no reason why the player need stick to this same identity throughout the story. Conventional fiction often jumps from one viewpoint character to another, and so can IF.

To do this at the most elementary level, we simply at some point

now the player is Janine;

where Janine is a person we've already defined in the code. Now the player is in whatever location Janine inhabits, carries whatever Janine carries, and wears whatever Janine is wearing. Terror of the Sierra Madre ★★★ shows off this effect, and also demonstrates how to make the command prompt remind the player which character he currently controls. Some games instead give this information in the status line or after the name of the location when looking, producing output like

The Bottomless Acherousia (as Charon)

We could do the same by adding a line such as

After printing the name of a room while constructing the status line or looking:
    say "[roman type] (as [the player])"

Of course, we'll need a good deal of other work to make Janine a distinct person from whichever character the player was before. The distinction may come from changed capabilities of the new character, which we can express through new rules about actions; e.g.,

Instead of listening when the player is Janine:
    say "Your childhood accident left you unable to hear any but the loudest noises. Currently there is only silence."

Janine may also have new, different perspective on her surroundings, expressed through the descriptions of the things she looks at; Uncommon Ground ★★ makes a "by viewpoint" token for text alternatives, allowing us to tag our descriptions to indicate which variations should be shown to which viewpoint characters. The Crane's Leg 1 ★★★ and 2 offer more elaborate and specialized ways of customizing the player character's observations to depend on how he relates (physically and in attitude) to the things around him.

If we want to change the tense and person of narration from the conventional present second person, we may do this as well:

When play begins:
    now the story viewpoint is first person plural;
    now the story tense is past tense.

Though this only changes the form of the text produced automatically by Inform (responses such as "you can't go that way" might become, say, "I couldn't go that way"), and all author-written text in the story must be written in the tense and person intended.

Examples

391. The Crane's Leg 2

Names of rules can be listed in tables. This is convenient if, for instance, we decide that we'd like to swap the rules we use for a specific purpose, as in this continuation of our earlier example of automated description:

paste.png "The Crane's Leg, Grown Longer"

Material is a kind of value. The materials are wood, glass, stone, cloth, paper, clay, and metal. A thing has a material.

Color is a kind of value. The colors are red, orange, yellow, green, blue, indigo, violet, black, brown, and white. A thing has a color. A thing is usually white.

A height is a kind of value. 3 feet 11 inches specifies a height. A thing has a height. Definition: a thing is tall if its height is 6 feet 0 inches or more. Definition: a thing is short if its height is 2 feet 0 inches or less.

Imitation relates various things to one thing (called the ideal). The verb to imitate means the imitation relation.

A table is a kind of supporter. A table is usually wood. The height of a table is usually 3 feet 8 inches. The ordinary table is a table. Every table imitates the ordinary table.

A rock is a kind of thing. A rock is usually stone. The ordinary rock is a rock. The height of a rock is usually 0 feet 3 inches. Every rock imitates the ordinary rock.

The description of a thing is usually "[comparison with ideal][run paragraph on]".

To say comparison with ideal:
    say "You observe [the noun]:[paragraph break]";
    choose row with character of the player in Table of Descriptive Reporting;
    follow instructions entry.

This is the comparative observation rule:
    let the sample be the ideal of the noun;
    if the sample is not a thing:
        say "Nothing special, really.";
        rule succeeds;
    if the material of the noun is not the material of the sample:
        if the height of the noun is not the height of the sample:
            if the noun is shorter than the sample, say "Unusually short at [height of the noun], and made of [material of the noun].";
            otherwise say "Unusually tall at [height of the noun], and made of [material of the noun].";
        otherwise:
            say "Distinct mostly in being made of [material of the noun].";
    otherwise:
        if the height of the noun is not the height of the sample:
            if the noun is shorter than the sample, say "Unusually short at [height of the noun].";
            otherwise say "Unusually tall at [height of the noun].";
        otherwise:
            say "In every respect [a sample]."

The Pleasure Garden is a room. "At the riverbank, a pleasing garden, having many curving paths and one straight."

The low table is a table in the Pleasure Garden. The height of the low table is 2 feet 3 inches. On the low table is a yellow metal rock called a gold nugget. A willow is in the Pleasure Garden. The height of the willow is 20 feet 2 inches.

Understand "possess [any person]" or "be [any person]" as possessing.

Possessing is an action applying to one thing. Carry out possessing: now the player is the noun; say "You swap bodies!"

The crane is a person in the Garden. The height of the crane is 4 feet 0 inches.

Table of Descriptive Reporting

character

instructions

yourself

comparative observation rule

crane

bird observation rule

This is the bird observation rule:
    if the noun is shorter than the player, say "Small, like a duck[if the color of the noun is not white]; and [color of the noun][end if].";
    otherwise say "Supremely tall[if the color of the noun is not white] and [color of the noun][end if]."

Test me with "examine table / examine nugget / examine willow / possess crane / examine table / examine nugget / examine willow".

455. Uncommon Ground ★★

A slightly more challenging case than the "by atmosphere" example is one in which we want to create text variations depending on the identity of our player character.

What we want to do is build a switch statement in I6, one that looks something like

switch(player)
{
    yourself: print "quaint";
    Lolita: print "thrilling";
    default: print "squalid";
}

out of I7 that looks like this:

say "[show to yourself]quaint[to Lolita]thrilling[to everyone else]squalid[end show]".

paste.png "Uncommon Ground"

The Mud Village is a room. "You stand at the center of a [show to yourself]quaint[to Lolita]thrilling[to everyone else]squalid[end show] mud village."

Leforge is a man in the Mud Village. Lolita is a woman in the Mud Village.

Instead of waiting:
    if the player is Lolita, now the player is Leforge;
    if the player is yourself, now the player is Lolita;
    say "You jump bodies. Whoops!"

To say show to (N - a person) -- beginning say_seen_by:
    (-
        switch(player)
        {-open-brace}
        {N}:
    -).

To say to (N - a person) -- continuing say_seen_by:
    (-
        {N}:
    -).

To say to everyone else -- continuing say_seen_by:
    (-
        default:
    -)

To say end show -- ending say_seen_by:
    (-
        {-close-brace}
    -)

Test me with "look / z / look / z / look".

53. The Crane's Leg 1 ★★★

When you see a long object, you don't have to think that it is too long if being long is the property given by the nature. It is proved by the fact that a duckling, having short legs, will cry if you try to draw them out by force, and that a crane, having long legs, will protest you with tears if you try to cut them with a knife. -- Zhuangzi

Suppose we have an extremely detailed world model in which every object is characterized by many features -- in this example, material and height, though one could add more. Suppose further that we would like to generate descriptions of these things automatically for the most part, drawing the player's attention only to those aspects of the object that are particularly interesting.

paste.png "The Crane's Leg"

Material is a kind of value. The materials are wood, glass, stone, cloth, paper, clay, and metal. A thing has a material.

A height is a kind of value. 3 feet 11 inches specifies a height. A thing has a height. Definition: a thing is tall if its height is 6 feet 0 inches or more. Definition: a thing is short if its height is 2 feet 0 inches or less.

So far, we have generally dealt with cases where the property of a thing can be a number (such as 3), a value (such as brightness), or a unit (like height, here). It is also possible for a thing to have a property which names another thing, as in "The mother of the baby trout is the large trout" -- where "mother" is a property, and its value, in the case of the baby trout, is large trout. We would define such a property with a line such as "A fish has a thing called the mother."

In practice, though, this is a bit confusing as syntax; moreover, Inform has a much more powerful construct for talking about the ways in which one object relates to another object. A full discussion of this will have to wait for the chapter on Relations. For now, it is enough to say that we can do this:

Imitation relates various things to one thing (called the ideal). The verb to imitate means the imitation relation.

This will allow us to declare that some objects imitate other objects, like so:

A chair is a kind of supporter. A chair is always enterable. A chair is usually wood. The height of a chair is usually 4 feet 0 inches. The ordinary chair is a chair. Every chair imitates the ordinary chair.

A table is a kind of supporter. A table is usually wood. The height of a table is usually 3 feet 8 inches. The ordinary table is a table. Every table imitates the ordinary table.

A rock is a kind of thing. A rock is usually stone. The ordinary rock is a rock. Every rock imitates the ordinary rock. The height of a rock is usually 0 feet 3 inches.

A jug is a kind of container. A jug is usually clay. The ordinary jug is a jug. Every jug imitates the ordinary jug. The height of a jug is usually 0 feet 8 inches.

Now each of these types has one ideal representative which has the fundamental attributes of its kind: the ordinary chair is the most chairlike chair imaginable, the ordinary table is the epitome of tableness, and so on. We are also allowed to refer to "the ideal of the chair", thanks to the way we defined imitation. (Again, the relations chapter offers a much more detailed explanation of how relations may be defined.)

The description of a thing is usually "[comparison with ideal][run paragraph on]".

To say comparison with ideal:
    let the sample be the ideal of the noun;
    if the sample is not a thing:
        say "Perfectly conforming to your expectations of its type.";
        rule succeeds;
    if the material of the noun is not the material of the sample:
        if the height of the noun is not the height of the sample:
            if the noun is shorter than the sample, say "Unusually short at [height of the noun], and made of [material of the noun].";
            otherwise say "Unusually tall at [height of the noun], and made of [material of the noun].";
        otherwise:
            say "Distinct mostly in being made of [material of the noun].";
    otherwise:
        if the height of the noun is not the height of the sample:
            if the noun is shorter than the sample, say "Unusually short at [height of the noun].";
            otherwise say "Unusually tall at [height of the noun].";
        otherwise:
            say "In every respect [a sample]."

The Pleasure Garden is a room. "At the riverbank, a pleasing garden, having many curving paths and one straight."

The low table is a table in the Pleasure Garden. The height of the low table is 2 feet 3 inches. On the low table is a metal rock called a gold nugget.

Test me with "x table / x nugget".

So far the effect is not very deep, but we could take the auto-description a great deal further: providing a larger and more interesting set of variations; or writing a complicated set of rules such that the player only notices height variations when carrying a ruler; or switching between several player-characters, each of whom notices a different subset of characteristics. But these refinements would require more input from later chapters.

121. Terror of the Sierra Madre ★★★

Suppose we have a game where we want the player to control two different characters, swapping bodies from one turn to the next. First, the setting, and the two people who will alternately play:

paste.png "Terror of the Sierra Madre"

The Hay-Strewn Corridor is a room. "[if the player is Maleska]The horse stalls are empty: you have already drained the animals, and carried off their corpses. The house will not long sustain you now.

The window throws on the floor a bright square of malevolent sunlight[otherwise]The stalls for horses run down one side of the room, but the house has long stood empty. A square window without shutters looks out over the ranch, away toward the Sierras[end if]."

Teresa is a woman in the Hay-Strewn Corridor. "Teresa stands opposite you[if Teresa carries something], her fingers wrapped tightly around [a list of things carried by Teresa][end if]." Teresa carries a bulb of garlic and a cross.

Maleska is a man in the Hay-Strewn Corridor. "Maleska watches you from eyes entirely black." Maleska carries a skull.

If we tried the text above in Inform, we would find ourselves in the Hay-Strewn Corridor and confronted by both Teresa and Maleska. If "player" is not set to any named person, Inform creates a bland person called "yourself" to represent the player. To avoid this, we set "player" to the person we want to begin as. The player character is normally privately-named, so we'll need to make sure "Maleska" still means what it should.

The player is Maleska. Understand "Maleska" as Maleska.

Now the Corridor contains just two people, and we arrive on the scene as Maleska, with only Teresa facing us.

At the end of every turn we will use the 'now the player is...' phrase. (This looks as if it simply changes the value of "player": which it does, but it also carries out a complicated operation behind the scenes to effect the switch.)

Every turn:
    if the player is Maleska, now the player is Teresa;
    otherwise now the player is Maleska.

Our two characters already see the Corridor differently, but let's differentiate them further:

Every person has a number called strength. The strength of Teresa is 3. The strength of Maleska is 5.

In this small example, strength is not used for anything, except that we will display it on the status line:

When play begins:
    now the command prompt is "[bold type][player][roman type] > ";
    now the left hand status line is "[player]";
    now the right hand status line is "STR: [strength of the player]".

That last rule doesn't quite do what we might have expected. When we print "[player]", we find that Inform usually prints "yourself". This is because Inform says "you" to mean Teresa when talking to the player-being-Teresa, and likewise for Maleska. We want to override that in this particular story, because the rapid switches of personality are otherwise hard to follow. So:

Rule for printing the name of Teresa: say "Teresa".

Rule for printing the name of Maleska: say "Maleska".

Test me with "look / look".