Chapter 13: Relations
13.16. What are relations for?

It is easy to say what verbs are for: they are to express relations. But what are relations for?

Inform 7's focus on relations between objects is unusual as an approach to interactive fiction; the concept does not exist in most design systems, or rather, it does but is submerged. Traditional design systems do, after all, have the spatial relations of being inside, on top of, and so on. It could well be said that these are the only relationships that inanimate objects ever have. A stone can be on top of a table, and if so then that expresses their entire association.

This is because the stone, and the table, have no opinions, emotions, knowledge or memory. If the stone is taken away and then put back, nothing has changed. People, on the other hand, tend to remember having met each other before; they like being in some places, but not others; their behaviour depends on who, or what, is nearby. Being conscious, they have internal states, unlike the stone. Relations are a simple but powerful way to express and talk about such connections, and although they have numerous uses in physical contexts too, they are at their most powerful when helping to make the characters of interactive fiction come alive.


241
** Example  Murder on the Orient Express
A number of sleuths (the player among them) find themselves aboard the Orient Express, where a murder has taken place, and one of them is apparently the culprit. Naturally they do not agree on whom, but there is physical evidence which may change their minds...

RB
242
** Example  What Not To Wear
A general-purpose clothing system that handles a variety of different clothing items layered in different combinations over different areas of the body.

RB

"What Not To Wear"

Section 1 - Overlying and Underlying

We start by borrowing some of the same ideas from the Bogart example, but we're also going to make a kind called "garment-element". This kind will include both garments (objects of clothing) and body parts (things that can be covered by clothing); using it allows us to restrict the way our underlying and overlying relations apply, which will make them a bit faster at run-time.

A garment-element is a kind of thing.

Underlying relates various garment-elements to various garment-elements with fast route-finding. The verb to underlie (it underlies, they underlie, it is underlying, it is underlaid) implies the underlying relation. The verb to be under implies the underlying relation.

Check taking off:
    if the noun underlies something (called the impediment) which is worn by the player, say "[The impediment] is in the way." instead.

Carry out taking off:
    now the noun is not underlaid by anything.

Report taking off something:
    say "You are now wearing [a list of uppermost things worn by the player]." instead.

Definition: a garment-element is uppermost if it is not under something opaque.

Here we've expanded on the previous ideas of 'uppermost' because it is possible for an upper layer to reveal what lies beneath: a tie, a clear plastic trenchcoat, an open-knit sweater, etc. We'll make such items transparent.

Before taking off something which underlies something which is worn by the player:
    while the noun underlies something (called the impediment) which is worn by the player:
        say "(first removing [the impediment])[command clarification break]";
        silently try taking off the impediment;
        if the noun underlies the impediment, stop the action.

Overlying relates various garment-elements to various garment-elements. The verb to overlie (it overlies, they overlie, it is overlying) implies the overlying relation.

Covering relates a garment-element (called A) to a garment-element (called B) when the number of steps via the overlying relation from A to B is greater than 0. The verb to cover (it covers, they cover, it is covering, it is covered) implies the covering relation.

Before wearing something when a garment which covers the noun is worn by the player:
    while the player wears a garment (called the impediment) which covers the noun:
        say "(first removing [the impediment])[command clarification break]";
        silently try taking off the impediment;
        if the player is wearing the impediment, stop the action.

Carry out wearing:
    repeat with hidden item running through things worn by the player:
        if the noun covers the hidden item, now the hidden item underlies the noun.

Instead of looking under something which is worn by the player:
    if something (called the underwear) underlies the noun, say "You peek at [the underwear]. Yup, still there.";
    otherwise say "Just you in there."

Instead of taking inventory:
    say "You're carrying [a list of things carried by the player][if the player wears something]. You are wearing [a list of uppermost garments worn by the player][end if]."

Section 2 - Regional Coverage

Here we draw in the idea that different clothes go over different areas of the body, and that they should be in competition with each other only if both sets of clothes belong at the same level over the same body area.

Before wearing something:
    let N be the layering depth of the noun;
    repeat with item running through things worn by the player:
        if the layering depth of the item is N and the item covers a body-part which is covered by the noun:
            say "(first taking off [the item])[command clarification break]";
            silently try taking off the item;
            if the player wears the item, stop the action.

This may seem like overkill, but it allows us to create garments that cover different subsets of the body -- pants and shirt vs. a dress, for instance.

To decide what number is the layering depth of (chosen garment - a thing):
    let N be 0;
    if the chosen garment covers a body-part (called base):
        let N be the number of steps via the overlying relation from the chosen garment to the base;
    decide on N.

To help with modeling, we'll give everyone body parts, broken down according to their relevance to clothing:

A body-part is a kind of garment-element. A torso, a seat, a head, pair of legs, and pair of feet are kinds of body-part.

If we wanted to allow gloves, we might put in hands as well; but this is enough for now.

One head is part of every person. One torso is part of every person. One pair of legs is part of every person. One pair of feet is part of every person. One seat is part of every person.

And now we make some categories of clothing:

A garment is a kind of garment-element. A garment can be transparent. A pair of pants, a pair of underpants, a foundation garment, a pair of socks, a pair of shoes, a jacket, a hat, a dress, and a shirt are kinds of garment.

The plural of pair of pants is pairs of pants. The plural of pair of underpants is pairs of underpants. The plural of pair of socks is pairs of socks. The plural of pair of shoes is pairs of shoes.

A pair of pants, a pair of underpants, a foundation garment, a pair of socks, a pair of shoes, a jacket, a hat, a dress, and a shirt are usually wearable.

When play begins:
    now every pair of socks overlies every pair of feet;
    now every pair of shoes overlies every pair of socks;
    now every pair of underpants overlies every seat;
    now every pair of pants overlies every pair of underpants;
    now every foundation garment overlies every torso;
    now every jacket overlies every shirt;
    now every jacket overlies every dress;
    now every hat overlies every head;
    now every dress overlies every pair of underpants;
    now every dress overlies every foundation garment.

Section 2 - The Scenario

The Dressing Room is a room.

The player carries some capris, some jeans, a corset, a plunge bra, a thong, boy-shorts, black satin D'Orsay pumps, brown leather boots, a camisole, a cocktail dress, a bolero, a cashmere shrug, a sheer wrap, and a linen tunic.

The woolly socks are a pair of socks.
The D'Orsay pumps and the brown leather boots are pairs of shoes.
The thong and the boy-shorts are pairs of underpants.
The capris and the jeans are pairs of pants.
The tunic is a shirt.
The camisole, the corset, and the plunge bra are foundation garments.
The cocktail dress is a dress.
The bolero, the cashmere shrug, and the sheer wrap are jackets. The shrug and the wrap are transparent.

Test me with "wear capris / wear jeans / i / wear thong / i / wear dress / wear corset / wear dress / i / wear wrap / i / wear boots / wear pumps / i".

243
*** Example  Graph-theory view of relations
Some notes on relations from the point of view of graph theory.

RB
244
*** Example  Mathematical view of relations
Some notes on relations from a mathematical point of view, provided only to clarify some technicalities for those who are interested.

RB


PreviousContentsNext