§7.11. Character Knowledge and Reasoning

A character may be endowed with knowledge and even reasoning skills. Relations form quite a good way of keeping track of such problems: for instance, we can allow characters to be acquainted with one another with a relation such as

Lucy knows Lady Cardew.

Or we might keep track of more complicated attitudes between characters, as in Murder on the Orient Express, in which some characters suspect others of the crime.

Alternatively, we might have a list of salient facts that are important in our game. We might declare these as values, and then characters could know, learn, and forget entries as appropriate:

A fact is a kind of value. Some facts are defined by the Table of All Known Facts.

Knowledge relates various people to various facts. The verb to know (he knows, they know, he knew, it is known) implies the knowledge relation.

Table of All Known Facts
fact summary
shoe-size "Lucy wears a size 9 shoe."
sunset-time "Sunset is at 8:22 PM this evening."

Lucy knows shoe-size.
Bob knows sunset-time and shoe-size.

Or again we might keep a whole database of information in a table: the characters in Questionable Revolutions know dates, countries, and a short description for each of several rebellions and popular uprisings, while in Queen of Sheba, Solomon is able to answer who, what, where, when, and why questions about a range of topics. This kind of approach is most useful when the characters need to display a deep knowledge of a particular field. The facts stored in the Table of All Known Facts, above, are comparatively sparse, because there we are designing a game in which not all data about the world is equally valuable: Lucy doesn't know the shoe size of every person in the game, because for some reason it is only her own shoe size that matters. On the other hand, the Table of All Known Facts can store different kinds of information, whereas the revolutions table has no way of storing shoe sizes or sunset times. And Murder on the Orient Express works differently again, because it is storing knowledge that concerns people and things that already exist in the world model, rather than abstract ideas. Our way of modeling character knowledge, in other words, will depend quite a lot on what kind of knowledge it is.

The possibilities of character reasoning are similarly broad, but The Problem of Edith introduces one kind: the character has a concept of how different conversation topics relate to one another, so that when she is asked about a new keyword, she picks a response that makes the question most relevant to the conversation already in progress.

We end with a longer scenario, in which we track what the character knows about the player and the conversational state: in Chronic Hinting Syndrome, the main character guides conversation in the direction he intends it to go, with the player's sometimes-reluctant participation.

* See Obedient Characters for a character who needs to be taught how to perform actions before doing them

* See Characters Following a Script for a programmable robot who can be given whole sequences of actions to perform


arrow-up.pngStart of Chapter 7: Other Characters
arrow-left.pngBack to §7.10. Character Emotion
arrow-right.pngOnward to §7.12. Characters Following a Script

**ExampleMurder 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...

Suppose that we have a core set of issues we want to be able to bring up with all the characters, and we want characters to draw intelligent connections between different conversation topics. We will need some model of how things relate to one another, so:

paste.png "The Problem of Edith"

Suggestion relates things to each other. The verb to suggest means the suggestion relation.

A subject is a kind of thing. The current subject is a thing that varies. greeting is a subject.

Understand "ask [someone] about [any subject]" as asking it about the subject. Understand "tell [someone] about [any subject]" as asking it about the subject.

Asking it about the subject is an action applying to one thing and one visible thing.

Carry out asking it about the subject:
    say "'Hmm, [the second noun],' says [the noun]. ";
    relate the current subject with the second noun;
    now the current subject is the second noun.

And if we wanted to offer the player some hints about angles he could pursue:

Instead of thinking:
    say "You contemplate [a list of things suggested by the current subject]."

For that matter, we could use the same system to have characters make sense of any physical evidence the character shows them:

Instead of showing something which suggests the current subject to someone:
    say "[The second noun] nods impatiently."

Instead of showing something to someone:
    let the next subject be the next step via the suggestion relation from the noun to the current subject;
    if the next subject is a subject:
        try asking the second noun about the subject the next subject;
    otherwise:
        say "[The second noun] shrugs."

When play begins:
    now the left hand status line is "Discussing: [current subject]";
    now the right hand status line is " ".

Broughton Hall is a room. Lady Uckfield is a woman in Broughton Hall. "Lady Uckfield sits at her desk, looking wholly composed."

The nasty letter is a thing carried by the player. The nasty letter suggests infidelity and penmanship. The ten-pound note is carried by the player. It suggests money.

Infidelity is a subject. Infidelity suggests marriage and divorce. Marriage suggests love. Marriage, love, and divorce are subjects.

Penmanship is a subject. Penmanship suggests education. Education is a subject. Class status and money are subjects. Class status suggests education. Money suggests class status and marriage.

The current subject is divorce.

Now we can define what gets said when the subject is changed, regardless of whether the segue was introduced in speech or by a shown object. Since rows are blanked after use, the speaker will never repeat herself; if we provide more than one line about the same pair of topics, the first one will be used, then the second, and so on, until the table runs out:

To relate (initial - a subject) with (next - a subject):
    repeat through Table of Remarks:
        if the initial is starting entry and the next is the final entry:
            say "[comment entry][paragraph break]";
            blank out the whole row;
            rule succeeds;
    say paragraph break.

Table of Remarks

starting

final

comment

divorce

love

"'As it seems to me, all the love is on one side,' she says crisply. 'And that rarely works.'"

divorce

love

"'Stop making that plea: it won't work.'"

divorce

infidelity

"'Frankly, I rather think there would have been cause enough for divorce without the perversely plentiful evidence of unfaithfulness.'"

divorce

money

"'If you mean that the divorce will be expensive, I know it,' she says. 'But I can think of no happier investment.'"

marriage

money

"'If you wish me to understand that it was a marriage for money, you could have spared your energy. That was patent from the outset.'"

infidelity

money

"'I'm sorry, but I don't see how having married for money excuses a subsequent infidelity.'"

If we had more than one character in the scenario, we could provide multiple tables, but this will do to demonstrate the idea.

Of course, we can override specific instances, if we want the character always to say the same thing regardless of how we came to this point:

Instead of asking Lady Uckfield about the subject penmanship:
    now the current subject is penmanship;
    say "She sighs. 'So few people write really beautifully these days.'"

Test me with "think / ask lady about infidelity / show nasty letter to lady / show note to lady / think / ask lady about divorce / ask lady about love / ask lady about marriage / ask lady about divorce / ask lady about love / ask lady about penmanship".

We would have to be careful about this system, since we have applied a various-to-various relation to every single object in the game. In practice it would probably be wisest to restrict it a bit, with judicious definitions of kind and so on.

***ExampleThe Problem of Edith
A conversation in which the main character tries to build logical connections between what the player is saying now and what went immediately before.

Suppose that we have a core set of issues we want to be able to bring up with all the characters, and we want characters to draw intelligent connections between different conversation topics. We will need some model of how things relate to one another, so:

paste.png "The Problem of Edith"

Suggestion relates things to each other. The verb to suggest means the suggestion relation.

A subject is a kind of thing. The current subject is a thing that varies. greeting is a subject.

Understand "ask [someone] about [any subject]" as asking it about the subject. Understand "tell [someone] about [any subject]" as asking it about the subject.

Asking it about the subject is an action applying to one thing and one visible thing.

Carry out asking it about the subject:
    say "'Hmm, [the second noun],' says [the noun]. ";
    relate the current subject with the second noun;
    now the current subject is the second noun.

And if we wanted to offer the player some hints about angles he could pursue:

Instead of thinking:
    say "You contemplate [a list of things suggested by the current subject]."

For that matter, we could use the same system to have characters make sense of any physical evidence the character shows them:

Instead of showing something which suggests the current subject to someone:
    say "[The second noun] nods impatiently."

Instead of showing something to someone:
    let the next subject be the next step via the suggestion relation from the noun to the current subject;
    if the next subject is a subject:
        try asking the second noun about the subject the next subject;
    otherwise:
        say "[The second noun] shrugs."

When play begins:
    now the left hand status line is "Discussing: [current subject]";
    now the right hand status line is " ".

Broughton Hall is a room. Lady Uckfield is a woman in Broughton Hall. "Lady Uckfield sits at her desk, looking wholly composed."

The nasty letter is a thing carried by the player. The nasty letter suggests infidelity and penmanship. The ten-pound note is carried by the player. It suggests money.

Infidelity is a subject. Infidelity suggests marriage and divorce. Marriage suggests love. Marriage, love, and divorce are subjects.

Penmanship is a subject. Penmanship suggests education. Education is a subject. Class status and money are subjects. Class status suggests education. Money suggests class status and marriage.

The current subject is divorce.

Now we can define what gets said when the subject is changed, regardless of whether the segue was introduced in speech or by a shown object. Since rows are blanked after use, the speaker will never repeat herself; if we provide more than one line about the same pair of topics, the first one will be used, then the second, and so on, until the table runs out:

To relate (initial - a subject) with (next - a subject):
    repeat through Table of Remarks:
        if the initial is starting entry and the next is the final entry:
            say "[comment entry][paragraph break]";
            blank out the whole row;
            rule succeeds;
    say paragraph break.

Table of Remarks

starting

final

comment

divorce

love

"'As it seems to me, all the love is on one side,' she says crisply. 'And that rarely works.'"

divorce

love

"'Stop making that plea: it won't work.'"

divorce

infidelity

"'Frankly, I rather think there would have been cause enough for divorce without the perversely plentiful evidence of unfaithfulness.'"

divorce

money

"'If you mean that the divorce will be expensive, I know it,' she says. 'But I can think of no happier investment.'"

marriage

money

"'If you wish me to understand that it was a marriage for money, you could have spared your energy. That was patent from the outset.'"

infidelity

money

"'I'm sorry, but I don't see how having married for money excuses a subsequent infidelity.'"

If we had more than one character in the scenario, we could provide multiple tables, but this will do to demonstrate the idea.

Of course, we can override specific instances, if we want the character always to say the same thing regardless of how we came to this point:

Instead of asking Lady Uckfield about the subject penmanship:
    now the current subject is penmanship;
    say "She sighs. 'So few people write really beautifully these days.'"

Test me with "think / ask lady about infidelity / show nasty letter to lady / show note to lady / think / ask lady about divorce / ask lady about love / ask lady about marriage / ask lady about divorce / ask lady about love / ask lady about penmanship".

We would have to be careful about this system, since we have applied a various-to-various relation to every single object in the game. In practice it would probably be wisest to restrict it a bit, with judicious definitions of kind and so on.

***ExampleThe Queen of Sheba
Allowing the player to use question words, and using that information to modify the response given by the other character.

***ExampleQuestionable Revolutions
An expansion on the previous idea, only this time we store information and let characters answer depending on their expertise in a given area.

****ExampleChronic Hinting Syndrome
Using name-printing rules to keep track of whether the player knows about objects, and also to highlight things he might want to follow up.