Workaround for odd "removing it from" behavior?

I sent in a bug report several years ago which was of marked of “cosmetic” severity, and put in the “won’t fix” category. Here’s a link to the bug report: inform7.com/mantis/view.php?id=713

I’m wondering again if there’s some kind of workaround for situations like the one in the MWE below. Specifically I’d like to intervene so that players who try “removing it from” when the noun is already held get the response “You already have that.”, as with “taking” when the noun is already held.

I’ve tried running the test with “actions” and “rules” turned on to see where the hooks are, but this gives no new information. Any ideas?

"Tester"

Space is a room. The box is an open container in space. The sausage is in the box.

test me with "take sausage / again / put sausage in box / remove sausage from box / again".

If you add this:

Understand "remove [something] from [a container]" as removing it from.

then the last response becomes more sensible “But it isn’t there now.”

I’m not sure what the cases are that this change would break. If the sausage is not directly in the box but on a plate that’s in the box, you’ll get the “it isn’t there” response which is not good but that’s the default response anyway.

This is great. Thank you.

Now, out of curiosity: The index shows “remove [things inside] from [something]” as a typed command leading to the removing it from action. Is it “[things inside]” that leads to the original problem? The command “remove [something] from [something]” works because the sausage is always [something] but may not be [things inside]…?

That’s basically it. When the sausage isn’t a “thing inside” then the parser assumes you’re trying to take off (=remove) something called “sausage from box” which doesn’t match any object.

The “things inside” token (“multiinside” in I6) allows the parser to work out “TAKE COIN FROM BOX” when there are several coins present, of which just one is in the box. The problem with adding Juhana’s Understand line is that the parser can start picking a carried coin instead of the one in the box. (Normally the parser prefers carried objects.)

A “does the player mean” rule may fix this. (But I haven’t tested it. Parser disambiguation is messy, and DTPM rules can’t always override.)

In case DTPM rules aren’t working, you can intercept the parser error when the parser is trying to parse a “removing it from” action and print a special message:

[code]To decide what action name is the action-to-be: (- action_to_be -).

For printing a parser error when the latest parser error is the can’t see any such thing error and the action-to-be is the removing it from action and the player’s command includes “from”: say “You can’t see any such thing inside any such other thing.”[/code]

I put in the bit about the player’s command including “from” because otherwise this glomps commands like “remove bloomp” and “take off bloomp.” (If the player has an Erich Fromm T-Shirt and misspells “Remove Erich Fromm T-shirt” they’ll get the wrong answer, but that can’t be helped.) Unfortunately this doesn’t catch “take box off table” which is also removing it from, and wouldn’t catch “take sausage out of box” if you decided to make that removing it from as well. So that might require some finesse.

A problem is that the message I put in stinks, but it has to cover cases like “Remove sausage from box” when the sausage isn’t in the box, “remove bloomp from box,” “remove sausage from bloomp,” and similar. Unfortunately I’m pretty sure there’s no nice way for the parser to tell us that “sausage” made sense and “box” made sense but the sausage wasn’t in the box.

Having poked around Ron Newcomb’s I7 version of the 6G60 parser a bit, there’s an incredible amount of code special-purposed for dealing with the “things inside” and “other things” tokens, which require the parser to jump ahead and figure out what the second noun is before it can figure out what the first noun is–and which are used in a total of eight Understand statements in the Standard Rules.

[Insert harrumph about the difficulty of working with disambiguation.]

I think this could all be modernized by dropping “things inside”/“multiinside” from the Inform grammar, and relying solely on DTPM. (Drop “someone”/“creature”, too, while we’re at it.) I haven’t tried to build that world-model, however.

In my somewhat limited experience, I wouldn’t rely on DTPM for anything except to give me a headache.

We’ve got the headache already, I’m afraid.