§7.12. Characters Following a Script

So far we've seen characters who will answer questions whenever the player feels like asking, and characters who will use some reasoning procedure to direct the conversation. There is a third option, often useful in IF with a fast-paced narrative: the character follows a conversational script, making sure to cover a series of points before the scene ends.

There are more and less tedious ways to implement this kind of scene. The worst case is one in which the player is not allowed to interrupt or ask any questions; he must merely wait until the character runs out of things to say. This can be useful and plausible in very small doses - say, two or three turns - but if the character has more information than that to impart, we may want to make the scene more interactive.

Pine 2 partly addresses this challenge: the character has a line of conversation that she wants to follow to its conclusion; we may ask questions along the way, but if we're silent, she'll take up the slack, and the scene won't end until she's done with what she has to say.

Another kind of script is a series of actions for the character to perform. Robo demonstrates a programmable robot that will observe what the player does, then try to emulate the actions later when switched into play-back mode. Robo 2 extends this capacity to allow the robot to contain fifteen different scripts which the player can store, list, run, and erase.

Your Mother Doesn't Work Here offers a character with a list of tasks but whose plans can be interrupted by more urgent demands. This verges on not being a simple script any more: if we carry the idea to its natural conclusion, we get characters capable of planning scripts for themselves to accomplish their aims. This is conventionally called "goal-seeking".

* See Goal-Seeking Characters for characters that work out plans for themselves in order to accomplish various outcomes


arrow-up.pngStart of Chapter 7: Other Characters
arrow-left.pngBack to §7.11. Character Knowledge and Reasoning
arrow-right.pngOnward to §7.13. Traveling Characters

*ExampleRobo 1
A robot which watches and records the player's actions, then tries to repeat them back in the same order when he is switched into play-back mode.

Suppose the player's mother is supposed to be cleaning the living room, but she can be interrupted by the need to pick up things the player has dropped. New tasks are added to the end of her "current plan" list; every turn, she attempts to do whatever is the last entry on that list.

paste.png "Your Mother Doesn't Work Here"

A person has a list of stored actions called the current plan.

Every turn:
    repeat with culprit running through people who are not the player:
        if the number of entries in current plan of the culprit is greater than 0:
            let N be the number of entries in the current plan of the culprit;
            try entry N of the current plan of the culprit;
            remove entry N from the current plan of the culprit.

The Living Room is a room. It contains a somewhat muddy Persian rug. Your mother is a woman in the Living Room.

West of the Living Room is the Kitchen.

Instead of your mother rubbing the rug:
    say "Your mother scrubs the stained areas of the rug, muttering to herself."

Instead of taking something:
    say "Nah, Mom'll get that."

Report your mother taking something:
    say "Your mother picks up [the noun][one of], sighing deeply[or], jaw tight[or], with assorted comments on your manners[or]; to judge from her comments, she is also indulging in a pleasant fantasy about Swiss boarding schools[stopping]." instead.

When play begins:
    add mother going west to the current plan of mother;
    add mother rubbing the rug to the current plan of mother.

Every turn:
    if mother is not in the Living Room, end the story finally.

Carry out dropping something:
    add mother taking the noun to the current plan of mother.

The player carries some dirty socks, some dirty shoes, a dirty hat, a pair of dirty trousers, and a backpack.

Test me with "drop socks / z / drop shoes / drop hat / drop all / z / z".

As goal-seeking goes, this is fairly rudimentary; "Boston Cream" provides an alternative (and slightly more sophisticated approach), but for really complex goal-seeking characters, it is probably best to turn to the character extensions designed for Inform.

*ExampleYour Mother Doesn't Work Here
Your hard-working mother uses a list as a stack: urgent tasks are added to the end of the list, interrupting longer-term plans.

Suppose the player's mother is supposed to be cleaning the living room, but she can be interrupted by the need to pick up things the player has dropped. New tasks are added to the end of her "current plan" list; every turn, she attempts to do whatever is the last entry on that list.

paste.png "Your Mother Doesn't Work Here"

A person has a list of stored actions called the current plan.

Every turn:
    repeat with culprit running through people who are not the player:
        if the number of entries in current plan of the culprit is greater than 0:
            let N be the number of entries in the current plan of the culprit;
            try entry N of the current plan of the culprit;
            remove entry N from the current plan of the culprit.

The Living Room is a room. It contains a somewhat muddy Persian rug. Your mother is a woman in the Living Room.

West of the Living Room is the Kitchen.

Instead of your mother rubbing the rug:
    say "Your mother scrubs the stained areas of the rug, muttering to herself."

Instead of taking something:
    say "Nah, Mom'll get that."

Report your mother taking something:
    say "Your mother picks up [the noun][one of], sighing deeply[or], jaw tight[or], with assorted comments on your manners[or]; to judge from her comments, she is also indulging in a pleasant fantasy about Swiss boarding schools[stopping]." instead.

When play begins:
    add mother going west to the current plan of mother;
    add mother rubbing the rug to the current plan of mother.

Every turn:
    if mother is not in the Living Room, end the story finally.

Carry out dropping something:
    add mother taking the noun to the current plan of mother.

The player carries some dirty socks, some dirty shoes, a dirty hat, a pair of dirty trousers, and a backpack.

Test me with "drop socks / z / drop shoes / drop hat / drop all / z / z".

As goal-seeking goes, this is fairly rudimentary; "Boston Cream" provides an alternative (and slightly more sophisticated approach), but for really complex goal-seeking characters, it is probably best to turn to the character extensions designed for Inform.

***ExamplePine 2
Pine: Adding a conversation with the princess, in which a basic set of facts must be covered before the scene is allowed to end.

***ExampleRobo 2
A robot which watches and records the player's actions, then tries to repeat them back in the same order when he is switched into play-back mode.