§19.3. New rules
Stretching a point seasonally, we might write:
Every turn, say "The summer breeze shakes the apple-blossom."
This rule is nameless. It needs no name because it will never need to be referred to: by identifying it as an every turn rule we have already said enough to lodge it in the "every turn" rulebook. In fact, though, it is easy to create a named rule:
This is the blossom shaking rule: say "The summer breeze shakes the apple-blossom."
The name of a rule must always end with the word "rule", for clarity's sake. (The phrasing "This is the ... rule" is used because "The ... rule" would be open to misinterpretation.)
Previously we had a rule which had no name, but belonged to a rulebook: now we have the opposite, because although the "blossom shaking rule" has a name, it has not been placed in any rulebook. That means it will probably never be applied, unless we give specific instructions for that.
Alternatively, it is possible to both name and place a rule in a single sentence:
Every turn (this is the alternative blossom rule): say "The summer breeze shakes the apple-blossom."
Now the "alternative blossom rule" is a named rule in the "every turn" rulebook.
|Start of Chapter 19: Rulebooks|
|Back to §19.2. Named rules and rulebooks|
|Onward to §19.4. Listing rules explicitly|
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:
"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.";
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].";
say "Distinct mostly in being made of [material of the noun].";
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].";
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
comparative observation rule
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".
A thing can have a rule as a property, if we like. Here we are going to allow the player to make a soup whose effects will depend on its ingredients. Each ingredient will have its own "food effect" rule, to be followed when the food is eaten.
Note that there are other, slightly less cumbersome ways to do the same thing -- we will see in a few sections in the chapter on object-based rulebooks that we could make a "food effects rulebook" and then write a number of rules such as "food effects rule for carrots" or "food effects rule for the stone". Nonetheless, we demonstrate rules-as-properties here for the sake of thoroughness.
A food is a kind of thing that is edible. A food has a rule called the food effect.
Carry out eating a food:
if a food is part of the noun:
repeat with item running through things which are part of the noun:
if item is a food, follow the food effect of the item;
follow the food effect of the noun.
Report eating a food:
say "You eat [the noun]. [diagnosis of the player]";
stop the action.
To say diagnosis of (victim - a person):
if the victim is ill:
say "You are ill.";
say "You are healthy. ";
if the victim is awake, say "You are wide awake. ";
otherwise say "You are sleepy. ";
if the victim is bright-eyed, say "Your eyesight is clear. ";
otherwise say "Your eyesight is dim. ";
if the victim is weak, say "You are weak. ";
otherwise say "You are strong. ";
if the victim is hungry, say "You are hungry.";
otherwise say "You are well-fed."
And now to provide some particular foods:
Some carrots are a food. The food effect of carrots is the bright-eye rule. This is the bright-eye rule: now the player is bright-eyed.
Some potatoes are a food. The food effect of the potatoes is the sleepiness rule. This is the sleepiness rule: now the player is sleepy.
The broth is a food. The indefinite article of the broth is "some". The food effect of broth is the filling rule. This is the filling rule: now the player is full.
The hambone is a food. The food effect of the hambone is the heartiness rule. This is the heartiness rule: now the player is strong. Instead of eating the hambone: say "You cannot just eat a bone!"
The poison ivy is a food. "Poison ivy grows nearby." The food effect of poison is the illness rule. This is the illness rule: now the player is ill.
A person can be bright-eyed or blind. The player is blind.
A person can be well or ill. The player is well.
A person can be hungry or full. The player is full.
A person can be strong or weak. The player is weak.
A person can be awake or sleepy. The player is sleepy.
The broth is in the kettle. The kettle is on the fire. The fire is in the Clearing. The Clearing is a room.
The player carries the hambone, the potatoes, and the carrots. The ivy is in the clearing.
Instead of examining the broth:
if something is part of the broth, say "In the broth, [a list of things that are part of the broth] float[if exactly one thing is part of the broth]s[end if].";
otherwise say "It is just a thin broth with no other ingredients."
Instead of inserting something into the broth: try inserting the noun into the holder of the broth.
Instead of taking the broth: say "You cannot take the broth in your bare hands."
And the following is a relatively unimportant nicety:
To sink is a verb.
After inserting a food which is not the broth into a container which contains the broth:
now the noun is part of the broth;
say "[The noun] [sink] into [the second noun], making the broth richer."
Test me with "x broth / eat hambone / put hambone in kettle / x broth / put potatoes in broth / x broth / eat carrots / eat broth / put ivy in kettle / eat ivy".
If we want to rewrite the functionality of a command that usually ends with a "block..." rule, we will have to begin by turning the blocking off.
The block giving rule is not listed in the check giving it to rules.
As it happens, correct behavior is built into the GIVE command once "block giving" is turned off, so we do not have to write a replacement report or carry-out rule; the object will be transferred to the possession of the caterpillar. But we do want to adjust the action just a little so that our gift cheers up the recipient:
Carry out giving (this is the gratitude for gifts rule): improve the mood of the second noun.
Mood is a kind of value. The moods are hostile, suspicious, indifferent, friendly, and adoring. An animal has a mood. An animal is usually indifferent.
To improve the mood of (character - an animal):
if the mood of character is less than friendly, now the mood of the character is the mood after the mood of the character.
Now whenever we give something to an animal, the animal will be pleased about the present. Of course, we might also want to add a check rule to giving, to see whether the offering is something the recipient really wants:
Check giving (this is the polite refusal of unwanted objects rule):
unless the noun interests the second noun:
say "[The second noun] disdainfully refuses [the noun]." instead.
To decide whether (item - a thing) interests (character - a person):
if the character has the item, no;
if the item is edible, yes;
Instead of showing something to someone:
try giving the noun to the second noun.
There is already a perfectly workable report rule that will describe what happens when we give something to someone, but let's say we want to report on the recipient's changed mood, too:
After giving something to someone:
say "You give [the noun] to [the second noun], who appears mollified and is now merely [mood of the second noun]."
And the rest is all scenario:
The Leafy Branch is a room. "You stand on smooth bark dappled by sunlight. The scent-trail runs forward to home.
The branch continues forward and backward from here, and a stem extends forward-up."
Instead of going south in Leafy Branch, say "You must not back down! The scent trail leads onward!"
The Very Hungry Caterpillar is a hostile animal in the Leafy Branch. "[The Caterpillar] looks [mood]." Instead of examining the Caterpillar, say "[The caterpillar] appears [mood]."
The player carries an edible thing called a peanut crumb. The carrying capacity of the player is 1. After taking something, say "You lift [the noun], though it is nearly your own size."
Instead of going north in the presence of a hostile caterpillar:
say "[The Caterpillar] moves to block your exit, glaring down at you with all the bristles on its skin extended to full size."
Instead of going north in the presence of a suspicious caterpillar:
say "[The Caterpillar] moves to block your exit, though it might allow you past if you offered further tribute."
The Leaf Face is above the branch. "The smooth and shiny surface of the leaf extends forward from here, but you have lost the scent-trail. This is not the way home." The pear fragment is an edible thing in Leaf Face. The dead aphid is a thing in Leaf Face.
The Twig is north of Leafy Branch. "The scent-trail is weak but not entirely gone, and you pursue it faithfully..."
After going to the Twig:
say "The scent-trail is weak but not entirely gone, and you pursue it faithfully...";
end the story finally.
Understand "forward-up" as up. Understand "forward" as north. Understand "backward" as south. Understand "backward-down" as down.
Test me with "forward / give crumb to caterpillar / forward / forward-up / get aphid / get fragment / down / give aphid to caterpillar / drop aphid / forward-up / get fragment / down / give fragment / forward".