[MUD-Dev] Text Parsing
David Bennett
ddt at discworld.imaginary.com
Wed Jun 2 17:03:33 CEST 1999
On 6/2/99, at 4:38 PM, Greg Miller wrote:
>I prefer "get red and blue swords" and "get swords" for these cases.
>They're plain english, less typing that anything suggested so far, and
>they're likely among the first things new players will try.
>Have you looked at the DiscWorld mudlib? I've found it saves me quite a
>bit of typing, simply by interpreting short english sentences to mean
>what they do in english rather than requiring odd constructs like "all
>swords" or "all.sword"
Since Discworld was mentioned... This parsing is mostly done using an efun
that exists in most lpMud drivers, original used on Genesis I think
(although I am not sure if they still do or not): 'parse_command' being the
efun. It works by getting a list of adjectives, plurals and nouns off
every object which is passed into the system (plus a list of adjectives etc
which match for all object off the master object). It will parse a few
default things, like numbers (one, two, three) and (first, second, third),
then it then goes through this list, breaking up the input into words, and
looking for the first match. The return from the efun is the list of
*every* object that matched the description (short circuited on the first
match), Discworld's wrapper then asks each object if it really wants to be
included in the resultant array and returns this result. The parsing leads
to some obvious problems: if you have something called 'longsword' and
something called 'longsword scabbard' it will always match the longsword
and not the scabbard.
In terms of input I think one of the best things you can do is, first of
all, be consistend and second be easy to use. The commands must be logical
at some level or people will just forget them.
Things like: sword 2, second sword and two swords all work in the discworld
parser, which is really just a sophisticated wrapper to parse_command() at
the object matching level. The way I ended up doing verbs was to use a
system where each object still adds their verb, but they add a pattern for
the verb too. Which means that the parser does a lot of the syntax
checking level of the work for you.
eg:
add_command("fill", "<direct:object> from <indirect:object>");
This does lead to some problems and I think overall having a centrally
controlled parser with a set of centrally defined patterns works a lot
better and leads to less confusion for the player.
May your days be long and frog filled,
David.
_______________________________________________
MUD-Dev maillist - MUD-Dev at kanga.nu
http://www.kanga.nu/lists/listinfo/mud-dev
More information about the mud-dev-archive
mailing list