Pointless disambiguation

This was unexpected:

[code]Test is a room.

Bob is a man in Test. Sue is a woman in Test.

Understand “mouth” as a person.

test me with “put hand in mouth”[/code]

This prompts the disambiguation question, “Who do you mean, yourself, Bob or Sue?” - of course if you answer, the line still fails to parse - so why is it even trying to disambiguate? Is there any way to avoid it?

I assume there’s some order-of-operations thing deep inside the parser. (It’s not simple left-to-right, as “put mouth in hand” gives the same result.)

Any fix would involve going deep inside the parser and changing things. I expect that side effects would outweigh the intended effects – but I haven’t looked.

Yeah, if I had no reason for sticking my hand in Bob or Sue’s mouth, I’d try to ensure the command reported just putting my hand into my own mouth.

Still, strange. I guess this assumes in a way that a “mouth” is always a “part of” any “man” or “woman” in Inform7?

The supplied code says that “mouth” is just another word for “person”.

The reason why you get asked to disambig before being told it doesn’t work is that an action can be allowed for only a certain noun/second noun, so the parser has to work out which object/s you are referring to before deciding whether it can do what you ask of it with that/those object/s.

I reckon DM4 Ch. IV: Describing and Parsing could provide the definitive answer.

Mm, that’s not the right diagnosis, I don’t think. The command isn’t being rejected based on action/noun/second-noun rules; it’s being rejected because “hand” doesn’t match any object at all. Meanwhile, “mouth” matches several objects and triggers a disambiguation.

In a simplified parser diagram, those both happen at the same stage and therefore it makes sense for the rejection to happen first. In practice, the parser isn’t simple.

I just discovered that the Does the Player Mean Rules don’t run in this case. Once again I’m infuriated that disambiguation could EVER happen without consulting the DPMR. I thought I had this whole thing sorted out because they did run with a simpler test case. But no.

I get that the disambiguation is happening at an earlier stage - perhaps before the exact grammar line has been decided, or at least before the split between noun and second noun has been located. But I don’t get why you’d ever want to do that. It should be a fundamental assumption of the parser: Figure out as much as you can before asking the player to disambiguate.

This is looking more like a bug to me.

Already filed as bug inform7.com/mantis/view.php?id=633 , looks like.

I agree, but in terms of the existing code it probably counts as a feature request.

That bug report is enlightening, and suggests a workaround: It’s specifically a problem with the word “put.” I could do a little hacking around with “when the quoted verb matches ‘put’.”

Untested, but I believe other multi-word commands that share the same first word may have the same problem.

It can only be a problem when the verb takes two nouns, and there aren’t so many of those. Maybe removing it from could be an issue, but I’m not sure what else…

Testing confirms that “get hand from mouth” and “take hand from mouth” produce disambiguation messages as well. Unfortunately, I was wrong about the word “put” because “insert hand into mouth” does too.

Curiously, “show mouth to hand” triggers disambiguation, but “show hand to mouth” doesn’t. Same with “give … to” and “unlock … with.”

[Slightly off topic, but suggested by the discussion]

I understand that Mr. Romney (who, as not too many people are aware, is an IF fan) was relaxing in front of the computer the other day. The following is an excerpt from the transcript of his game:

[size=85]> PUT FOOT IN MOUTH

Which foot do you mean, your foot or the foot of the poor guy that you don’t care about?[/size]

Robert Rothman

That would be the “normal” behaviour.
In the case of “show mouth to hand”, when the parser gets to the word “mouth”, it asks for disambiguation and halts; the same happens in the case of “put mouth in hand”.
In the case of “show hand to mouth”, when the parser gets to the word “hand”, it concludes there is no hand in scope; but in the case of “put hand in mouth”, when the parser gets to the word “hand”, the grammar line requires that the noun match the grammar token “[other things]”, and to ascertain that the noun is other than the second noun, the parser looks ahead and tries to parse the second noun first, which in turn triggers the disambiguation question.
(The same thing happens when the grammar line contains the token “[things inside]”.)

That’s useful. Based on that information, I’m working out a feature request…

Understand X as Y when [action-name]

This syntax would apply the understanding command to each grammar line, setting the value of [action-name] to the appropriate thing each time. If the grammar line doesn’t match the action-name (or if it does, in the case of “not [action-name]”), the Understand line doesn’t apply.

A phrase such as “the current action is [action-name]” or “the action-to-be is [action-name]” or “the action of the current grammar line is [action-name]” would be fine too.

Actually, never mind. DPMR works fine for that. As long as they actually run.

More data:

[code]Test is a room.

Bob is a man in Test. Sue is a woman in Test.

Understand “mouth” as a person.

Does the player mean:
showme the current action;
make no decision;

Does the player mean inserting something into:
say “specific rule for inserting.”;
make no decision;

test me with “put hand in mouth/put mouth in hand/insert hand in mouth/insert mouth in hand/get hand from mouth/get mouth from hand/show hand to mouth/show mouth to hand/give hand to mouth/give mouth to hand/unlock hand with mouth/unlock mouth with hand”

What I see here is that my DPMR didn’t fire because “inserting something into” doesn’t match “inserting nothing into Sue!”

[code]Test is a room.

Bob is a man in Test. Sue is a woman in Test.

Understand “mouth” as a person.

Does the player mean:
showme the current action;
make no decision.

test one with “put mouth in hand / put hand in mouth”.
test two with “put hand in mouth / put mouth in hand”.
Why does the Does the player mean rule run for “put mouth in hand” in test two but not in test one???

That’s freaky. New bug?

And if you change the rule preamble from “inserting something into” to just “inserting,” it does fire.

It also fires if you change it to “inserting an object into.”

Yes, please file one. As best I can tell there’s a reset of cobj_flag missing somewhere.

I’ll file it if you don’t want to Felix, but I’ll give you the chance first - since you discovered it! :smiley: