Inferring the name of the only NPC in the room when ASKING/TELLING?

I’ve gotten some tester feedback that the name of a character should be implied in conversation if you’re alone with them. For instance, instead of saying “TELL BOB ABOUT FROG” when you’re alone with Bob, the player wants to be able to say “TELL ABOUT FROG” instead.

I haven’t the faintest clue as to how to go about approaching this problem. Anybody else know? Thanks!

3 Likes

Conversation Framework by Eric Eve takes care of precisely this kind of thing. You might give it a try or at least steal some code from it.

6 Likes

Thanks, I’ll look into that.

1 Like

This can be done without much code for the case where there will never be more than one NPC in the location.

implicit-telling is an action applying to one topic.
understand "tell about [text]" as implicit-telling.

before implicit-telling:
  let listener be a random visible person who is not the player;
  if listener is nothing, instead say "There's no one here to tell.";
  instead try telling the listener about the topic understood;

If there were multiple people, then ideally you’d want a disambiguation question, and I’m not sure how that could be arranged.

5 Likes

I’d think you could specify a last-person-spoken e.g.

after telling:
    now last-person-spoken is noun;

does the player mean implicit-telling last-person-spoken when last-person-spoken is in location of player:
    it is very likely.

This wouldn’t take care of all of the cases, but it’d take care of the most likely one e.g. assuming you don’t switch between conversations.

3 Likes

I don’t want to harp on something here, but y’all are reinventing what Conversation Framework already does.

3 Likes

I copied and pasted some relevant parts from the Conversation Framework extension. It doesn’t completely work yet, but I need to spend some more time tinkering with it. It seems to correctly detect who the player intends to speak to, but doesn’t actually succeed in asking/telling them anything. Gonna keep messing with it though. It would probably work great if I had included the extension from the beginning and designed my conversations around it, instead of trying to tack it on after the game is more or less finished.

1 Like

AmandaB was tangling with this a while ago (see Making shorthand for "ask about"). I’m not sure that a satisfactory solution was ever attained on that thread.

Here are some factors relevant to the problem:

  • The only easily-reached hook before the attempt to parse the grammar line is the Reading a command activity. Working there tends toward recreation of the parser in miniature to handle special cases, so it is generally not desirable.

  • The built-in asking it about action is defined as applying to one thing and one topic. A grammar line like "ask [text]" won’t be accepted as applicable to that action, because the expectation seems to be that the first token will apply to the first parameter (the thing, i.e. the person being asked).

  • It’s not allowed to write a (with nouns reversed) grammar line that accepts only one parameter, so you can’t write a nouns-reversed grammar line for asking it about that accepts only the topic.

  • For a new action, the parser starts by trying to match the grammar line "ask [text]". Because of a particularity of the parser’s operation, if the last token in the grammar line is [text], no other token can come after it.

  • The supplying a missing noun and supplying a missing second noun activities run only after the grammar line has been matched. It is possible to make use of a rule for supplying a missing second noun with the right action and grammar line definitions, but at that point it is too late to trigger a disambiguation question, which is generated by NounDomain() during parsing.

  • A disambiguation question is generated by NounDomain() if and only if some text in the player’s command can be matched to multiple in-scope objects, and the grammar line is seeking a single object. The prompt occurs in the middle of parsing a single token within a grammar line, and the code responsible is monolithic in structure and not easily modified.

It’s OK to define a new grammar line for asking it about:

Understand "ask [text] of [someone]" as asking it about (with nouns reversed).

This uses the parser’s normal inference code to gracefully handle the case of a single NPC. In cases where there are multiple NPCs, it instead asks for the player to complete the command:

>ASK PARSER DETAILS
Whom do you want to ask that of?

It never generates a “Which do you mean…” question. Note that setting up a command synonym with Understand the command "a" as "ask". results in a probably-undesirable version of this question when that abbreviation is used:

>A PARSER DETAILS
Whom do you want to a that of?

There is a way to handle this at the I6 level. Following is a 6M62 version:

Include (-

Replace LanguageVerb OrigLanguageVerb;

-) before "Commands" in "Language.i6t".

Include (-

[ LanguageVerb i ;
	if (i == 'a//')
		print "ask";
	else
		return OrigLanguageVerb(i);
	rtrue;
];

-) after "Commands" in "Language.i6t".
5 Likes

You still haven’t marked this as solved, so I assume that you’re hoping for something that will ask “Which do you mean…?” questions.

With some deeper modifications, it’s possible to set up “general parsing routines” (GPRs) that modify the player’s command and request reparsing. The I7 compiler gives more latitude to grammar lines including GPRs. With that approach (and some other tweaks) you can get the desired behavior including “Which do you mean…” questions:

Example interaction
Place
You can see Alice and Bob here.

>A PARSING
Who do you mean, Alice or Bob?

>ALICE
Alice makes a few pithy comments about parsing.

>A PARSER MODIFICATION
Alice makes a few pithy comments about parser modification.

>E

Other Place
You can see Carl here.

>A INCLUSIONS
(of Carl)
Carl makes a few pithy comments about inclusions.

>E

Yet Another Place

>A INFORM 6
(of yourself)
You make a few pithy comments about inform 6.

>W

Other Place
You can see Carl here.

>A TWEAKING
(of Carl)
Carl makes a few pithy comments about tweaking.

>W

Place
You can see Alice and Bob here.

>A TWEAKS
Who do you mean, Alice or Bob?

>BOB
Bob makes a few pithy comments about tweaks.

>A TESTING
Bob makes a few pithy comments about testing.

I made a quickie extension for 6M62. Use at your own risk. Note that a 10.1 version is possible but takes some modifications due to new restrictions against the Replace directive and use of the (+ ... +) format for non-constant values.

Easy Abbreviated Asking.i7x (6.4 KB)

3 Likes

Thanks, I appreciate your suggestions. I will check into your examples and solutions. I haven’t marked this as solved yet because the last couple of days I have been receiving tester transcripts highlighting other issues and have been working to fix those issues that I already know how to solve. I’ve still got this issue on my to-do list though and will come back around to it soon.