I would like to be able to encode a table that contains various conditions that NPCs would like to hold, such that they will complain about them if they do not hold. And I’d like the table to contain various different relations – the cat is on the table, the mouse is in the cupboard, Annie is located in the front parlor, Jane is angry at Eliza.
To do this, I want to be able to define various pseudorelations as phrases taking two objects as inputs and putting out a truth state, run through the table to check whether they hold, and output some text if they don’t hold.
The following rather twisted code seems to be working so far. (Note that the “sign” entry tells you whether the desirer wants the pseudorelation in question to hold or not – Hartington wants the knife to be on the table so the sign entry is true, Annie wants the cat not to be on the table so the sign entry is false.)
Use American dialect and the serial comma.
Front Parlor is a room. Jane is a woman in Front Parlor. Hartington is a man in Front Parlor. Alfred is a man in Front Parlor. The player is Alfred. Eliza is a woman in Front Parlor. Annie is a woman in Front Parlor.
The table is a supporter in the Front Parlor. The cat is on the table. The knife is in the Front Parlor.
A pseudotruth state is a kind of value. The pseudotruth states are oui and non.
To decide which pseudotruth state is si (top - object) overtops (bottom - object) (this is overtopping):
if top is on bottom, decide on oui;
decide on non.
Table of Desires
Desirer first relatum pseudorelation second relatum sign
Eliza cat overtopping the table false
Hartington knife overtopping the table true
Every turn:
repeat through the Table of Desires:
if the sign entry is true:
if the pseudorelation entry applied to the first relatum entry and the second relatum entry is non:
say "[The desirer entry] says, 'I say! [The first relatum entry] [negative text of the pseudorelation entry] [the second relatum entry]!'";
otherwise [the sign entry is false]:
if the pseudorelation entry applied to the first relatum entry and the second relatum entry is oui:
say "[The desirer entry] says, 'I say! [The first relatum entry] [positive text of the pseudorelation entry] [the second relatum entry]!'".
[note that order seems to matter here; we have to have the generic case first]
To say negative text of (generic pseudorelation - phrase (object, object) -> pseudotruth state): say "isn't [generic pseudorelation][run paragraph on]".
To say negative text of (overtopping - phrase (object, object) -> pseudotruth state): say "isn't on[run paragraph on]".
To say positive text of (generic pseudorelation - phrase (object, object) -> pseudotruth state): say "is [generic pseudorelation][run paragraph on]".
To say positive text of (overtopping - phrase (object, object) -> pseudotruth state): say "is on[run paragraph on]".
test me with "take knife/take cat/put knife on table".
But this has a horrible hack involving “oui” and “non” as pseudotruth states, because
(1) phrases aren’t allowed to decide on a truth state (you have to said “to decide whether” instead of “to decide on what truth state is…” (see note below);
(2) this doesn’t compile:
To decide whether (top - object) overtops (bottom - object) (this is overtopping):
decide on whether top is on bottom.
Table of Desires
Desirer first relatum pseudorelation second relatum sign
Eliza cat overtopping the table false
Hartington knife overtopping the table true
Every turn:
repeat through the Table of Desires:
if the sign entry is true:
if the pseudorelation entry applied to the first relatum entry and the second relatum entry is false:
say "[The desirer entry] says, 'I say! [The first relatum entry] [negative text of the pseudorelation entry] [the second relatum entry]!'";
otherwise [the sign entry is false]:
if the pseudorelation entry applied to the first relatum entry and the second relatum entry is true:
say "[The desirer entry] says, 'I say! [The first relatum entry] [positive text of the pseudorelation entry] [the second relatum entry]!'".
[note that order seems to matter here; we have to have the generic case first]
To say negative text of (generic pseudorelation - phrase (object, object) -> nothing): say "isn't [generic pseudorelation][run paragraph on]".
To say negative text of (overtopping - phrase (object, object) -> nothing): say "isn't on[run paragraph on]".
To say positive text of (generic pseudorelation - phrase (object, object) -> nothing): say "is [generic pseudorelation][run paragraph on]".
To say positive text of (overtopping - phrase (object, object) -> nothing): say "is on[run paragraph on]".
Apparently the “to decide whether” phrase is a phrase (object, object) -> nothing rather than a phrase (object, object) -> truth state. But then how do I apply one of those to find out what its result is? Can I do that? Am I making a basic syntax error?
note below: the standard rules do have a phrase that decides on a truth state:
To decide what truth state is whether or not (C - condition)
(documented at ph_whether):
(- ({C}) -).
This compiles (obviously) but when I include another “to decide what truth state is…” phrase then the I7 compiler throws an error at this phrase of the Standard Rules as well as at the one I included.