T3: Generic People Words

Here’s an odd little problem. I have two male NPCs. One is named (Leo), the other is simply “the old man.” I have given the old man a vocabLikelihood of 15, so that when both are in scope and the player refers to ‘man’, the parser will infer that it’s the old man. But I still get this:

Leo thinks ‘man’ refers to himself. Or rather, in this situation the parser thinks so.

I could give Leo vocabWords ‘(man)/leo’, but if I do that, then ‘x man’ when the old man isn’t present produces “You see no man here.” Obviously a bad idea.

So how do I help the parser understand that ‘man’ refers exclusively to the old man when he’s in scope? I could do this with cmdDict.addWord and cmdDict.removeWord, calling them each time the old man moves in and out of scope, but that would be messy and error-prone. Is there an easier way?

Maybe in the verify function for ask on Leo?

For topic matches, you can use breakTopicTie on the topic you’d like to match.

class Man: Person
	vocabWords = 'man'
	isHim = true

oldman: Man 'old man' 'old man' @lab
	"The old man glares at you. "
	vocabLikelihood = 15

bob: Man 'bob' 'Bob' @lab
	"It's Bob! "

	isProperName = true

+ AskTopic @bob
	"\"Oh, well, there's not much to say about me.\" "

+ AskTopic @oldman
	"\"That guy gives me the creeps.\" "

	breakTopicTie(matchList, topic, fromActor, toks) {
		if (toks.indexOf('man')
			&& oldman.getOutermostRoom == bob.getOutermostRoom)
			return self;
			return nil;

I just now got around to trying this code, and it doesn’t seem to work. I tried it several different ways, including putting it (with a suitable reversal of self and nil as the return value) in BOTH of the topics.

My conclusion is that breakTopicTie is not being called at all because the parser has already decided that it’s more likely you’re asking the NPC about himself.

The solution, once I researched it, turns out to be easier – giving the NPC’s TopicEntry for himself a matchScore of 75. This causes that topic to be less preferred when there’s a choice.

That will work up until the player knows about the old man, at which point the topic for the old man will unlock. Then >ask leo about man will always refer to the old man, even if he is not in scope.

That’s probably fine but I thought you were after something else.

No, that’s what I wanted. Sorry for the confusion.

It doesn’t really matter that the NPC always thinks ‘man’ refers to the old man, because no player is going to type ‘ask leo about man’ or ‘ask man about himself’ referring to Leo. Leo is a friend of the PC’s, so that would be a very unnatural way to phrase it. In that context, ‘man’ can always unambiguously refer to the old man without any confusion arising.

That makes more sense than what I implemented. :slight_smile:

It wasn’t a total loss, since I found and fixed a small bug in the new breakTopicTie() method while putting my code together.