Epistemology of Conversation Topics

As an alternative to Disambiguation Control, you can try my Disambiguation Override, which allows you to set variables (possibly changing the scope) and then reparse the command.

eyeballsun.org/i/Disambiguation%20Override.i7x

OK, I think I’ve done something like this. I’m using a relation that calls a check on the availability rules, and then I can use that relation to prune the disambiguation list in my call to Disambiguation Control. I had worried that there might be a problem depending on whether the CI was the noun or the second noun, but I threw in an Understand line that had the nouns reversed and that seems to work. (“Compliment rock to Janice” works properly, well except that it spells it “complimen.”) So if the hitch is that you can’t parse the CI from the second noun and the quip from the noun, maybe the solution is to reverse all your nouns and parse the CI from the noun and the quip from the second noun?

[code]Include Disambiguation Control by Jon Ingold.

Lab is a room.
Complimenting it on is an action applying to two visible things. Understand “compliment [someone] on [any thing]” as complimenting it on. Understand “compliment [any thing] to [someone]” as complimenting it on (with nouns reversed).
Report complimenting: say “You say ‘That’s a very nice [second noun], [noun].’”

The current interlocutor is a person that varies.
Carry out examining someone: Now the current interlocutor is the noun.
Carry out complimenting someone on something: now the current interlocutor is the noun.

A thing can be relevant or irrelevant.

Instead of examining a relevant thing: say “[The current interlocutor] notices your interest in [the noun].”

The availability rules are a person based rulebook.
First availability rule: now everything is irrelevant.
An availability rule for Janice: Now the red rock is relevant.
An availability rule for Janice: now the green rock is relevant.
An availability rule for Boromir: now the blue rock is relevant.

Every turn:
follow the availability rules for the current interlocutor;
if the current interlocutor is not yourself, say “[The current interlocutor] is interested in [the list of relevant things].”

To decide whether (subject - a thing) interests (addressee - a person):
follow the availability rules for addressee;
if the subject is relevant, yes.

Interest relates a thing (called subject) to a person (called addressee) when the subject interests the addressee. The verb to be watched by implies the interest relation.

Should the game suggest complimenting someone on a thing that is not watched by the noun: never.

Lab is a room. Janice is a woman in Lab. Boromir is a man in Lab. A red rock is in Lab. A green rock is in Lab. A blue rock is in Lab.

Instead of singing:
say “Red rock:”;
if red rock is watched by Janice, say “Yes.”;
say “Blue rock:”;
if blue rock is watched by Janice, say “Yes.”;
say “Green rock:”;
if green rock is watched by Janice, say “Yes.”.[/code]

(The business about singing is debug code; the first time through I ended the “To decide whether” rule with “if the subject is irrelevant, no” which meant that it never decided on yes.)

This may well be unnecessarily roundabout; I sort of kicked it until it worked. And it would probably require all kinds of special care, since parsing “compliment” commands throws away all the relevance information. If I were doing this properly I might make a pseudo-availability rulebook that does the calculation and gets consulted both in the turn sequence rule and in parsing, and have another rule that only gets called in the turn sequence rule that sets the available quips to whatever is pseudo-available. That might have an effect of the sort of conditional calculation of availability that you’re looking for, without messing up the actual calculations of availability.

Also, I suspect this code is hellaciously inefficient.

Oof. Yes, I imagine that running a rulebook that performs calculations over every single quip, times every single quip, for every disambiguation, will be inefficient.

That rulebook should only need to be run once – well, once here after reading the player’s command, and at the end of the turn as usual – since its results are recorded onto each individual thing. So I will see if I can’t run the activity just once, after reading a command, and before parsing… Thanks for pointing me in this direction!

capmikee, great! That extension looks like exactly what I’m looking for. …I think. That is some dense documentation, I’m still trying to wrap my head around it.

Sorry about the documentation. I’m afraid I didn’t spend as much time on it as I should… and I’ve been procrastinating on all my extensions, waiting for the next release of I7.

But feel free to ask questions!

Also, as I might have mentioned in the other thread, Lost Items makes use of Disambiguation Override, and you can use that to get an idea of what should be happening with it.

Well I’m finally getting somewhere – run-time errors. For those of you following along at home, here’s a mini-TC to demonstrate the issue:

[spoiler][code]“Spelunkery”

Include Disambiguation Override by Mike Ciul.
Include Conversation Framework by Eric Eve.

Book I - Machinery

Section 1 - Quips

A quip is a kind of thing.

Quip-supplying relates various quips to various people. The verb to quip-supply (it quip-supplies, they quip-supply, it quip-supplied, it is quip-supplied) implies the quip-supplying relation.

Definition: a quip is character-tailored rather than universally-applicable if it quip-supplies someone.

Mentioning relates various quips to various things. The verb to mention (it mentions, they mention, he mentioned, it is mentioned) implies the mentioning relation.

Understand “[something related by mentioning]” as a quip.

Section 2 - Availability Rulebook, abridged

This is the relabel available quips rule:
[ This rule is very important: it tags quips available before running a new turn. Therefore, the game doesn’t have to reassess availability on the fly during plausibility tests or during parsing. ]
[ On the other hand, it means that we should not test availability or plausibility on our own without first calling this rule. ]
now every quip is flagged-unready;
repeat with item running through quips:
if item is available:
say "[item]: y ";
now item is flagged-ready.
[Thus, we can also mark quips nonviable in order to skip considering them; if for instance we only want to consider quips relevant to the current scene, or the current character.]

A quip can be flagged-ready or flagged-unready.

The relabel available quips rule is listed after the adjust light rule in the turn sequence rules.
[ The rule needs to appear late in the turn sequence so that if for instance a change of scene changes the identity of the current interlocutor, ]
[ the quips are correctly labeled based on that information. ]

Availability rules are an object-based rulebook. The availability rules have outcomes it is available (success) and it is off-limits (failure).
[ This determines whether a given quip is even allowed for use. It is different from plausibility, which chooses quips that are relevant at the moment, ]
[ but (depending on the system) might not include everything that the player could reasonably choose to talk about at the moment. ]

Definition: a quip is available:
follow the availability rules for it;
if the outcome of the rulebook is the it is available outcome, yes;
no.

The first availability rule (this is the don’t talk to no one rule):
if the current interlocutor is not a person:
it is off-limits; [But this should never happen!]

An availability rule for a quip (called the target) (this is the restriction of quips to special people rule):
if the target is character-tailored and the current interlocutor is not quip-supplied by the target:
it is off-limits;
make no decision;

The last availability rule (this is the generic availability rule):
it is available.

Section 3 - The Discussion Action

Understand the commands “ask”, “tell”, “say”, “answer”, “a”, “t” as something new.

Discussing it with is an action applying to two visible things.

Check discussing something with:
if the second noun is not the current interlocutor:
implicitly greet the second noun;
say “(addressing [the current interlocutor])”;
if the current interlocutor is not the second noun, stop the action;
follow the relabel available quips rule;

Carry out discussing it with:
try discussing the noun.

Discussing is an action applying to one visible thing.

Understand “talk about [any flagged-ready quip]” and “talk [any flagged-ready quip]” as discussing.
Understand the commands “say” and “discuss” as “talk”.

Understand “change the subject to [any flagged-ready quip]” and “change subject to [any flagged-ready quip]” as discussing.
Understand the command “a” as “ask”. Understand the command “t” as “tell”.

Understand “discuss [any flagged-ready quip] with [something]” or “say [any flagged-ready quip] to [something]” as discussing it with.
Understand “tell [something] that/about [any flagged-ready quip]” or “ask [something] that/about [any flagged-ready quip]” as discussing it with (with nouns reversed).
Understand “tell [something] [any flagged-ready quip]” or “ask [something] [any flagged-ready quip]” as discussing it with (with nouns reversed).

Report discussing: say “You ask [the current interlocutor] [the noun].”

Section 4 - Catching

Proto-discussing is an action applying to one visible thing. Proto-discussing it with is an action applying to two visible things.

Understand “talk about [any quip]” and “talk [any quip]” as proto-discussing. Understand “change the subject to [any quip]” and “change subject to [any quip]” as proto-discussing.

Understand “tell about [any quip]” and “tell [any quip]” as proto-discussing. Understand “ask about [any quip]” and “ask [any quip]” as proto-discussing.

Understand “discuss [any quip] with [something]” or “say [any quip] to [something]” as proto-discussing it with.
Understand “tell [something] that/about [any quip]” or “ask [something] that/about [any quip]” as proto-discussing it with (with nouns reversed).
Understand “tell [something] [any quip]” or “ask [something] [any quip]” as proto-discussing it with (with nouns reversed).

[Check proto-discussing when the current interlocutor is not visible and the current interlocutor is not nothing:
abide by the can’t converse with absent interlocutor rule.]

[Check proto-discussing:
if the current interlocutor is not a person, say “You aren’t addressing anyone at the moment.” instead;
say “That doesn’t seem to be a topic of conversation at the moment.” instead.]

Before asking which do you mean when proto-discussing:
follow the relabel available quips rule;
filter the match list for flagged-ready quips, leaving at least one choice;
if the first match is not a quip or the first match is not flagged-ready:
say “That doesn’t seem to be a potential topic of conversation.” instead.

Check proto-discussing something with:
if the second noun is not the current interlocutor:
implicitly greet the second noun;
say “(addressing [the current interlocutor])”;
if the current interlocutor is not the second noun, stop the action;
follow the relabel available quips rule;
Let item be the most likely match between the topic understood and “[any flagged-ready quip]”;
If item is a thing:
instead try discussing the item;

instead of proto-discussing it with, try discussing the noun.

proto-discussing is implicit-conversing.

Check saying hello to the player:
say “Talking to yourself is unrewarding.” instead;

Instead of proto-discussing:
try discussing the noun.

Book II - The World

There is room. Bob is a man, here. Janet is a woman, here. The player carries a coin. Janet wears a bandana.

what it might be worth is a quip.
it quip-supplies Bob.
It mentions the coin.

who she represents is a quip.
it quip-supplies Janet.
it mentions the bandana.

who would buy it is a quip.
it mentions the coin and the bandana.

Test problem with “ask Bob about coin / worth / ask Janet about bandana / represents / ask Bob about coin / ask Bob about coin”[/code][/spoiler]

Interestingly enough, the first two commands break if you type them in manually, but not if you run the test suite. In any case, I can run the relabel quips rule after setting the interlocutor during a normal discussion action, but then how can I reparse to only take into account the newly available set of quips?

I’m sorry, I’m still trying to figure out Disambiguation Override. I’m not even sure what questions I should be asking…

I’m not getting any run-time errors. That’s good, right? There’s a bug or two about what happens with the test command in certain IDEs, so maybe that’s happening.

It seems to me that this is not actually doing the filtering we want. When you ask Janet about bandana, it seems to default to the only quip that was available given that Bob was the interlocutor; and I tried adding a secret quip (one that shouldn’t be available) and it wound up getting revealed:

[code]Freya is a woman.

who flipped it is a quip.
it quip-supplies Freya.
it mentions the coin.[/code]

This shouldn’t be available when you ask Bob about the coin, but when I ask Bob about the coin it shows up.

In my tinkering around with this, the basic problem I’ve encountered is that I can’t figure out how to parse the first noun before generating the match list for the second noun. Does the player mean rules seem to do this kind of half-parsing, and the should the game suggest rule from Disambiguation Control did it too. (The problem being that it runs quip-squared times for every disambiguation.) But I don’t know any other way to do it, or any way to pull that half-parsed noun out of the parser internals.

It looks to me as though the asking which do you mean activity might be too late – by then the match list is already generated and it’s just printing the question. Or I could be dead wrong. I’m going by what happens when I try stuff, not by any understanding of what’s happening internally. I don’t really know.

Hm, I had a thought. If the problem with the approach I was using was that it runs the availability rules far too often, maybe we could set a flag to make sure that only happens once per stage. I’ll see if I can get that working with your scenario.

[rant=This is wrong. See below.]OK, the reason that “ask Janet about bandana” is forcing us to “who would buy it” seems to be that the understand lines are still “any flagged-ready quip” rather than “any quip,” and since “who she represents” isn’t flagged-ready when the current interlocutor has just been Bob, the only flagged-ready quip that matches the typed command is “who would buy it” and the disambiguation machinery never runs.[/rant]

…well, I’ve been banging around for a while, and what seems to be the exact same code that worked with my original example refuses to do anything with your code. I’ve tried about everything I can think of and the “Should the game suggest” rule – which is the one that resets the quips and the one that excludes the ones that aren’t available – blithely refuses to run. I’m done for the night; probably it’d be better to get someone who actually understands the internals on the case, instead of me trying to kludge something up with extensions I only one-third understand at best.

OK, now I think I’ve figured out why “ask Janet about bandana” is going straight to “who would buy it” in your original code. This line:

Understand "tell [something] that/about [any flagged-ready quip]" or "ask [something] that/about [any flagged-ready quip]" as discussing it with (with nouns reversed).

is matching before this line:

Understand "tell [something] that/about [any quip]" or "ask [something] that/about [any quip]" as proto-discussing it with (with nouns reversed).

when there’s a matching flagged-ready quip available. When the current interlocutor is Bob, the only flagged-ready quip that mentions the bandana will be who would buy it, so the discussing it with line is matching and proto-discussing isn’t happening.

We can fix that by restricting the first line to discussing it with the current interlocutor:

Understand "discuss [any flagged-ready quip] with [something]" or "say [any flagged-ready quip] to [something]" as discussing it with when the second noun is the current interlocutor. Understand "tell [something] that/about [any flagged-ready quip]" or "ask [something] that/about [any flagged-ready quip]" as discussing it with (with nouns reversed) when the second noun is the current interlocutor. Understand "tell [something] [any flagged-ready quip]" or "ask [something] [any flagged-ready quip]" as discussing it with (with nouns reversed) when the second noun is the current interlocutor.

But disambiguation is still revealing unready quips when I add the bit about Freya at the end. Let me see if I can work that out.

Interesting. As I said before, this only happens when you enter these commands manually, without running the test script:

Yes, this is exactly the problem I was trying to outline on the last page, only put far more succinctly.

That’s a great idea, thanks!

Incidentally, when I run the first few lines again with some debugging text added:

[spoiler]>actions
Actions listing on.

ask bob about coin
Which do you mean, what it might be worth, who would buy it or who flipped it?

worth
[proto-discussing what it might be worth with Bob]
[(1) saying hello to Bob]
[(1) saying hello to Bob - succeeded]

(addressing Bob)
what it might be worth (y), who she represents, who would buy it (y), who flipped it,
[** Programming error: tried to read from -->-1 in the array “parse”, which has entries 0 up to 60 **]
[proto-discussing what it might be worth with Bob - succeeded]

“current interlocutor” = object: Bob

what it might be worth (y), who she represents, who would buy it (y), who flipped it,

ask janet about bandana
Which do you mean, who she represents or who would buy it?

represents
[proto-discussing who she represents with Janet]
[(1) saying hello to Janet]
[(1) saying hello to Janet - succeeded]

(addressing Janet)
what it might be worth, who she represents (y), who would buy it (y), who flipped it,
[** Programming error: tried to read from -->-1 in the array “parse”, which has entries 0 up to 60 **]
[proto-discussing who she represents with Janet - succeeded]

“current interlocutor” = object: Janet

what it might be worth, who she represents (y), who would buy it (y), who flipped it,[/spoiler]Each of those lists shows the availability rulebook running across all the quips, and the result ((y), if available, else blank). So the problem here seems to be that disambiguation across quips is being triggered before the interlocutor is identified and the relabel available quips rule can be called, but it needs to happen after.

Hmm, I straight-up copypasted your code and I’m not getting run-time errors, even when I type the commands in. Maybe we have different versions of some of these extensions.

The problem you just identified with the debug text is the same one I’ve been bumping my head against. In my old code about complimenting people about rocks I can get something to work, but I don’t know why it’s not happening when I try to do the same thing with your code. I think I’m going to try to see if I can get Jon Ingold to explain some stuff to me. If possible, could you post or PM me a version of your code without any of the Disambiguation Override calls in it – what the simplified TC would look like if you weren’t worried about disambiguation? I’m trying to construct a case that shows what I’m trying to do but I can’t figure out exactly what that Check proto-discussing it with line is doing besides calling DO, and if I’m going to use DC I need to strip all references to DO.

BTW I solved the inefficiency problem in the complimenting code; if you run this you’ll see that the availability rules only get called once during the disambiguation process:

[spoiler][code]Include Disambiguation Control by Jon Ingold.

Lab is a room.
Complimenting it on is an action applying to two visible things. Understand “compliment [someone] on [any thing]” as complimenting it on. Understand “compliment [any thing] to [someone]” as complimenting it on (with nouns reversed).
Report complimenting: say “You say ‘That’s a very nice [second noun], [noun].’”

The current interlocutor is a person that varies.
Carry out examining someone: Now the current interlocutor is the noun.
Carry out complimenting someone on something: now the current interlocutor is the noun.

A thing can be relevant or irrelevant.

Instead of examining a relevant thing: say “[The current interlocutor] notices your interest in [the noun].”

The availability rules are a person based rulebook.
First availability rule: now everything is irrelevant.
An availability rule for Janice: Now the red rock is relevant.
An availability rule for Janice: now the green rock is relevant.
An availability rule for Boromir: now the blue rock is relevant.
Last availability rule: Say “Ran availability rules.”

Every turn:
follow the availability rules for the current interlocutor;
if the current interlocutor is not yourself, say “[The current interlocutor] is interested in [the list of relevant things].”

Availability checked is a truth state that varies.
Every turn: now availability checked is false.
To decide whether (subject - a thing) interests (addressee - a person):
if availability checked is false:
follow the availability rules for addressee;
now availability checked is true;
if the subject is relevant, yes.

Interest relates a thing (called subject) to a person (called addressee) when the subject interests the addressee. The verb to be watched by implies the interest relation.

Should the game suggest complimenting someone on a thing that is not watched by the noun: never.

Lab is a room. Janice is a woman in Lab. Boromir is a man in Lab. A red rock is in Lab. A green rock is in Lab. A blue rock is in Lab.

Test me with “compliment janice on rock/red/compliment boromir on rock”[/code][/spoiler]

Hmm, I’m not sure how, I thought I downloaded Mike’s latest version: Disambiguation Override Version 1/121212, and I’m using Conversation Framework Version 10.

Here’s the DO-less code, with the debug text added:

[spoiler][code]“Spelunkery”

[Include Disambiguation Override by Mike Ciul.]
Include Conversation Framework by Eric Eve.

Book I - Machinery

Section 1 - Quips

A quip is a kind of thing.

Quip-supplying relates various quips to various people. The verb to quip-supply (it quip-supplies, they quip-supply, it quip-supplied, it is quip-supplied) implies the quip-supplying relation.

Definition: a quip is character-tailored rather than universally-applicable if it quip-supplies someone.

Mentioning relates various quips to various things. The verb to mention (it mentions, they mention, he mentioned, it is mentioned) implies the mentioning relation.

Understand “[something related by mentioning]” as a quip.

Section 2 - Availability Rulebook, abridged

This is the relabel available quips rule:
[ This rule is very important: it tags quips available before running a new turn. Therefore, the game doesn’t have to reassess availability on the fly during plausibility tests or during parsing. ]
[ On the other hand, it means that we should not test availability or plausibility on our own without first calling this rule. ]
now every quip is flagged-unready;
repeat with item running through quips:
say “[item]”;
if item is available:
say “*”;
now item is flagged-ready;
[Thus, we can also mark quips nonviable in order to skip considering them; if for instance we only want to consider quips relevant to the current scene, or the current character.]
say ", ";

A quip can be flagged-ready or flagged-unready.

The relabel available quips rule is listed after the adjust light rule in the turn sequence rules.
[ The rule needs to appear late in the turn sequence so that if for instance a change of scene changes the identity of the current interlocutor, ]
[ the quips are correctly labeled based on that information. ]

Availability rules are an object-based rulebook. The availability rules have outcomes it is available (success) and it is off-limits (failure).
[ This determines whether a given quip is even allowed for use. It is different from plausibility, which chooses quips that are relevant at the moment, ]
[ but (depending on the system) might not include everything that the player could reasonably choose to talk about at the moment. ]

Definition: a quip is available:
follow the availability rules for it;
if the outcome of the rulebook is the it is available outcome, yes;
no.

The first availability rule (this is the don’t talk to no one rule):
if the current interlocutor is not a person:
it is off-limits; [But this should never happen!]

An availability rule for a quip (called the target) (this is the restriction of quips to special people rule):
if the target is character-tailored and the current interlocutor is not quip-supplied by the target:
it is off-limits;
make no decision;

The last availability rule (this is the generic availability rule):
it is available.

Section 3 - The Discussion Action

Understand the commands “ask”, “tell”, “say”, “answer”, “a”, “t” as something new.

Discussing it with is an action applying to two visible things.

Check discussing something with:
if the second noun is not the current interlocutor:
implicitly greet the second noun;
say “(addressing [the current interlocutor])”;
if the current interlocutor is not the second noun, stop the action;
follow the relabel available quips rule;

Carry out discussing it with:
try discussing the noun.

Discussing is an action applying to one visible thing.

Understand “talk about [any flagged-ready quip]” and “talk [any flagged-ready quip]” as discussing.
Understand the commands “say” and “discuss” as “talk”.

Understand “change the subject to [any flagged-ready quip]” and “change subject to [any flagged-ready quip]” as discussing.
Understand the command “a” as “ask”. Understand the command “t” as “tell”.

Understand “discuss [any flagged-ready quip] with [something]” or “say [any flagged-ready quip] to [something]” as discussing it with when the second noun is the current interlocutor.
Understand “tell [something] that/about [any flagged-ready quip]” or “ask [something] that/about [any flagged-ready quip]” as discussing it with (with nouns reversed) when the second noun is the current interlocutor.
Understand “tell [something] [any flagged-ready quip]” or “ask [something] [any flagged-ready quip]” as discussing it with (with nouns reversed) when the second noun is the current interlocutor.

Report discussing: say “You ask [the current interlocutor] [the noun].”

Section 4 - Catching

Proto-discussing is an action applying to one visible thing. Proto-discussing it with is an action applying to two visible things.

Understand “talk about [any quip]” and “talk [any quip]” as proto-discussing. Understand “change the subject to [any quip]” and “change subject to [any quip]” as proto-discussing.

Understand “tell about [any quip]” and “tell [any quip]” as proto-discussing. Understand “ask about [any quip]” and “ask [any quip]” as proto-discussing.

Understand “discuss [any quip] with [something]” or “say [any quip] to [something]” as proto-discussing it with.
Understand “tell [something] that/about [any quip]” or “ask [something] that/about [any quip]” as proto-discussing it with (with nouns reversed).
Understand “tell [something] [any quip]” or “ask [something] [any quip]” as proto-discussing it with (with nouns reversed).

[Check proto-discussing when the current interlocutor is not visible and the current interlocutor is not nothing:
abide by the can’t converse with absent interlocutor rule.]

[Check proto-discussing:
if the current interlocutor is not a person, say “You aren’t addressing anyone at the moment.” instead;
say “That doesn’t seem to be a topic of conversation at the moment.” instead.]

Before asking which do you mean when proto-discussing:
follow the relabel available quips rule;
[ filter the match list for flagged-ready quips, leaving at least one choice;
if the first match is not a quip or the first match is not flagged-ready:
say “That doesn’t seem to be a potential topic of conversation.” instead.]

Check proto-discussing something with:
if the second noun is not the current interlocutor:
implicitly greet the second noun;
say “(addressing [the current interlocutor])”;
if the current interlocutor is not the second noun, stop the action;
follow the relabel available quips rule;
[ Let item be the most likely match between the topic understood and “[any flagged-ready quip]”;
If item is a thing:
instead try discussing the item;]

instead of proto-discussing it with, try discussing the noun.

proto-discussing is implicit-conversing.

Check saying hello to the player:
say “Talking to yourself is unrewarding.” instead;

Instead of proto-discussing:
try discussing the noun.

Book II - The World

There is room. Bob is a man, here. Janet is a woman, here. The player carries a coin. Janet wears a bandana.

what it might be worth is a quip.
it quip-supplies Bob.
It mentions the coin.

who she represents is a quip.
it quip-supplies Janet.
it mentions the bandana.

who would buy it is a quip.
it mentions the coin and the bandana.

Freya is a woman.

who flipped it is a quip.
it quip-supplies Freya.
it mentions the coin.

Test problem with “ask Bob about coin / worth / ask Janet about bandana / represents / ask Bob about coin / ask Bob about coin”

every turn, showme the current interlocutor.[/code][/spoiler]

I’ve got Version 9 of Conversation Framework! So maybe that’s it. Still, if you’re getting different results depending on whether you type stuff in or use a test command, there must be something funny happening.

Thanks for posting that code. I’ll take a look at it when I get a chance. Looking at it with a slightly clearer head, I think that the check proto-discussing it with rule is going to be too late to do anything in, because no action-processing rule will fire until after all the disambiguation has been taken care of. But I think the parts you commented out are the ones I commented out, so I expect that my attempt will run into the same problems as before. But now I can be more sure that I have the right problems in my code when I’m asking for help. :wink:

OHHHH BABY! I think I have something working. Well, with some hitches.

One hitch is that you probably have to redefine proto-discussing so the nouns go the other way, because I couldn’t get it to happen with the quip as the first noun and the interlocutor as the second noun. I think the Should the game suggest rules can resolve the noun first and then evaluate the second noun based on what the noun is but not vice versa. (The documentation discusses this in relation to the Does The Player Mean rules in section 16.19, and I expect STGS rules work the same way.)

Another hitch is that I don’t understand why it’s working now and why it wasn’t working before, which means that there’s probably all kinds of fragilities involved. And I spent a while goofing up because I forgot that “now the addressee is the last interlocutor checked” isn’t the same thing as “now the last interlocutor checked is the addresee.”

I also kept having to try eight times to get the syntax for the relation in the “Should the game suggest” rule to compile, and I’m not sure why some work and others don’t.

There may also be some type safety issues involving where I demand things to be quips and where I don’t.

The proto-discussing action didn’t actually seem to be redirecting to discussing, but when I changed the “instead of proto-discussing to it about” rule to a “carry out proto-discussing to it about” rule, that seemed to get fixed. IIRC check and instead rules don’t play together nicely, though I’m not sure why they didn’t play nicely in this particular way.

And I got the code working so it doesn’t run the relabel available quips rule for every disambiguation – it keeps track of who the interlocutor was the last time it relabeled available quips, and if that’s still the interlocutor, it doesn’t rerun the rule.

Anyway, I’m happy that it seems to be working now. Hope this is helpful.

Here’s the code, with the rest of the attempted code scattered in the comments:

[spoiler][code]“Spelunkery”

[Include Disambiguation Override by Mike Ciul.]
Include Conversation Framework by Eric Eve.
Include Disambiguation Control by Jon Ingold.

Book I - Machinery

Section 1 - Quips

A quip is a kind of thing.

Quip-supplying relates various quips to various people. The verb to quip-supply (it quip-supplies, they quip-supply, it quip-supplied, it is quip-supplied) implies the quip-supplying relation.

Definition: a quip is character-tailored rather than universally-applicable if it quip-supplies someone.

Mentioning relates various quips to various things. The verb to mention (it mentions, they mention, he mentioned, it is mentioned) implies the mentioning relation.

Understand “[something related by mentioning]” as a quip.

Section 2 - Availability Rulebook, abridged

This is the relabel available quips rule:
[ This rule is very important: it tags quips available before running a new turn. Therefore, the game doesn’t have to reassess availability on the fly during plausibility tests or during parsing. ]
[ On the other hand, it means that we should not test availability or plausibility on our own without first calling this rule. ]
now every quip is flagged-unready;
repeat with item running through quips:
say “[item]”;
if item is available:
say “*”;
now item is flagged-ready;
[Thus, we can also mark quips nonviable in order to skip considering them; if for instance we only want to consider quips relevant to the current scene, or the current character.]
say ", ";

A quip can be flagged-ready or flagged-unready.

The relabel available quips rule is listed after the adjust light rule in the turn sequence rules.
[ The rule needs to appear late in the turn sequence so that if for instance a change of scene changes the identity of the current interlocutor, ]
[ the quips are correctly labeled based on that information. ]

Availability rules are an object-based rulebook. The availability rules have outcomes it is available (success) and it is off-limits (failure).
[ This determines whether a given quip is even allowed for use. It is different from plausibility, which chooses quips that are relevant at the moment, ]
[ but (depending on the system) might not include everything that the player could reasonably choose to talk about at the moment. ]

Definition: a quip is available:
follow the availability rules for it;
if the outcome of the rulebook is the it is available outcome, yes;
no.

The first availability rule (this is the don’t talk to no one rule):
if the current interlocutor is not a person:
it is off-limits; [But this should never happen!]

An availability rule for a quip (called the target) (this is the restriction of quips to special people rule):
if the target is character-tailored and the current interlocutor is not quip-supplied by the target:
it is off-limits;
make no decision;

The last availability rule (this is the generic availability rule):
it is available.

Section 3 - The Discussion Action

Understand the commands “ask”, “tell”, “say”, “answer”, “a”, “t” as something new.

Discussing it with is an action applying to two visible things.

Check discussing something with:
if the second noun is not the current interlocutor:
implicitly greet the second noun;
say “(addressing [the current interlocutor])”;
if the current interlocutor is not the second noun, stop the action;
follow the relabel available quips rule;

Carry out discussing it with:
try discussing the noun.

Discussing is an action applying to one visible thing.

Understand “talk about [any flagged-ready quip]” and “talk [any flagged-ready quip]” as discussing.
Understand the commands “say” and “discuss” as “talk”.

Understand “change the subject to [any flagged-ready quip]” and “change subject to [any flagged-ready quip]” as discussing.
Understand the command “a” as “ask”. Understand the command “t” as “tell”.

Understand “discuss [any flagged-ready quip] with [something]” or “say [any flagged-ready quip] to [something]” as discussing it with when the second noun is the current interlocutor.
Understand “tell [something] that/about [any flagged-ready quip]” or “ask [something] that/about [any flagged-ready quip]” as discussing it with (with nouns reversed) when the second noun is the current interlocutor.
Understand “tell [something] [any flagged-ready quip]” or “ask [something] [any flagged-ready quip]” as discussing it with (with nouns reversed) when the second noun is the current interlocutor.

Report discussing: say “You ask [the current interlocutor] [the noun].”

Section 4 - Catching

Proto-discussing is an action applying to one visible thing. Proto-discussing to it about is an action applying to two visible things.

Understand “talk about [any quip]” and “talk [any quip]” as proto-discussing. Understand “change the subject to [any quip]” and “change subject to [any quip]” as proto-discussing.

Understand “tell about [any quip]” and “tell [any quip]” as proto-discussing. Understand “ask about [any quip]” and “ask [any quip]” as proto-discussing.

Understand “discuss [any quip] with [something]” or “say [any quip] to [something]” as proto-discussing to it about (with nouns reversed).
Understand “tell [something] that/about [any quip]” or “ask [something] that/about [any quip]” as proto-discussing to it about.
Understand “tell [something] [any quip]” or “ask [something] [any quip]” as proto-discussing to it about.

[Check proto-discussing when the current interlocutor is not visible and the current interlocutor is not nothing:
abide by the can’t converse with absent interlocutor rule.]

[Check proto-discussing:
if the current interlocutor is not a person, say “You aren’t addressing anyone at the moment.” instead;
say “That doesn’t seem to be a topic of conversation at the moment.” instead.]

Before asking which do you mean when proto-discussing:
follow the relabel available quips rule;
[ filter the match list for flagged-ready quips, leaving at least one choice;
if the first match is not a quip or the first match is not flagged-ready:
say “That doesn’t seem to be a potential topic of conversation.” instead.]

Check proto-discussing to something about:
if the noun is not the current interlocutor:
implicitly greet the noun;
say “(addressing [the current interlocutor])”;
if the current interlocutor is not the noun, stop the action;
follow the relabel available quips rule;
[ Let item be the most likely match between the topic understood and “[any flagged-ready quip]”;
If item is a thing:
instead try discussing the item;]

[instead of proto-discussing to it about, try discussing the second noun.]
Carry out proto-discussing to it about: try discussing the second noun.

proto-discussing is implicit-conversing.

Check saying hello to the player:
say “Talking to yourself is unrewarding.” instead;

Instead of proto-discussing:
try discussing the noun.

Section 5 - Disambiguation Control-Related Stuff

The last interlocutor checked is a person that varies.
Every turn: now the last interlocutor checked is the player. [Hopefully this effectively serves as a null value, because you can’t talk to yourself. If not you may need an actual null value.]

To decide whether (subject - a quip) interests (addressee - a person):
if the addressee is not the last interlocutor checked: [otherwise we just relabeled quips for that interlocutor and don’t have to do it again]
now the last interlocutor checked is the addressee;
now the current interlocutor is the addressee;
follow the relabel available quips rule;
if the subject is flagged-ready, yes.

Interest relates a thing (called subject) to a person (called addressee) when the subject interests the addressee. The verb to fascinate (he fascinates, they fascinate, it is fascinated) implies the interest relation.

Should the game suggest proto-discussing to a person about a quip that does not fascinate the noun: never.

Book II - The World

There is room. Bob is a man, here. Janet is a woman, here. The player carries a coin. Janet wears a bandana.

what it might be worth is a quip.
it quip-supplies Bob.
It mentions the coin.

who she represents is a quip.
it quip-supplies Janet.
it mentions the bandana.

who would buy it is a quip.
it mentions the coin and the bandana.

Freya is a woman.

who flipped it is a quip.
it quip-supplies Freya.
it mentions the coin.

Test problem with “ask Bob about coin / worth / ask Janet about bandana / represents / ask Bob about coin / ask Bob about coin”

every turn, showme the current interlocutor.[/code][/spoiler]

And here’s the output:

Typing the commands in instead of using the test command also works.

By the way, you can’t type “buy” at the last prompt after the disambiguation question, because the game recognizes it as a verb and goes to processing it as a command instead of a disambiguation. This is a known issue with Disambiguation Control and also with plain old Inform 7. [EDIT: Wait, maybe it’s not a known issue. Well, is now.]

I posted a uservoice suggestion to deal with the issue about typing “buy” at the disambiguation prompt, in case anyone wants to discuss/support it.

Disambiguation Override may not be helpful here. For it to be useful, you would have to have a situation where you can identify the new interlocutor, but you can’t identify the new subject. You’d have to use a grammar line that matches a topic, so you can identify the interlocutor before you try to match the subject. Here’s a quick example:

[code]include disambiguation override by Mike Ciul

Test is a room. Bob is a man in test.

There is a table in Test.

Engaging it about is an action applying to one thing and one topic.

Understand “talk to [someone] about [text]” as engaging it about.

The discussed subject is an object that varies.
The current interlocutor is an object that varies.

Definition: A thing is discussable:
if the current interlocutor is Bob, yes;
no.

Setting action variables for engaging something about:
Now the current interlocutor is the noun;
Now the discussed subject is the most likely match between the topic understood and “[any discussable object]”;
If something matched and the discussed subject is nothing:
say “WARNING: We should have done some disambiguation.”;
Now the discussed subject is the first match;

Check engaging someone about when the discussed subject is nothing:
say “That’s not something you can talk to [the noun] about.”;
stop the action.

Report engaging someone about something:
say “You talk to [the noun] about [the discussed subject].”

Test me with “Talk to Bob about table/Talk to me about table”[/code]

To really do this right, you’d probably want all of your [text] grammar lines to trigger dummy actions that do the following:

  • Check a flag to make sure we’re not already reparsing a command. Issue an error instead if we are.
  • Set the current interlocutor so that the correct quips will be flagged-ready when the command is reparsed
  • Set the flag indicating that we are reparsing the command (to prevent an infinite loop)
  • Reparse the command so that a grammar line with an [any flagged-ready quip] token can handle it

Lost Items does something like that, so I encourage you to look at the code if that’s what you want to do. The relevant part is Chapter 2, but instead of creating a rule “for printing a parser error,” you want to create a rule “before topic-based interlocutor-defining actions,” or whatever you want to call it. You also should look at Chapter 5 for how to skip the turn sequence when you’re going to reparse a command.

Looking at all this code is reminding me that I wanted to roll that functionality into an “iterative parsing” extension. But that really must wait for the next release of I7.

Ok Matt, that seems a bit closer, but now we’re back to the old problem of being able to ask anyone any quip, regardless of availability.

At first, I intended that proto-discussing should always fail – I originally created it to catch malformed commands referencing, for example, currently-unavailable quips. It was just a way to prevent the noun-didn’t-make-sense-in-this-context-error during conversation.

Anyway, I think I got sidetracked and was actually trying to solve the wrong problem, here. Walking up to someone and saying >Ask Bob about (some topic of conversation I don’t know about because I haven’t greeted him to get a list) isn’t a particularly likely scenario. The original bug report/request involved asking about a subject, which is more plausible: Ask Bob about coin makes more sense, even if he’s not yet been greeted.

I think I might just have the case where the player asks a non-interlocutor about a subject redirect to the saying hello action, and keep the proto-discussing action around purely to catch the context error.

Only, now that’s not actually working, either:

[spoiler][code]“Spelunkery”

Include Conversation Framework by Eric Eve.

Book I - Machinery

Chapter 1 - Quips

A quip is a kind of thing. A subject is a kind of thing.

A quip can be one-time or repeatable. A quip is usually one-time.

Quip-supplying relates various quips to various people. The verb to quip-supply (it quip-supplies, they quip-supply, it quip-supplied, it is quip-supplied) implies the quip-supplying relation.

Definition: a quip is character-tailored rather than universally-applicable if it quip-supplies someone.

Mentioning relates various quips to various things. The verb to mention (it mentions, they mention, he mentioned, it is mentioned) implies the mentioning relation.

Understand “[something related by mentioning]” as a quip.

Quip-awareness relates various people to various quips. The verb to recollect (he recollects, they recollect, he recollected, it is recollected) implies the quip-awareness relation.
[This will be set when the characters learn things.]

Chapter 2 - Availability Rulebook, abridged

This is the relabel available quips rule:
[ This rule is very important: it tags quips available before running a new turn. Therefore, the game doesn’t have to reassess availability on the fly during plausibility tests or during parsing. ]
[ On the other hand, it means that we should not test availability or plausibility on our own without first calling this rule. ]
now every quip is flagged-unready;
say “You could ask”;
repeat with item running through quips:
if item is available:
say “[if any quip is flagged-ready],[end if] [item]”; [suggestions hacked in here for demonstration]
now item is flagged-ready;
[Thus, we can also mark quips nonviable in order to skip considering them; if for instance we only want to consider quips relevant to the current scene, or the current character.]
say “.”

A quip can be flagged-ready or flagged-unready.

The relabel available quips rule is listed after the adjust light rule in the turn sequence rules.
[ The rule needs to appear late in the turn sequence so that if for instance a change of scene changes the identity of the current interlocutor, ]
[ the quips are correctly labeled based on that information. ]

Availability rules are an object-based rulebook. The availability rules have outcomes it is available (success) and it is off-limits (failure).
[ This determines whether a given quip is even allowed for use. It is different from plausibility, which chooses quips that are relevant at the moment, ]
[ but (depending on the system) might not include everything that the player could reasonably choose to talk about at the moment. ]

Definition: a quip is available:
follow the availability rules for it;
if the outcome of the rulebook is the it is available outcome, yes;
no.

The first availability rule (this is the don’t talk to no one rule):
if the current interlocutor is not a person:
it is off-limits; [But this should never happen!]

An availability rule for a quip (called the target) (this is the restriction of quips to special people rule):
if the target is character-tailored and the current interlocutor is not quip-supplied by the target:
it is off-limits;
make no decision;

An availability rule for a quip (called the target) (this is the restriction of one-time quips rule):
if the target is a one-time quip and the current interlocutor recollects the target:
it is off-limits;
make no decision;

The last availability rule (this is the generic availability rule):
it is available.

Chapter 3 - The Discussion Action

Understand the commands “ask”, “tell”, “say”, “answer”, “a”, “t” as something new.

Discussing is an action applying to one visible thing.

Understand “talk about/-- [any flagged-ready quip]” as discussing.
Understand the commands “say” and “discuss” as “talk”.

Understand “change the/-- subject to [any flagged-ready quip]” as discussing.

Understand “tell about/-- [any flagged-ready quip]” or
“ask about/-- [any flagged-ready quip]” as discussing.

Understand the command “a” as “ask”. Understand the command “t” as “tell”.

Understand “[any flagged-ready quip]” as discussing.

Carry out discussing:
try the current interlocutor trying discussing the noun.

Carry out someone discussing (this is the everyone has heard rule):
[now every person who can see the person asked recollects the noun.]
if the player can see the actor:
now the player recollects the noun;
now the actor recollects the noun. [This comes after the former line so that we can check whether we’ve repeated ourselves.]

Report discussing: say “You ask [the current interlocutor] about [the noun].”

[Report an actor discussing: unless the actor is the player, say “[The actor] acknowledges [the noun].”]

Check saying hello to the player:
say “Talking to yourself is unrewarding.” instead;

Discussing it with is an action applying to two visible things.

Understand “discuss [any flagged-ready quip] with [someone]” or
“say [any flagged-ready quip] to [someone]” as discussing it with
when the second noun is the current interlocutor.

Understand “tell [someone] that/about/-- [any flagged-ready quip]” or
“ask [someone] that/about/-- [any flagged-ready quip]” as discussing it with (with nouns reversed)
when the second noun is the current interlocutor.

Check discussing something with:
address the second noun, if necessary.

to address (considerant - a person), if necessary:
unless the considerant is the current interlocutor:
say “(addressing [the considerant])”;
implicitly greet the considerant;
if the current interlocutor is not the considerant, stop the action;

Carry out discussing it with:
try discussing the noun.

Chapter 4 - Catching Malformed Commands

Section 4a - talking implicitly about invalid quips

Proto-discussing is an action applying to one visible thing.

Understand “talk about/-- [any quip]” and
“change the/-- subject to [any quip]” and
“tell about/-- [any quip]” and
“ask about/-- [any quip]” as proto-discussing.

Understand “[any quip]” as proto-discussing.

Check proto-discussing (This is the can’t discuss with no one rule):
if the current interlocutor is not a person:
say “You aren’t addressing anyone at the moment.” instead;

Check proto-discussing when the current interlocutor is not visible and the current interlocutor is someone:
abide by the can’t converse with absent interlocutor rule.

Carry out proto-discussing:
say “That doesn’t seem to be a topic of conversation at the moment.” instead.

proto-discussing is implicit-conversing.

section 4b - talking explicitly about invalid quips

proto-discussing it with is an action applying to two visible things.

Understand “discuss [any subject] with [something]” or
“say [any subject] to [something]” as proto-discussing it with.

Understand “tell [something] that/about/-- [any subject]” or
“ask [something] that/about/-- [any subject]” as proto-discussing it with (with nouns reversed).

Rule for asking which do you mean when proto-discussing something with:
stop the action.

Check proto-discussing something with:
if the second noun is not the current interlocutor:
try saying hello to the second noun instead.

instead of proto-discussing something with:
try proto-discussing the noun.

section 4c - asking non-interlocutors about subjects

subjectifying it to is an action applying to two visible things.

Understand “discuss [any subject] with [something]” or
“say [any subject] to [something]” as subjectifying it to
when the current interlocutor is nothing or
the second noun is not the current interlocutor.

Understand “tell [something] that/about/-- [any subject]” or
“ask [something] that/about/-- [any subject]” as subjectifying it to (with nouns reversed)
when the current interlocutor is nothing or
the second noun is not the current interlocutor.

Rule for asking which do you mean when subjectifying something to:
stop the action.

instead of subjectifying something to:
try saying hello to the second noun.

Book II - The World

There is room. Bob is a man, here. Janet is a woman, here. The player carries a coin. Janet wears a bandana.

The coin is a subject. The bandana is a subject.

what it might be worth is a quip.
it quip-supplies Bob.
It mentions the coin.

who she represents is a quip.
it quip-supplies Janet.
it mentions the bandana.

who would buy it is a quip.
it mentions the coin and the bandana.

Freya is a woman.

who flipped it is a repeatable quip.
it quip-supplies Freya.
it mentions the coin.

Test me with “test one / test problem”.
Test one with “ask Bob about coin / worth / ask Janet about bandana / represents / ask Bob about coin”.
Test problem with “ask Bob about coin / ask Janet who flipped it”.

every turn:
showme the current interlocutor;
showme the second noun.[/code][/spoiler]

All of this code seems to work nicely, except that after typing “discuss [subject] with [the current interlocutor]”, subjectifying it to is chosen by the parser, when it should be discussing it with:

A minor issue, since all the regular discussing syntax and action still works fine, but still annoying.

Mike: Thanks, though as mentioned I’m changing my goal somewhat in this thread. Do you think DO could still help here?

I never liked the way greetings worked, and I ended up moving the interlocutor-changing behavior into an activity instead of an action in my Speech Motivations extension.

I think you can do everything you need to do without DO. I’m looking at some possibilities…

I found a hack that could help you, but it’s slow - it doesn’t rely on your caching scheme:

[code]
Test is a room. Bob is a man in test. Sue is a woman in Test.

There is a table in Test. There is a chair in Test.

Discussability relates various things to various people. The verb to be discussable with implies the discussability relation.

The table is discussable with Bob. The chair is discussable with Sue.

Engaging it about is an action applying to one thing and one visible thing.

To decide what object is the parser’s returned noun: (- parser_results–>INP1_PRES -).

Definition: A thing (called the subject matter) is relevant:
if the parser’s returned noun is not a person, no;
decide on whether or not the subject matter is discussable with the parser’s returned noun.

Understand “talk to [someone] about [any relevant thing]” as engaging it about.

Report engaging someone about something:
say “You talk to [the noun] about [the second noun].”

Test me with “talk to bob about table/talk to bob about chair/talk to sue about table/talk to sue about chair”[/code]

The “parser’s returned noun” is stolen out of Ron Newcomb’s Original Parser. You can’t use “the noun” here because when the second noun is being parsed, it actually sets the noun to the object that is being tested.

Alternatively, you could do your caching at the point where the noun is determined. This hack uses side effects to mark what is being parsed. I haven’t checked whether this would be faster or not:

[code]Test is a room. Bob is a man in test. Sue is a woman in Test.

There is a table in Test. There is a chair in Test.

Discussability relates various things to various people. The verb to be discussable with implies the discussability relation.

The table is discussable with Bob. The chair is discussable with Sue.

Engaging it about is an action applying to one thing and one visible thing.

The interlocutor-to-be is an object that varies.

A thing can be flagged-ready or flagged-unready.

Definition: a person is being parsed as the interlocutor:
if it is the interlocutor-to-be, yes;
Now the interlocutor-to-be is it;
Now every thing is flagged-unready;
Now every thing that is discussable with the interlocutor-to-be is flagged-ready;
yes.

Understand “talk to [someone being parsed as the interlocutor] about [any flagged-ready thing]” as engaging it about.

Report engaging someone about something:
say “You talk to [the noun] about [the second noun].”

Test me with “talk to bob about table/talk to bob about chair/talk to sue about table/talk to sue about chair”[/code]

In both of these cases, you would need to write a rule for handling the “noun does not make sense in that context” error for the case where the second noun can’t be discussed with the noun. Or write an mistake action that takes text instead of the second noun.

I haven’t worked through the logic or code here yet, but do you really need both these actions? It looks like you always want subjectifying when the second noun isn’t the current interlocutor, and you always want discussing when the second noun is the current interlocutor, so why not just make one overall action that redirects to the appropriate behavior depending on whether the second noun is the current interlocutor?

For the other code, I was thinking that non-available quips could be blocked at the action stage, but if you’ve got something that gives the desired behavior without relying on all that machinery it’s probably much better. [size=85]But I’m still really proud of having found a way to make it work as well as it did.[/size]

Well, the difference was (and thanks for making me realize I had overlooked this!) the noun in subjectifying is a subject, while the noun in discussing is a quip. Commands valid for the former are a subset of those valid for the latter, because a quip can be referred to by a subject.

Yes, that’s the parsing code: the understand lines provide this availability checking, by only recognizing “any flagged-ready quips”, and so on. The problem is, the use of “any” here leads to the dreaded “context” error whenever this checking breaks down.

Hmm, I wonder if instead, I should just place valid quips into scope while discussing, or maybe use the container-within-an-everywhere-accessible-backdrop method from WI Ex 201, Puff of Orange Smoke…