Problem with "does the player mean" -- compiles but...

I was trying to do something clever: Use a phrase with a relation as part of a “does the player mean” rule to allow the parser to automatically select the “right” object from multiple objects in scope.

The scenario is about model rockets. Individual rocket parts are set up as kinds of objects, and an object of each rocket part kind is a part of every rocket, using nosecones as an example:

A nosecone is a kind of thing. A nosecone is part of every rocket.

Rockets are modeled as containers because you have to put various parts into them prior to launch.

A rocket is a kind of container. A rocket is usually open and openable.

The player starts out with more than one rocket:

The player is holding a rocket called the Yankee. The player is holding a rocket called the Alpha.

Now I want to be able to translate the command “put nosecone on Yankee” into a close action for the Yankee object, but I’m running into a parser issue, because “nosecone” refers to every nosecone in scope.

After thinking for a while, I tried:

Does the player mean putting a nosecone part of the second noun on the second noun: it is very likely.

which compiled but had no effect – “put nosecone on Yankee” still prompts about which nosecone.

I reviewed chapter 16.19, which mentions that the “putting it on” action has special rules and that the second noun is detected first. In this case, the second noun is unambiguous, so I was thinking it would work.

Several other variations that do compile but do not seem to work:

Does the player mean putting a nosecone part of the second noun on the second noun: it is very likely. Does the player mean putting a nosecone on a rocket incorporating the nosecone: it is very likely. Does the player mean putting a nosecone not part of the second noun on the second noun: it is very unlikely. Does the player mean putting a nosecone on a rocket not incorporating the nosecone: it is very unlikely.

And, what finally brought me here, even the brute force approach doesn’t seem to work:

Does the player mean putting nosecone part of Yankee on Yankee: it is very likely. Does the player mean putting nosecone part of Alpha on Alpha: it is very likely.

Any suggestions? Following is complete code, for ease of cross-checking:

[code]“Rockets” by Otis

Launch Site is a room.

A rocket is a kind of container. A rocket is usually open and openable.

A nosecone is a kind of thing. A nosecone is part of every rocket.

The player is holding a rocket called the Yankee. The player is holding a rocket called the Alpha.

[Does not work as desired]
[Does the player mean putting a nosecone part of the second noun on the second noun: it is very likely.]

[Does not work as desired]
[Does the player mean putting a nosecone on a rocket incorporating the nosecone: it is very likely.]

[Does not work as desired]
[Does the player mean putting a nosecone not part of the second noun on the second noun: it is very unlikely.]

[Does not work as desired]
[Does the player mean putting a nosecone on a rocket not incorporating the nosecone: it is very unlikely.]

[
[UNPRODUCTIVE BRUTE FORCE APPROACH]
Does the player mean putting nosecone part of Yankee on Yankee: it is very likely.
Does the player mean putting nosecone part of Alpha on Alpha: it is very likely.
]

Instead of putting a nosecone (called subject nosecone) on a rocket (called the subject rocket):
if the subject nosecone is not part of the subject rocket, instead say “That’s the wrong nosecone!”;
try closing the subject rocket instead.

After closing a rocket (called the subject):
say “Being very careful, you slide the nosecone to fit snugly onto the top of [the subject].”

[The following rule just demonstrates that the phrase ‘nosecone part of [rocket]’ can be recognized in some cases.]
When play begins, say “[random nosecone part of Yankee] -> [Yankee], [random nosecone part of Alpha] -> [Alpha].”

test me with “put nosecone on Yankee / put yankee’s nosecone on yankee / open yankee / put alpha’s nosecone on yankee”
[/code]

We debugged this on the MUD: it turned out the “does the player mean” rule runs for the wearing action, because the parser detects the ambiguity when it’s processing the line for “put [something] on”. I believe this is a parser bug: all the routines that influence disambiguation are called in the context of a grammar line that can’t possibly match. Instead, the parser should try to finish matching the rest of the grammar line first, and only ask a disambiguation question if ambiguity is the only thing stopping the command from being valid.

a possible workaround but it works only for the Yankee and Alpha rockets.
more rockets will have to be coded accordingly.

“Rockets”

after printing the name of a transparent container:
omit contents in listing.

Launch Site is a room.

The player is holding a closed, transparent container called the Alpha rocket.
The player is holding a closed, transparent container called the Yankee rocket.

the Alpha’s nosecone is in the Alpha Rocket.
understand “cone” as the Alpha’s nosecone.

the Yankee’s nosecone is in the Yankee Rocket.
understand “cone” as the Yankee’s nosecone.

understand “Put nosecone on rocket” or “cone on rocket” as a mistake
(“Do you mean the Alpha’s nosecone or the Yankee’s nosecone?”)

understand “Take nosecone” or “take cone” as a mistake
(“Do you mean the Alpha’s nosecone or the Yankee’s nosecone”)

before taking the Alpha’s nosecone when the Alpha rocket is closed:
now the Alpha rocket is open;
say “You remove the nosecone from the Alpha Rocket.”;
now the Alpha’s nosecone is carried by yourself instead.

before taking the Yankee’s nosecone when the Yankee rocket is closed:
now the Yankee rocket is open;
say “You remove the nosecone from the Yankee Rocket.”;
now the Yankee’s nosecone is carried by yourself instead.

before putting something (called the attachment) on the Yankee:
if the attachment is the Alpha’s nosecone:
say “That’s the wrong nosecone!” instead;
otherwise:
now the Yankee’s nosecone is in the Yankee;
now the Yankee is closed;
say “Very carefully you put the Yankee’s nosecone on the Yankee rocket.” instead

before putting something (called the attachment) on the Alpha:
if the attachment is the Yankee’s nosecone:
say “That’s the wrong nosecone!” instead;
otherwise:
now the Alpha’s nosecone is in the Alpha;
now the Alpha is closed;
say “Very carefully you put the Alpha’s nosecone on the Alpha’s rocket.” instead

test me with “put nosecone on Yankee/put yankee’s nosecone on yankee/put alpha’s nosecone on yankee”

understand "Take nosecone" or "take cone" as a mistake
("Do you mean the Alpha's nosecone or the Yankee's nosecone")

This is bad I7 practice for a couple of reasons.

  1. It will not catch “take the cone”, “get nosecone”, “pick the nosecone up”, or any other such synonyms.

  2. If the player hits it and then follows up by just typing “alpha”, the parser will choke, because it doesn’t know it’s doing disambiguation.

I actually found something of a workaround to this (thanks to vaporware’s guidance on the source of the problem):

Understand the command "put" as something new. Understand "put [other things] in/inside/into [something]" as inserting it into. Understand "put [other things] on/onto [something]" as putting it on. Understand "put down [held things]" as dropping. [*] Understand "put [held things] down" as dropping.[*] Understand "put on [held thing]" as wearing.[*] Understand "put [held thing] on" as wearing. [*]

Note the change of the token from “preferably held” type to just “held” for those commented with an asterisk (the wearing and dropping actions).

Also included are the following key lines:

Definition: A thing is rocket-component if it is part of a rocket and it is not a rocket.

Does the player mean putting a rocket-component thing (called piece) on the holder of the piece: it is very likely.

Does the player mean inserting a rocket-component thing (called piece) into the holder of the piece: it is very likely.

With these changes, trace lines show that wearing and dropping grammar are still evaluated prior to reaching the inserting it into or putting it on grammar, the inserting it into or putting it on grammar is properly guided by the “does the player mean” rules provided, and one of the desired actions (putting it on or inserting it into for the correct nosecone/rocket combination) is generated. Both inserting it into or putting it on are intercepted with instead rules and converted to a close action for the rocket.

I understand that I have sacrificed the behavior in which something not held will be automatically taken if you try to wear or drop it, but I think that’s OK in this case.

I’d really like to understand a little more deeply what is going on here. What is it exactly about the preferably held token that makes a difference? Is it actually a disambiguation question for the implicit take that the user sees with my original code?

1 Like

Well, I’ll be! The workaround worked better than I thought it did: It doesn’t sacrifice normal automatic-taking behavior for unheld things the player attempts to wear or drop, after all.

I still don’t understand precisely why this workaround works at all. If anyone who understands the internals can explain it, I would be appreciative. In the meantime, I’m happy it works and I hope someone else can make use of this example.

[code]Launch Site is a room.

Some safety goggles are a wearable thing in Launch Site.

A rocket is a kind of container. A rocket is usually open and openable.

A nosecone is a kind of thing. A nosecone is part of every rocket.

The player is holding a rocket called the Yankee. The player is holding a rocket called the Alpha.

Definition: A thing is rocket-component if it is part of a rocket and it is not a rocket.

Does the player mean putting a rocket-component thing (called piece) on the holder of the piece: it is very likely.
Does the player mean inserting a rocket-component thing (called piece) into the holder of the piece: it is very likely.

Understand the command “put” as something new.
Understand “put [other things] in/inside/into [something]” as inserting it into.
Understand “put [other things] on/onto [something]” as putting it on.
Understand “put down [held things]” as dropping. [modified from Standard Rules]
Understand “put [held things] down” as dropping.[modified from Standard Rules]
Understand “put on [held thing]” as wearing.[modified from Standard Rules]
Understand “put [held thing] on” as wearing.[modified from Standard Rules]

Instead of inserting a nosecone (called subject nosecone) into a rocket (called the subject rocket):
if the subject nosecone is not part of the subject rocket, instead say “That’s the wrong nosecone!”;
try closing the subject rocket instead.

Instead of putting a nosecone (called subject nosecone) on a rocket (called the subject rocket):
if the subject nosecone is not part of the subject rocket, instead say “That’s the wrong nosecone!”;
try closing the subject rocket instead.

After closing a rocket (called the subject):
say “You slide the nosecone to fit snugly onto the top of [the subject].”

test me with “trace / put nosecone on Yankee / open yankee / put alpha’s nosecone on yankee / wear goggles / drop goggles / rules / drop goggles”[/code]

(How embarrassing.)

Actually, it does sacrifice those things. My test scenario didn’t use the “put on” or “put down” grammars that were written out. sp of course everything works as usual.

There is an unpleasant side effect, in that if the player tries to “put down goggles” while not holding the goggles, the parser claims there is no such thing as any goggles. You can see the difference with:

test me with "trace / put nosecone on Yankee  / open yankee / put alpha's nosecone on yankee  / put on goggles / wear goggles / put down goggles / drop goggles / rules / drop goggles"

The best option I see is to let the player know their intent was understood but won’t work in this scenario, as with:

[code]Understand “put [something] on” or “put on [something]” as a mistake (“Sorry, that syntax for trying to wear something has been disabled in this scenario. Try using the command ‘wear’ instead.”).

Understand “put [something] down” or “put down [something]” as a mistake (“Sorry, that syntax for trying to drop something has been disabled in this scenario. Try using the command ‘drop’ instead.”).[/code]

Not perfectly solved, but good enough for now, I guess.

I’ve actually has this problem where “does the player mean” rules fail to work as we want them to. It turns out that the solution is actually a lot simpler that it seems. Try this.

[code]“Rockets” by Otis

The Launch Site is A Room.

Some safety goggles are a wearable thing in Launch Site.

A rocket is a kind of container. A rocket is usually open and openable.

A nosecone is a kind of thing. A nosecone is part of every rocket.

The player is holding a rocket called the yankee. The player is holding a rocket called the alpha.

A does the player mean rule when the noun is a nosecone and the second noun is a rocket:
if the noun is part of the second noun begin;
it is very likely;
otherwise;
it is very unlikely;
end if.

Check putting a nosecone on a rocket:
if the noun is not part of the second noun, say “That’s the wrong nosecone!” instead;
try closing the second noun instead.

After closing a rocket: say “Being very careful, you slide the nosecone to fit snugly onto the top of [the noun].”.

Test me with “put nosecone on Yankee / open yankee / put alpha’s nosecone on yankee / put on goggles / wear goggles / put down goggles / drop goggles”.[/code]

For some reason, the extra bits on the “does the player mean” rules are not being recognised and therefore the rule isn’t firing. Replacing them with a “when” statement bypasses this and allows the rule to fire.

Hope this helps.

A does the player mean rule when the noun is a nosecone and the second noun is a rocket:

See vaporware’s original explanation, on the 19th. There’s a parerser bug whereby the DTPM rules are being run for the “wearing” action instead of the “putting on” action. Your code works around this, because it never checks the action, only the two nouns.

True, but in this situation it appears to be the optimal workaround as it doesn’t involve interfering with the vocabulary of the “dropping” action or the “wearing” action. Also, it seems sensible here to assume that the player will likely mean the nose cone that is part of the rocket for any action not just the “putting it on” action, even for an action that does nothing useful and just gives a failure message. Personally, I would prefer to use “does the player mean putting a nosecone on a rocket”. However, what works, works.

Also, when I got this problem, it was with the “inserting it into” action rather than the “putting it on” action, so the parser bug here may be more general than first thought.

That is great, climbingstars!

The same idea can be phrased quite succinctly in a one-liner that seems to solve all my problems:

Does the player mean doing something to something while the noun is part of the second noun: it is likely.

Thank you very much, and thanks to zarf, as well, for giving more detail on why it works.