Chapter 10: Physics: Substances, Ropes, Energy and Weight
10.2. Liquids

Liquids are notoriously difficult to simulate well. A fully thorough approach consumes endless storage and can be very finicky to write and keep realistic. It is essential to decide what aspect of a liquid's behaviour is actually needed in a given story, and to simulate only that. For instance, if we only need a little chemistry, where a player can add (say) water to salt and make a solution, we do not want to fool around with calculating quantities or concentrations: what's important is that "some water" (amount unspecified) combines with "some salt" to produce "some salty water". We should no more calculate precisely here than we would work out where all the furniture is to the nearest inch. Good advice for handling liquids is to simulate the least amount of realism possible, but no less.

Sometimes all we want is a down-in-one drink: we needn't simulate the actual liquid, just the bottle it comes in, and all we need is to handle the "drinking" action. See Beverage Service, and also 3 AM, where carbonated drinks can be shaken - again simulating the vessel, not the liquid.

Some elementary biochemistry in Xylan is done simply by... well, the point is that two different liquids are represented by single things each, and a chemical reaction simply switches one for the other.

In Frizz, we allow any container to be filled (only) with water (only) and we simulate what happens to any solid objects also inside: some waterproof, some not. Flotation provides a well (always full of water), with rules to determine whether things dropped into it should sink or float.

Next we move up to quantitative approaches, where we remember not just whether a liquid is present, but how much of it. In its simplest form, we could have a drinking vessel from which we draw in sips, so that it can be full, half-empty or empty: see Thirst.

The example with the best compromise between simulation quality and complexity is Lemonade. Here we provide a kind of container called a "fluid container", not just a single cup, and each such vessel has a given "fluid capacity". Each holds only a single liquid at a time (so no mixtures) and can be empty or full to any level (rounded off to the nearest 0.1 fl oz). We can fill one vessel from another (unless it would make a mixture). But liquids leaving these vessels must be consumed - drunk or poured away without trace: we cannot make pools on the floor, or carry liquids in our cupped hands. There is no object representing "lemonade": there are only fluid containers, but which can be called LEMONADE if that is what they now contain.

Savannah is a light elaboration of Lemonade, showing how liquids might be poured on other objects, as for instance to extinguish a fire.

Noisy Cricket extends Lemonade to allow for mixing, though then the number of different possible mixtures is so large that complexity increases greatly. Lakeside Living extends Lemonade differently to add a "liquid source" kind, a form of fluid container which has infinite fluid capacity and is scenery - ideal for a lake, river or spring.

* See Bags, Bottles, Boxes and Safes for stoppered bottles which could also be used for carrying liquids around in

* See Heat for keeping liquids warm in insulated containers


123
* Example  Beverage Service
A potion that the player can drink.

WI
193
*** Example  3 AM
A shake command which agitates soda and makes items thump around in boxes.

WI

"3 AM"

Understand "shake [something preferably held]" as shaking.

Shaking is an action with past participle shaken, applying to one carried thing.

Carry out shaking:
    say "Nothing results of your shaking [the noun]."

Instead of shaking a closed container when something is in the noun:
    say "Something rattles inside [the noun]."

Instead of shaking a closed transparent container when something is in the noun:
    say "Inside [the noun] there are banging noises produced by [the list of things contained by the noun]."

Instead of shaking an open container which contains something:
    say "[The list of things contained by the noun] might fly out."

The Wawa is a room. "A convenience store, if you like to call it that, vending the usual assortment of chips, donuts, soda, and beer. There is something of a line at the sandwich counter."

The box of enrobed cakes is in the Wawa. "A box of Tastykake Enrobed Cakes has fallen off its shelf." The description is "'Enrobed Cakes' is a fancy term for 'strange sponge-like baked good, covered in a thin shell of waxy chocolate'. They are addictive, but not in a way that lets you respect yourself in the morning." The box is a closed openable container. In the box is a cake.

Instead of opening the box, say "The Wawa clerks frown on the consumption of unpurchased foodstuffs."

The can of root beer is a closed openable container carried by the player. The can of root beer is either agitated or calm.

Because the can of root beer should have some reactions to having been shaken later in the game, we need to borrow a few ideas from the later chapters on time:

Instead of shaking the can of root beer:
    the can calms down in five turns from now;
    say "You give the can a good hard shake.";
    now the can is agitated.

Instead of listening to the can: say "It sounds [if agitated]fizzy[otherwise]calm[end if]!"

At the time when the can calms down:
    now the can is calm.

The sticky mess is fixed in place. "There is a sticky mess on the ground."

Instead of opening the agitated can of root beer:
    remove the can of root beer from play;
    now the sticky mess is in the location;
    say "You open the can and fizzing sweet soda goes absolutely everywhere."

Instead of opening the calm can of root beer when the can has been agitated:
    remove the can of root beer from play;
    say "The root beer is disappointingly flat. That's what you get for shaking it up!"

Test me with "get box / shake box / open box / shake box / listen to can / shake can / listen to can / wait / wait / wait / wait / wait / listen to can / open can".

192
*** Example  Frizz
Liquid flows within containers and soaks objects that are not waterproof; any contact with a wet object can dampen our gloves.

WI
385
* Example  Flotation
Objects that can sink or float in a well, depending on their own properties and the state of the surrounding environment.

WI
277
** Example  Xylan
Creating a new command that does require an object to be named; and some comments about the choice of vocabulary, in general.

WI
117
* Example  Thirst
A waterskin that is depleted as the player drinks from it.

WI
256
*** Example  Lemonade
Containers for liquid which keep track of how much liquid they are holding and of what kind, and allow quantities to be moved from one container to another.

WI
255
*** Example  Savannah
Using the liquid implementation demonstrated in Lemonade for putting out fires.

WI
265
*** Example  Noisy Cricket
Implementing liquids that can be mixed, and the components automatically recognized as matching one recipe or another.

WI
320
*** Example  Lakeside Living
Similar to "Lemonade", but with bodies of liquid that can never be depleted, and some adjustments to the "fill" command so that it will automatically attempt to fill from a large liquid source if possible.

WI


PreviousContentsNext