Disambiguation for NPC actions

What’s the trick to telling Inform that NPCs should default to using a carried object rather than one they’re not carrying? I want to do something like:

Does the player mean asking a person to try doing something to something which is carried by the person: it is likely.

Pros: This compiles! Cons: It doesn’t actually work.

I think it’s the classic pitfall that Inform doesn’t know that you intend to refer to that very same person in the latter part; so you need to give the person a temporary name and refer back to it, like this:

Does the player mean asking a person (called P) to try doing something to something which is enclosed by P: it is likely.

(And I’d probably use enclosed, as above, instead of carried, to include the indirectly carried things. But of course that depends on whether that’s intended in the game.)

3 Likes

Excellent idea! Still doesn’t work, though — the NPC insists on trying to give me an identical object that I already have, instead of the one they are carrying. (X, GIVE ME Y works fine, though.)

Hmm, okay. It worked when I tested it in a minimal scenario, but I didn’t test it with a giving action, so there is probably some special case going on.
Behind the scenes, Inform converts “ask NPC for foo” into “NPC, give me foo”. Maybe the conversion doesn’t play well with the disambiguation rule.

Spoiler for Improv: Origins below:

>**i** 

You are carrying:

a rubber band

a ballpoint pen

a paper clip (slightly bent)

>**actions**

Actions listing on.

>**ask pastiche for band**

[asking Pastiche for the rubber band]

[(1) asking Pastiche to try giving the rubber band to yourself]

(Pastiche first taking the rubber band)

[(2) asking Pastiche to try taking the rubber band - silently]

[(3) asking Pastiche to try self-failing - silently]

She looks confused. "I don't think I can do that. At least, I'm pretty sure. As my mom always tells me, sometimes my right hand doesn't know what my left hand is doing."

[(3) asking Pastiche to try self-failing - silently - failed]

[(2) asking Pastiche to try taking the rubber band - silently - failed]

[(1) asking Pastiche to try giving the rubber band to yourself - failed the carrying requirements rule]

[asking Pastiche for the rubber band - failed the carrying requirements rule]

>**pastiche, give me band**

[asking Pastiche to try giving the rubber band to yourself]

"Sure thing."

Pastiche hands the rubber band to you.

This should work (worked for me just now when I tried it out):

Does the player mean asking someone for something which is enclosed by the player:
	it is unlikely.

That doesn’t work for me, either. Did you try it with two indistinguishable objects of the same kind? I’m wondering if that could be what’s causing the problem.

Well, I wasn’t sure what you meant with “an identical object” in the post further above, so at first I just tested it with two similarly-named things (but not of a special kind) which would ordinarily cause a disambiguation question, like “red foo” and “blue foo”.

Now I tested it again with objects of the same kind, and it works for me, too. Here’s a small scenario:

A foo is a kind of thing.
Understand "foo" as a foo.

Persuasion rule for asking a person to try giving something to someone:
	persuasion succeeds.

The block giving rule is not listed in any rulebook.

Does the player mean asking someone for something which is enclosed by the player:
	it is unlikely.

The Lab is a room.

Robby is a person in the lab.

The greeno is a foo.
Robby carries the greeno.

The yellowo is a foo.
The player carries the yellowo.

The output is:

>x foo
(the yellowo)
You see nothing special about the yellowo.

(Defaults to the player’s foo.)

>ask robby for foo
(the greeno)
Robby gives the greeno to you.

(Uses Robby’s foo. The result for “ROBBY, GIVE ME FOO” is the same.)

That seems to be the desired result, I think?
If it doesn’t capture your scenario, then I’d need to see a minimal example, otherwise I’m stabbing a bit in the dark here.

Edited to add: I also tested it with two unnamed objects of the same kind:

Robby carries a foo.

The player carries a foo.

Works too:

>ask robby for foo
Robby gives the foo to you.

>i
You are carrying:
  two foos

I think Neil’s case is different because instead of differently-named foos, there are just multiple generic foos (so like, instead of “The yellowo is a foo. The player carries the yellowo.” it’d be "The player carries a foo). When I try your example with that change pasted in, though, it still works correctly. So there must be something else going on that’s confusing the parser?

This is very consistent with my experience of working with generic instances of kinds, by the way. My first game had a large puzzle where you need to hide a bunch of objects around a room, and I don’t think I ever squashed a bug where sometimes you’d type TAKE THING FROM DESK and the thing that would show up in your inventory was actually the one from under the bed even though I swear there is no possible way that could happen.

EDIT: cross-posted.

Yeah, the Case of Robby’s Two Foos above indicates that I did something special to trigger this behavior. I’ll investigate further — thanks, StJohn and Mike!

The asking it for action is a little unusual in that it’s really only a gateway to an asking someone to try giving it to action. It’s a separate action because the meaning of the action parameters actor, noun and second noun get switched around over the course of action processing.

Step 1 is the action the player asking Pastiche for the rubber band. This is considered to be a spontaneous action, not a command. There is no action requester. The actor is the player. The noun is Pastiche. The second noun is a whichever rubber band is decided as the best candidate from those in scope.

Step 2 is the action asking Pastiche to try giving the rubber band to the player. This is considered to be a command. The action requester is the player. The actor is Pastiche, because she was the noun of the asking it for action. The noun is whichever rubber band was decided upon, because that was the second noun of the asking it for action. The second noun is the player.

Step 3 is the action Pastiche giving the rubber band to the player, which happens if persuasion succeeds. The action parameters are all identical to step 2 except now there is no action requester.

Your original does the player mean (DTPM) rule could only apply to step 2 because it specifies asking someone to... (i.e. it must be a command), but step 2 doesn’t involve any disambiguation, so the rule won’t actually ever apply.

In the case of this action, it’s probably best not to try to rely on a general DTPM rule. It may be better to make use of positive weighting instead of negative. For example:

Does the player mean asking a person (called P) for something enclosed by P (this is the people assume PC is asking for things that possess rule):
    it is very likely.

Does the player mean asking a person (called P) for something not enclosed by a person (this is the people assume PC is asking for something nobody has rule):
    it is likely.

In combination, these make things in the area preferred over things held by anyone at all, and things held by the person responding over things in the area.

To head off the nonsense of an NPC trying to take something already held by the PC, you can install a check rule:

Check asking a person (called P) for something enclosed by the player (this is the no point in asking someone for something already possessed rule):
    say "But you're already in possession of [the second noun]!" instead.
3 Likes