13.17. Review of Chapter 13: Relations

| Chapter 13: Relations |

| 13.17. Review of Chapter 13: Relations

1. Existing relations. As we have seen, the following relations are defined by default in Inform:

> Verb - Relation
> to contain - containment relation
> to support - support relation
> to carry - carrying relation
> to wear - wearing relation
> to unlock - unlocking relation

The meanings of these are explained in the chapter on Things. Two of Inform's built-in relations are expressed using prepositions instead:

> Preposition - Relation
> to be part of - incorporation relation
> to be adjacent to - adjacency relation

The meaning of parts is discussed in the chapter on Things. Adjacency is explained in the chapter on Descriptions.

Finally, there are conditional relations defined by Inform in advance:

> Verb/Preposition - Relation
> to be able to see - visibility relation
> to be able to touch - touchability relation
> to have - a superset of the carrying and wearing relations (possession relation)
> to enclose - indirect containment/support/incorporation relation
> to hold - direct containment/support/incorporation relation

The meaning of visibility and touchability is discussed further in the chapter on Descriptions (and further under Advanced Actions); enclosure in the chapter on Things.

We may review the relations that are currently defined by Inform or by our own code by looking at the bottom of the Phrasebook in the Index.

2. Creating new relations. We have already used the example:

> Loving relates various people to one person.

Let us create a verb which expresses this:

> The verb to love (he loves, they love, he loved, he is loved) implies the loving relation.

Note that we have omitted one of the parts of the verb. Actually we can legally miss out any of them, but the result is that the usages missed out will not be understood by Inform. In this case, Inform will understand

> Elizabeth loves Darcy.
> if anybody has been loved by Darcy, ...
> someone who is loved by Elizabeth
> the number of women who love Darcy

but it will not understand

> Elizabeth is loving Darcy.
> if Darcy is loving anybody, ...

because we did not supply the present participle "he is loving" as part of the definition of the verb. (That was deliberate, because the verb "to love" isn't used that way.)

Similarly, using our reciprocated relation for mere acquaintanceship,

> Meeting relates people to each other. The verb to know (he knows, they know, he knew, he is known) implies the meeting relation. Elizabeth knows Mr Wickham. Mr Wickham knows Mr Darcy.

We may also create two special formats of relation verb:

> The verb to be angry at implies the fury relation.
> The verb to be able to beat (he is beaten) implies the superiority relation.

In the first case, we will then be able to test (and set) the relation with standard forms of the verb to be, as in

> if anyone is angry at Marie Antoinette, ...
> now the Professor is angry at Gilligan.

and in the second, we may use such forms as

> if Fred can beat George, ...
> if Fred is able to beat your George, ...
> now Mistress Eva is able to beat the player.
> now the player can be beaten by Mistress Eva.

and so on.

3. Relation types. A relation can be characterized by three aspects: the number of entities allowed to participate in each side of the relation, whether the relation is reciprocal, and whether relation to one member of the group indicates the same relation to all the other members.

This does not produce quite as many combinations as one might at first expect. We cannot, of course, have a reciprocal relation that is unbalanced -- there is no such thing as a reciprocal one-various or various-one relation. Similarly, relations in groups must be various-various. Thus we may say

> Nationality relates people to each other in groups. (grouping, effectively reciprocal, various-various)

> Marriage relates one person to another. (reciprocal, one-one)
> Meeting relates people to each other. (reciprocal, various-various)

> Orbit relates one gravitational body to one gravitational body. (not reciprocal, one-one)
> Patronage relates one person to various people. (not reciprocal, one-various)
> Underlying relates various things to one thing. (not reciprocal, various-one)
> Admiration relates various people to various people. (not reciprocal, various-various)

In addition to these, we may write conditional relations, such as

> Contact relates a thing (called X) to a thing (called Y) when X is part of Y or Y is part of X. The verb to be joined to implies the contact relation.

These are considerably more restricted than other types of relation, and exist chiefly to allow more expression in our source text. We cannot set conditional relations by fiat (as in "now the hook is joined to the line"). Furthermore, it is not possible to find a best route through a conditional relation.

Conditional relations can be used to express the relation between things and values, as well, so that we can make more elegant phrasings for the properties of things.

4. Setting and unsetting relations. As usual, "now" can be used to change the state of the relation:

> now Elizabeth loves Bingham

But Inform will not allow this:

> now Elizabeth does not love Bingham

because, given the various-to-one nature of the relation, Inform knows that Elizabeth must love either one specific person or else nobody. It therefore thinks that ruling out specific individuals, as here, is misleading. Instead, we can cast Elizabeth adrift with an open heart thus -

> now Elizabeth does not love anybody

Such instructions are required to use the right kind: here we have "anybody" since the object of Elizabeth's love must be a person. For a relation of various people to one room, it would be "anywhere"; for a relation of various people to one thing, it would be "anything".

5. Finding indirect relations. Relations other than conditional relations may be used to find shortest paths between things: so that we may talk about

> the next step via the overlooking relation from the location to the Sundial Plot
> the number of steps via the overlooking relation from the location to the Sundial Plot

The number of steps -- as with pathfinding through rooms, a special case -- will be 0 if the location is the Sundial Plot, and -1 if there is no possible route between the two by this relation.

Previous | Contents | Next