[Home] [Groups] - Message: [Prev in Group] [Next in Group]

nu.kanga.list.mud-dev

10242: Re: [MUD-Dev] Text Parsing

[Full Header] [Plain Text]
From: Greg Miller <gmiller@classic-games.com>
Newsgroups: nu.kanga.list.mud-dev
Date: Fri, 28 May 1999 17:52:53 -0500
References: [1]
Organization: Kanga.Nu
Albert wrote:
> I'm currently building a text adventure game, with intentions of expanding it into some sort of
> mud server once I master network programming. In any case, I was 

Well, you'll probably end up having to rewrite the code nearly from
scratch and heavily overhaul the gameplay to make a mud out of it. But
that's ok, most of us approach our muds as iterative processes anyway.

> Then say the player enter a command like: buy the biggest ball from the 3rd shopkeeper
> The convoluted pseudocode would be:
> 
> void Parse(string & rhs) {
>         ParsedCommand pc;
>         string word;
>         while (1) {
>                 word = GetNextWord(rhs); // Would magically keep pointer position

This'll likely be a problem once you build a mud server due to
reentrancy issues. You have to either make it reentrant or parse the
entire sequence of commands without allowing other player commands to go
through.

>                 if (word.empty())       break;
>                 switch (GetKind(word)) {

This is another problem. What if you want to allow "get the knife" and
"knife the innocent victim"?

> I know, this system is hugely inefficient. But I believe it allows the 

The biggest inefficieny being that you store everything as strings. A
better approach would be to analyze each word independently first for
classification and tokenization.
--
http://www.classic-games.com/
President Clinton was acquitted; then again, so was O. J. Simpson.
*** NEWBIES: Limit signatures to four lines! No HTML mail or posts! ***



_______________________________________________
MUD-Dev maillist  -  MUD-Dev@kanga.nu
http://www.kanga.nu/lists/listinfo/mud-dev