Re: Liquids (and Inform)


23 Mar 95 15:10:27 GMT

In article <baf.795156846@max.tiac.net>, baf@max.tiac.net (Carl Muckenhoupt) writes:
> nelson@vax.oxford.ac.uk (Mathematical Institute, (0865) 2-73525) writes:
>
>>Interestingly, I've just implemented such a library for Inform, so
>>I've been thinking about just this problem. I've not used the ordinary
>>containment system for liquids, so I don't need to dynamically allocate
>>objects: one prototype object is needed for each different liquid in the
>>game. An amusing set of parsing rules moves the names of liquids into
>>scope at the right times.
>
> This sounds remarkably like the system that was used in GC. I've
> rejected this approach for my project, principally because it keeps
> liquid contents seperate from conventional contents. It is a nice
> elegant approach, though.
>
>>Finally, actions are generated when liquid 1 is added to liquid 2
>>(and this is not assumed to be symmetrical), when a liquid is added
>>to a solid (e.g. water added to a beanstalk plant) and vice versa
>>(e.g. a lump of sodium dropped into a bucket of water). These last
>>three can all happen in various different ways, so I think it's useful
>>that the rules can be written once only. For instance, the prototype
>>"water" object contains a generic rule for what happens when water is
>>added to oil.
>
> This part interests me. In particular, I'd like to know how you handle
> mixtures of arbitrary liquids. Do you have special "mixture" liquids?
> I'm a bit wary of making it necessary to specify the properties of each
> possible combination of liquids, you see.
> Abstracting the mixing away from specific verbs is a good idea. In fact,
> abstracting actions in general is a good idea. It can only make your
> code more robust - if you want a bucket of whitewash to fall down when a
> door is opened, you really want a single routine that gets called no
> matter what caused the door to open.

The way it works is this. When a liquid is told that the player's
trying (in some way) to mix another liquid into it, it can either
take action itself and tell the library to forget about the problem
(e.g. print "The world explodes!" and kill the player), or it can do
nothing at all (in which case the library says something like "Nothing
is to be gained by mixing custard and vodka") or it can return (the
number of) an object, which is the resultant mixed liquid. In my
little test game, for instance, I have water, red dye and pinkish water.
Like all such approaches, this is an approximation, but it's clean
and simple, while not ruling out the designer writing more complicated
code as needed. (For instance, changing the short name of the "pinkish
water" according to exactly how dye-concentrated it is.)

Graham Nelson
Oxford