Let's Play/Read: Inform 7 manuals (Done for now)

Chapter 13, Relations (part 2)

13.13 is Relations involving values.

You can relate anything, not just objects:

Partnership relates various texts to various texts.

The verb to belong with means the
partnership relation.

"cheese" belongs with "crackers".
"clam" belongs with "chowder".

You can do conditions on this like so:

if "chalk" relates to a text by the partnership relation, ...
if a text relates to "cheese" by the partnership relation, ...
the text to which "chalk" relates by the partnership relation
the text which relates to "cheese" by the partnership relation

For multiple answers of this type:
list of texts which relate to "cheese" by the partnership relation
list of texts to which "chalk" relates by the partnership relation

Finally you can get every possible left hand side or right hand side:
list of texts which the partnership relation relates
list of texts which the partnership relation relates to

Some of the distinctions between these are very small, so it’s worth checking it carefully.

Example 238 is Meet Market:

Feature is a kind of value. The features are snub-nosed, gangly, comely, bright-eyed, and sulky.

Appearance relates various persons to various features. The verb to appear means the appearance relation.

Instead of looking:
    say "The snub-nosed ones: [list of people who appear snub-nosed][line break]";
    say "The gangly ones: [list of people who appear gangly][line break]";
    say "The comely ones: [list of people who appear comely][line break]";
    say "The bright-eyed ones: [list of people who appear bright-eyed][line break]";
    say "The sulky ones: [list of people who appear sulky][paragraph break]".

So this is just an example using relations for lists.

Example 239 is For Demonstration Purposes:
Capability relates various people to various stored actions. The verb to be capable of means the capability relation.

(as a side note, I don’t think you need to say ‘stored action’ anymore based on earlier material in this chapter).

Persuasion rule:
    let CA be the current action with no specific actor;
    if the person asked is capable of CA:
        persuasion succeeds;
    otherwise:
        say "[The person asked] look[s] confused. Maybe a demonstration would help.";
        persuasion fails.

The learning by observation rule is listed after the report stage rule in the specific action-processing rules.

Definition: a person is other if he is not the player.

This is the learning by observation rule:
    repeat with the viewer running through other people who can see the player:
        if the player is the actor and viewer is not capable of the current action:
            say "[The viewer] watches your behavior with interest. Seems like [they] [are] learning.";
            now the viewer is capable of the current action.

There’s some other heavy-duty code in here, but basically this lets other people learn from your actions.

Section 13.14 is Relations as values in their own right:

Parity relates a number (called N) to a number (called M) when N minus M is even.

Joint magnitude relates a number (called N) to a number (called M) when N plus M is greater than 7.

are both examples of relations, and they have the same kind:
relation of numbers to numbers, and every relation is between a kind K and a kind L (so this really is just set theoretical relations with domain K and codomain L). If K=L we call it a relation of K.

So you if you want to refer to a kind of relations you can do it like this:

To chart (R - a relation of numbers):
    repeat with N running from 1 to 5:
        repeat with M running from 1 to 5:
            if R relates N to M, say "[N] <=> [M] ";
        say "[line break]";

You can also write this for any relation:

if R relates X to Y, ...
now R relates X to Y;
now R does not relate X to Y;

Hmm, could you also repeat through relations? Sounds interesting.

Here are some adjectives applying to relations:

"empty" - nothing relates to anything else
"symmetric" - by definition X relates to Y if and only if Y relates to X
"equivalence" - this is a relation "in groups", or an "equivalence relation"
"one-to-one" - it relates one K to one L
"one-to-various" - similarly
"various-to-one" - similarly
"various-to-various" - similarly

Ha! I was right that relation ‘in groups’ was just an equivalence relation in a fancy hat.

You can clear out some relations with ‘now R is empty’, but not a lot of built-in ones.

Example 240 is Number Study.

Parity relates a number (called N) to a number (called M) when N minus M is even.

Joint magnitude relates a number (called N) to a number (called M) when N plus M is greater than 7.

To chart (R - a relation of numbers):
    repeat with N running from 1 to 5:
        repeat with M running from 1 to 5:
            if R relates N to M, say "[N] <=> [M] by [R][line break]";

When play begins:
    let L be { parity relation, joint magnitude relation };
    repeat with R running through L:
        chart R.

Huh, so you can repeat through some relations. Nice.

Section 13.15 is Temporary relations. You can create a new, empty relation like this:

let the password dictionary be a relation of texts;

By default, relations are various-to-various, but we could instead write, say:

let the nicknames catalogue be a various-to-one relation of texts;

There’s no verb created when you do this, but you can say something like this:

now the nicknames catalogue relates "Trudy" to "Snake-eyes";

Finally, section 13.16 is What are relations for?

It points out that most other design systems for IF don’t really have relations (I don’t remember Dialog having them. Does TADS?)

It says that relations are most useful when working on the internal motivations of people. Interesting…

Example 241 is Murder on the Orient express, where people suspect each other:

The Dining Car is a room. Lord Peter is a man in the Dining Car. Sherlock Holmes is a man in the Dining Car. Miss Marple is a woman in the Dining Car. Adam Dalgliesh is a man in the Dining Car.

Suspecting relates various people to one person.

The verb to suspect means the suspecting relation.

Dalgliesh suspects Holmes. Holmes suspects Lord Peter. Lord Peter suspects Holmes. Miss Marple suspects the player.
Instead of showing something to a person who suspects the player:
    say "'You would say that,' remarks [the second noun] darkly.".

Instead of showing something which exculpates the player to someone:
    say "'How striking!' says [the second noun]. 'Almost I begin to distrust myself.'".

Example 242 is What Not to Wear

This is a very long example similar to one we covered earlier, where garments overlay each other and different garments have different body parts. It’s complex enough that I don’t think a snippet will do it justice.

Example 243 is Mathematical view of relations, which basically covers everything I mentioned earlier. Cool! Things like reflexive, symmetric, transitive, and equivalence classes.

Example 244 is a graph theory view, which explains a bit about how route finding is calculated. It also mentions data storage use of relations:

All the cases are benign except for “various to various” - the most useful - and for its closely related symmetrical version, “relates… to each other”. Inform cannot afford to assume that the relation will be “sparse” (that is: that no vertex will have more than a certain number of arrows, or that the total number of arrows will be small), because it has no idea how the arrows will come and go during play. It therefore uses 1 bit of storage for each pair of objects. This sounds harmless, but if there are 200 rooms, there are 40,000 pairs of rooms, which means a 5000-byte allocation of storage (plus a handful of bytes as overhead). Gratuitous various-to-various relations are therefore not a good idea.

Pretty fun! I love math, so this is neat to read.

1 Like