mud grammar

Carter T Shock ctso at umiacs.umd.edu
Tue Mar 11 04:34:37 CET 1997


Hrmmm... I think we have a misunderstanding as to what a "context free
grammar" is.

As far as the purple dinosaur goes, in all of the examples, whether you are
shooting in the next room, the left eye or whatever, the meaning of "shoot"
doesn't change. lex/yacc grammars can easily capture the meaning of
modifiers such as "with" or "in". The "whisper"/"say" example parses nicely
as well.

I agree that some commands should not be useful in all parts of the mud. It
seems unfair to the player to have the mud simply refuse to recognize your
news command when not in the post office. For a consistant interface with
the player shouldn't the mud recognize the syntax of the command as valid,
but simply deny the command's execution (tell them that the command doesn't
work here as opposed to pretending the command doesn't exist). A agree
wholeheartedly with the lament about whether to use "push" or "press" for
the damned button (that may or may not respond to the keyword "button", but
that's another issue entirely). It is the grammar that is context free;
individual sentences are of course context sensitive. (or am I _really_
making a fool of myself?)

The point about using a natural language processor is also well taken, but
I don't think that's what you've implemented there. If you allowed natural
language, I should be able to use any synonym of shoot and purple
dinosaur...

Let's consider when the user tries:

"use gun on purple dinosaur"

This is an example of context sensitive grammar. What does "use" mean?
Shoot the dinosaur? Whack him over the head with it? Scratch his tummy with
the butt of the rifle? It's ambiguous. Natural language processors try to
do the "right thing" in these situations (is the dinosaur friend or foe? Is
the rifle loaded? Are you a decent shot? Does his tummy itch?).
If, however, you allow exactly one meaning for "use" (let's say it means
"shoot") then the sentence is unambiguous and the grammar context free.

Finally, don't think that I'm some devotee of lex/yacc. No reason you can't
cook up your own parser. I'm just suggesting that it offers a relatively
easy and structured implementation of a grammar. Also, once created, it's
easy to modify the grammar (change meanings, add new verbs, etc). It is
similar to the question of how you handle your mud's contents. Depending on
how you've implemented the mud's catalog of items, "where sword" may do an
iterative search of the entire mud contents, or it may do an SQL query into
a set of tables. Both work, the difference is a question of style and
portability -- portability not in the sense of cross-platform compilation,
but in the sense of when someone else looks at your code if they know
lex/yacc they will be able to understand the mud command structure quickly
rather than having to pore over your home-grown parser.




More information about the mud-dev-archive mailing list