Newsgroups: rec.arts.int-fiction
Path: gmd.de!nntp.gmd.de!Germany.EU.net!news.dfn.de!gs.dfn.de!news.dkrz.de!dscomsa.desy.de!CERN.ch!EU.net!howland.reston.ans.net!torn!watserv2.uwaterloo.ca!undergrad.math.uwaterloo.ca!calum!mlvanbie
From: mlvanbie@calum.csclub.uwaterloo.ca (Michael Van Biesbrouck)
Subject: Re: override routines (Re: NPC Thoughts for comment)
Message-ID: <Cxp0HA.EIo@undergrad.math.uwaterloo.ca>
Sender: news@undergrad.math.uwaterloo.ca (news spool owner)
Nntp-Posting-Host: calum.csclub.uwaterloo.ca
Organization: University of Waterloo
References: <whittenCx9I9y.3DH@netcom.com> <FLEE.94Oct12234018@snobol.cse.psu.edu> <37kncf$2il@cantua.canterbury.ac.nz> <FLEE.94Oct13221108@snobol.cse.psu.edu>
Date: Sat, 15 Oct 1994 02:34:21 GMT
Lines: 59

Felix Lee <flee@cse.psu.edu> wrote:
>Greg Ewing:
>>The difficulty I got stuck on was that often the
>>interrelationships between the conditions for different
>>versions of an action are such that it's critical to
>>test the conditions in the right order. Whenever you
>>add a new alternative, you have to consider where
>>abouts in the sequence to insert it.
>
>right.  if I remember my Prolog, the rules are tried in the order that
>they're defined, and this isn't the right thing to do if you want
>modular adventure code.

(Parenthetically, this is not necessarily the case.  It is typical of
most Prolog implementations, however.  Prolog variants that do not have
this procedural extension tend to go by different names.  Parlog will
test rules in parallel, completely bypassing any sort of order.)

>but I think I can make it so that rules are naturally checked in the
>right order, mainly by ensuring that more "specific" rules are checked
>before more general rules.  I'll have to see if it works out..

I have previously considered this sort of problem, and my decision was
to modularize programs so that object definitions consist of properties
and rules that correspond to common verbs (also intended to be reused).
Verb definitions would mostly cover the different grammatical forms.  In
the case of verbs that exist for one game only, object properties
associated with the verb are best placed with the verb.

Special cases for objects are placed according to where they take
effect.  Data sources would be combined something like this:

include main-loop
include parser
include locations
  (also contains the rule for lighting matches in gas filled rooms)
include verbs
  include local-verbs
	(defines new verbs, also pun-action special cases in ``Nord and
	Bert'')
  include usual-verbs
include objects
  include local-objects
	(with verb information)
  include usual-objects

This sketch hierarchy assumes that verbs check properties of objects.
Reasonable coding allows an OO-like programming approach.  (The stool is
of class Chair, so you can sit on it; the oil is liquid but not potable,
so drink has the response ``You cringe at the thought of drinking that.'',
etc.)

The ordering of rules shown above should allow special cases to be added
without modifying pre-packaged definitions.

-- 
"You're obviously on drugs,      Michael Van Biesbrouck
but not the right ones."         Oook!  UW CSC Librarian
-- bwross about mlvanbie         http://csclub.uwaterloo.ca/u/mlvanbie/
