Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[Inform] another pet peeve

9 views
Skip to first unread message

Michael S Gentry

unread,
Sep 17, 1998, 3:00:00 AM9/17/98
to
I've got another pet peeve about the Inform parser.

[begin transcript]

>I
You are carrying a 9mm automatic pistol and a hard grudge against the fat
bastard who stole your dog.

Your fingers tighten on the trigger as Benson leers at you. "Come on," he
taunts. "Shoot me. I dare ya to shoot me!"

>SHOOT BENSON
What do you want to shoot Benson with?

>WITH PISTOL
You can't see any such thing.

[punch computer]
[end transcript]

I do this all the time: it's the natural way I would respond to such a
question. The game always burns me because it reads the total input as SHOOT
BENSON WITH WITH PISTOL. ("'With pistol'?" thinks the parser, "What's a
'with pistol'? I'll check the name properties of everything in scope, I
guess, but I'm pretty sure there's no such thing as a 'with pistol'.")

I'd like to tweak it so that whenever the game asks the player to provide an
indirect object, it will allow the player to type the preposition as the
first word of the input. (Basically, if the first word of the player's
answer is identical to the word used at the end of the computer's question,
then skip over that word and start parsing from there.)

But the parser routine is long and complicated and I have a headache and my
wife stole the Advil. Does anyone happen to know which part of the parser
handles input for the "please specify an indirect object" question, and can
they point me in its general direction?

Much obliged,

--M
================================================
"If you don't eat your meat, you can't have any pudding.
How can you have any pudding if you don't eat your meat?"


Irene Callaci

unread,
Sep 17, 1998, 3:00:00 AM9/17/98
to
And, while we're at it, can someone also explain how to emulate
this ability of the parser's to handle partial input? Sometimes
I want my NPC to ask a disambiguating question instead of the
parser, but I don't know how to handle it without requiring the
player to type in the entire command again. I think it has
something to do with NounDomain and REPARSE_CODE. (How's that
for vague?)

Example:

>SAM, GIVE ME THE BALL

Sam eyes you warily. "Yeah? Which one? The red ball or the
green ball?"

>RED

Sam tosses the red ball into the fire. "Get it yerself,"
he sneers.


irene

On Thu, 17 Sep 1998 15:40:47 -0400, "Michael S Gentry"
<edr...@sprynet.com> wrote:

[example snipped]

Kory Heath

unread,
Sep 18, 1998, 3:00:00 AM9/18/98
to
Michael S Gentry wrote:
> Does anyone happen to know which part of the parser
> handles input for the "please specify an indirect object" question, and can
> they point me in its general direction?

The code you're looking for starts at line 2170 of parserm.h (library
version 6/7).

Although I would never dream of discouraging you from hacking the Inform
libraries :), I would urge you hack carefully. The code here is a bit
subtle, and it wouldn't be difficult to break.

Technically, the functionality here isn't "ask the player to specify an
indirect object" (though that's often what it amounts to). The actual
functionality is "ask the player to finish an incomplete command". For
instance, if the player enters "TAKE" (and there is more than one
takeable object around), it's considered an incomplete command (just as
"SHOOT BENSON" is), and the parser asks "What do you want to take?"
Basically, the general form of the question is "What do you want to x?",
where x is the exact command entered (along with inferences, like the
word 'with' in your example). [1] As you've surmised, the answer is
pasted onto the end of the original command (with inferences), and the
whole thing is reparsed.

What you're wanting to do is to compare the beginning of the new input
with the ending of the previous input, and to filter out any overlap.
The tricky part is that you'll probably have to do this comparison on
the character level, not the word level, because the inferences get
pasted onto the end of the original input character-by-character. It
could be done, of course, but it wouldn't be pretty. Also, there may be
some odd cases in which this filtering would happen, but you don't want
it to. I can't think of any off the top of my head - which is exactly
why it worries me. :)

Anyway, you can at least take a look at the code and see what you think.

[1] The question might also be "Whom do you want to x?", or "What do
you want the [actor] to x?", etc. The text for these messages is in
English.h, Miscellany #48 and #49.

--
Kory Heath
khe...@best.com

Kory Heath

unread,
Sep 18, 1998, 3:00:00 AM9/18/98
to
Irene Callaci wrote:
> And, while we're at it, can someone also explain how to emulate
> this ability of the parser's to handle partial input? Sometimes
> I want my NPC to ask a disambiguating question instead of the
> parser, but I don't know how to handle it without requiring the
> player to type in the entire command again. I think it has
> something to do with NounDomain and REPARSE_CODE. (How's that
> for vague?)

There are actually two different kinds of questions the parser can ask,
and they are indeed both generated by NounDomian. The kinds you're
referring to are "disambiguation" questions, like "Which do you mean,
the red ball or the green ball?" The other questions are "incomplete
input" questions, which are asked when there isn't enough input to even
begin parsing for a noun. These are questions like "What do you want
Sam to pick up?" (Check my other post in this thread for a bit more info
about these questions.) You might be interested in changing these
messages, too:

>SAM, GIVE
Sam folds his arms belligerently. "Yeah? Maybe I will, maybe I won't.
What do you want?"


Since you essentially only want to change some messages, you may be able
to do what you want by adding some code to the lm (library messages)
object. Take a look at Miscellany #45, #46, #48, and #49 in English.h,
which is where these questions are actually printed. You can check the
'actor' variable, and if it's not equal to the player, you can send the
actor a message to allow it to print it's own "Which do you mean" or
"What do you want to ..." text.

It may get messier than this, but it's a start.

--
Kory Heath
khe...@best.com

Andrew Plotkin

unread,
Sep 18, 1998, 3:00:00 AM9/18/98
to
Michael S Gentry (edr...@sprynet.com) wrote:
> I've got another pet peeve about the Inform parser.

> [... transcript]

> I do this all the time: it's the natural way I would respond to such a
> question. The game always burns me because it reads the total input as SHOOT
> BENSON WITH WITH PISTOL. ("'With pistol'?" thinks the parser, "What's a
> 'with pistol'? I'll check the name properties of everything in scope, I
> guess, but I'm pretty sure there's no such thing as a 'with pistol'.")
>
> I'd like to tweak it so that whenever the game asks the player to provide an
> indirect object, it will allow the player to type the preposition as the
> first word of the input. (Basically, if the first word of the player's
> answer is identical to the word used at the end of the computer's question,
> then skip over that word and start parsing from there.)

Good idea. You're also correct that it's a headache. (You may have to
check more than the most recent word; if the grammar line is "get noun out
of second", you'd have to allow "get fork" / "out of drawer". And so on.
Awkward example, but the principle holds.)

The relevant piece of library -- search for calls of "Keyboard" in
parserm.h. There are three: the main command entry, the "Which you do
mean, the A or the B...?" entry, and the "What do want to verb...?" entry.
Obviously, you want the third.

Checking the first word is easy; there's already code there to check if
the first word is a verb (so it can accept it as a full command, instead
of a disambiguation.)

The tricky part will be figuring out the last N prepositions in the
grammar line. The parser jumps *to* that Keyboard() call with the line

if (match_from > num_words) jump Incomplete;

So you could probably work with match_from... except I think match_from
counts words in the player's input, not the grammar line. Maybe look at
the code a little lower down that talks aobut "gluing in a pronoun".

Oh, heck, maybe you'll want to hack the second Keyboard() call as well.
(The "Which you do mean, the A or the B...?" entry.)

Have fun.

--Z

--

"And Aholibamah bare Jeush, and Jaalam, and Korah: these were the
borogoves..."

Andrew Plotkin

unread,
Sep 18, 1998, 3:00:00 AM9/18/98
to
Kory Heath (khe...@best.com) wrote:
> Irene Callaci wrote:
> > And, while we're at it, can someone also explain how to emulate
> > this ability of the parser's to handle partial input? Sometimes
> > I want my NPC to ask a disambiguating question instead of the
> > parser, but I don't know how to handle it without requiring the
> > player to type in the entire command again. I think it has
> > something to do with NounDomain and REPARSE_CODE. (How's that
> > for vague?)

> [good explanation snipped]


>
> Since you essentially only want to change some messages, you may be able
> to do what you want by adding some code to the lm (library messages)
> object. Take a look at Miscellany #45, #46, #48, and #49 in English.h,
> which is where these questions are actually printed. You can check the
> 'actor' variable, and if it's not equal to the player, you can send the
> actor a message to allow it to print it's own "Which do you mean" or
> "What do you want to ..." text.

Sounds good.

I've devoutly wished for a really general way to get into the
disambiguation system from action code. That is:

> TOUCH BALL
As you reach for it, you see that it's actually two hemispheres stuck
together. Which do you mean, the left hemisphere or the right hemisphere?

And actually do this in the ball's "before" clause. (Again, contrived
example, but I've really wanted to do this.)

It would be sort of possible to call Keyboard() myself and parse the
result as a noun, but you really want the main parser code to handle it.
(The parser handles all the wonky details: accepting a new command instead
of the disambiguation noun, making sure "again" works next turn, setting
the damn pronouns... I'm sure there are other details I don't understand.)

0 new messages