Chapter 2: Adaptive Prose
2.2. Varying What Is Read

Making the printed text adapt to circumstances only makes half of the conversation graceful: the other half is to allow the player's commands to have a similar freedom. The things the player can refer to should always respond to the names which would seem natural to the player.

Names of things which contain prepositions are sometimes tricky because Inform misreads the sentences creating them: Laura shows how some awkward cases can be safely overcome.

First Name Basis shows how to assign names generically.

The more difficult case is to ensure that if we change the description or nature of something in play, then the names we understand for it adapt, too. "Understand... if..." can be all that's needed:

Understand "king" as Aragorn if we have crowned Aragorn.

Properties can also be matched without fuss:

Tint is a kind of value. The tints are green, aquamarine and darkish purple. The wallpaper is fixed in place in the Hôtel. The wallpaper has a tint. Understand the tint property as describing the wallpaper.

This allows EXAMINE AQUAMARINE WALLPAPER if, but only if, it happens to be aquamarine at the moment. Relationships can also be matched automatically:

A box is a kind of container. The red box is a box in the Toyshop. Some crayons are in the red box. Understand "box of [something related by containment]" as a box.

which recognises BOX OF CRAYONS until they are removed, when it reverts to plain BOX only.

Greater difficulty arises if, using some variable or property or table to mark that a bottle contains wine, we print messages calling it "bottle of wine". We are then honour-bound to understand commands like TAKE BOTTLE OF WINE in return, not to insist on TAKE BOTTLE. Almost all "simulation" IF runs in to issues like this, and there is no general solution because simulations are so varied.

* See Liquids for a resolution of this bottle-of-wine issue

* See Background, Memory, and Knowledge for a way to refer to characters whom the player knows about but who aren't currently in the room


18
** Example  Laura
Some general advice about creating objects with unusual or awkward names, and a discussion of the use of printed names.

WI

Occasionally it is useful to give something a printed name because we want to call it something extremely long-winded; give one thing a name that is the subset of the name of something else; or use words such as "with" or "and" that are likely to confuse Inform into thinking that the object name ends before it actually does.

Often it is enough to preface these ambiguously-titled things with "a thing called..." or "a supporter called..." or the like, as here:

South of Spring Rolls is a room called Hot and Sour Soup.

prevents Inform from trying to read "Hot and Sour Soup" as two separate rooms, while

The player carries an orange ticket. The player carries a thing called an orange.

creates two objects instead of the one orange ticket that would result if the second sentence were merely "The player carries an orange."

Even so, if we try to compile

The player carries a thing called an incriminating photograph of a woman with blonde hair.

Inform will misunderstand our meaning. So we might instead give the photograph a printed name:

"Laura"

The City of Angels is a room. The incriminating photograph is carried by the player. The printed name of the incriminating photograph is "incriminating photograph of a woman with blonde hair".

Now we've gotten around any awkwardness with printing the name -- but we also need to understand when the player refers to the photograph. When we define the names of objects under normal circumstances, Inform takes care of this automatically, but if we have especially set the printed name, we must also specially define the appropriate terms for the player to use. For this we need "understand", which will be explained in much more depth in a later chapter:

Understand "woman" or "with" or "blonde" or "hair" or "of" or "a" as the incriminating photograph.

Test one with "x photograph / x incriminating photograph of a woman with blonde hair / x hair / x blonde / x woman with blonde hair / x incriminating photograph of a woman".

That's probably as far as we really need to go, and if you are satisfied with this behavior, there is no need to read on.

One possible objection to this solution is that Inform will accept some nonsensical formulations as applying to the photograph: for instance, it will allow >EXAMINE PHOTOGRAPH OF, >X BLONDE PHOTOGRAPH WOMAN INCRIMINATING, or even >X OF ...though in the case there were two items with "of" names, the game would disambiguate with a question such as "Which do you mean, the incriminating photograph of a woman with blonde hair or the essence of wormwood?"

Traditionally, Inform has tended to be fairly flexible about word order, preferring to err in the direction of leniency. On the other hand, there are times when we need more exacting rules in order to distinguish otherwise similar cases.

Two features allow us to specify more exactly if we so desire. The first is that, if we specify a whole phrase as the name of something, all the words in that phrase are required, in the order given. Thus "Understand "blonde hair" as the photograph" would require that both "blonde" and "hair" be present, and would not recognize >X BLONDE, >X HAIR BLONDE, or >X HAIR.

Second, we can create tokens, such as "Understand "blonde hair" or "hair" as "[hair]", and then use these tokens in match phrases. This saves a good deal of time when we want to specify a number of different but fussy alternatives. So, for instance, here is a drawing that would not respond to >X OF, or >X BROWN EYES, but would respond to >X DRAWING OF MAN WITH BROWN EYES, >X MAN WITH BROWN EYES, and so on:

The drawing is carried by the player. The printed name of the drawing is "drawing of a man with brown eyes".

Understand "eyes" or "brown eyes" as "[brown eyes]". Understand "man" or "man with [brown eyes]" or "brown-eyed man" as "[man]". Understand "[man]" or "drawing of [man]" or "drawing of a [man]" as the drawing.

Test me with "test one / test two".

Test two with "x drawing / x man / x of / x drawing of man / x drawing of a man / x drawing of a man with brown eyes / x drawing of a brown-eyed man / x brown eyes".

Yet further refinements are possible; for a full discussion of how Inform understands names of objects, we should refer to the chapter on Understanding.

10
* Example  First Name Basis
Allowing the player to use different synonyms to refer to something.

WI


PreviousContentsNext