Newsgroups: rec.arts.int-fiction
Path: gmd.de!urmel.informatik.rwth-aachen.de!newsserver.rrzn.uni-hannover.de!hrz-ws11.hrz.uni-kassel.de!news.th-darmstadt.de!zib-berlin.de!news.rrz.uni-hamburg.de!news.dkrz.de!dscomsa.desy.de!CERN.ch!EU.net!sun4nl!news.nic.surfnet.nl!spider.research.ptt.nl!sun005!bos_m
From: bos_m@sun005.research.ptt.nl (Marnix van den Bos)
Subject: parsing and executing user input
Message-ID: <1994Mar24.092001.25993@news.research.ptt.nl>
Sender: usenet@news.research.ptt.nl (USEnet News)
Nntp-Posting-Host: sun005.research.ptt.nl
Organization: PTT Research, The Netherlands
Distribution: rec.arts.int-fiction
Date: Thu, 24 Mar 1994 09:20:01 GMT
Lines: 50



I have a question about implementing an adventure development system. I have 
been working on such a system for quite a while now, and I would like to
check whether my approach of handling the user's command line input is
a common one.

I have no experience with existing development systems at all. I deliberately
didn't look at existing systems, because I wanted to start out with an
`empty' mind. The only information I have are many adventures I have played
(some people may think this is a bad decision. I don't).

Anyway, the system I am developing exists of a compiler and an interpreter
(and a definition language, of course). I have spent some time deciding how
to execute the commands a user enters at the command line. I don't like
using constructs like: if (verb_id == take) {blahblah}, because then in the
blahblah-part all nouns, adverbs etc cases must be handled.
Instead, I decided to have my compiler use the interpreter.

The interpreter first checks the syntax of the user data and then parses it.
Finally, an action_rec is delivered by the interpreter. The action_rec
contains the action to be performed, the actor, the subject(s), adverbs and
more. A typical action_rec would be about 30 bytes. Next, the action_rec
is executed by the interpreter.

In the definition language, I want to be able to indicate that certain user
commands must lead to certain events to be executed (like moving objects
around, etc.). These events I call triggers. What I do is the following:
In the adventure source file I enter a sentence like it would be entered
by the user, followed by an arrow and the name of a trigger. Example:
"pick up the lamp" -> takelamp. The compiler now uses the interpreter (a
simplified version, it won't ask for additional info in case things are 
unclear) to create an action_rec and store this in the compiled file.
At runtime, the interpreter will create an action_rec from the user's
input and hand it over to objects and locations. Each object and location
will check to see if it has a matching action_rec and if so, it will 
execute the corresponding trigger. Of course there's a bit more to it, like
flow control in case more objects want to respond, but this is the general
idea.

My question: is this a commmon approach, or are there other (better?) ways
to process and execute user input?

Thanks,

Marnix J. van den Bos
M.J.B.vandenBos@research.ptt.nl



