[MUD-Dev] Text Parsing
Greg Miller
gmiller at classic-games.com
Fri May 28 17:52:53 CEST 1999
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 at kanga.nu
http://www.kanga.nu/lists/listinfo/mud-dev
More information about the mud-dev-archive
mailing list