13.13. Relations involving values

| Chapter 13: Relations |

| 13.13. Relations involving values

Although most of the examples in this chapter have involved objects, relations can connect almost any values together. We can create relations in groups, one to various relations, various to one relations, one to one relations, and various to various relations for any combination of kinds. For example:

> Partnership relates various texts to various texts.

> The verb to belong with (he belongs with, they belong with) implies the
> partnership relation.

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

How might we make use of this? Clearly it would be impractical to keep trying:

> if "caviar" belongs with "aardvarks", ...
> if "caviar" belongs with "abacuses", ...
> ...

to find out what "caviar" belongs with. It's still harder to find out if it belongs with anything at all -- in theory we would have to try every possibility, which of course is impossible. Instead we have these phrases:

if (value) relates to (name of kind) by (relation of values to values):

This condition is true if the value V is such that V relates to something by the given relation. Example: suppose partnership relates various texts to various texts. Then we can test if "chalk" relates to a text by the partnership relation, ...

if (name of kind) relates to (value) by (relation of values to values):

This condition is true if the value V is such that something relates to V by the given relation. Example: suppose partnership relates various texts to various texts. Then we can test if a text relates to "cheese" by the partnership relation, ...

If a partner does exist, then we can find it with:

(name of kind) to which/whom (value) relates by (relation of values to values) ... value
or: (name of kind) that/which/whom (value) relates to by (relation of values to values) ... value

This phrase produces an Y such that the given value V relates to Y by the given relation. Example: suppose partnership relates various texts to various texts. Then we can obtain the text to which "chalk" relates by the partnership relation which might be, say, "cheese". It's a run-time problem to use this if no such Y exists.

(name of kind) that/which/who relates to (value) by (relation of values to values) ... value

This phrase produces an X such that X relates to the given value V by the given relation. Example: suppose partnership relates various texts to various texts. Then we can obtain the text which relates to "cheese" by the partnership relation which might be, say, "chalk". It's a run-time problem to use this if no such X exists.

Of course, there might be many answers to this question, so perhaps these are neater:

list of (name of kind) that/which/who relate to (value) by (relation of values to values) ... value

This phrase produces a list of all the X such that X relates to the given value V by the given relation. Example: suppose partnership relates various texts to various texts. Then we can obtain list of texts which relate to "cheese" relates by the partnership relation which might be, say, { "chalk", "grapes", "macaroni" }. The answer might be the empty set, but that's not a problem.

list of (name of kind) to which/whom (value) relates by (relation of values to values) ... value
or: list of (name of kind) that/which/whom (value) relates to by (relation of values to values) ... value

This phrase produces a list of all Y such that the given value V relates to Y by the given relation. Example: suppose partnership relates various texts to various texts. Then we can obtain list of texts to which "chalk" relates by the partnership relation which might be, say, { "cheese", "blackboard", "cliffs" }. The answer might be the empty set, but that's not a problem.

Finally, it's sometimes useful to get at the list of all values which can appear on the left or right hand side of a relation. We need tongue-twister like wording to do it, but:

list of (name of kind) that/which/whom (relation of values to values) relates ... value

This phrase produces a list of all X which relate to anything under the given relation. Example: suppose partnership relates various texts to various texts. Then we can obtain list of texts which the partnership relation relates

list of (name of kind) to which/whom (relation of values to values) relates ... value
or: list of (name of kind) that/which/whom (relation of values to values) relates to ... value

This phrase produces a list of all Y which anything relates to under the given relation. Example: suppose partnership relates various texts to various texts. Then we can obtain list of texts which the partnership relation relates to

For efficiency reasons, there are no guarantees about what order these lists have - but they can of course always be sorted when found.

238
| Example Meet Market A case in which relations give characters multiple values of the same kind. |
RB

239
| Example For Demonstration Purposes A character who learns new actions by watching the player performing them. |
RB

Suppose we want to have a character who can dynamically learn new actions by observing the player performing them. We could do this by adding the actions to a list of things the character can do, but using a relation to express the same idea allows for tidier, easier-to-read code. Thanks to Jesse McGrew for the initial design of this example. "For Demonstration Purposes" Section 1 - Procedure Capability relates various people to various stored actions. The verb to be capable of implies the capability relation. 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 action requester is an object that varies. The action requester variable translates into I6 as "act_requester". To decide which stored action is the current action with no specific actor: let old actor be the person asked; let old requester be the action requester; now the person asked is the player; now the action requester is nothing; let CA be the current action; now the person asked is the old actor; now the action requester is the old requester; decide on CA. The learning by observation rule is listed after the report stage rule in the specific action-processing rules. Include Plurality by Emily Short. 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 [it-they] [is-are] learning."; now the viewer is capable of the current action. Section 2 - Scenario The Daily Planet is a room. Clark is here. He is a man. When play begins: now Clark is capable of the action of taking inventory. Test me with "Clark, inventory / Clark, x me / x me / Clark, x me".

Previous | Contents | Next