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.";
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".
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]".
"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".
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.
"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.
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:
"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".