Skip to content

Fluids: Divisibility

Most objects in virtual worlds are solids, and that’s how they’re implemented. However, when modeling the real world it’s a little hard to avoid the presence of fluids, especially water 1. I use the term “fluids” rather than “liquids” in order not to exclude those solids that (in naïve physics) act like liquids, such as sand, ash, and flour; I also mean it to discount substances like glass that are formally liquids but on human timescales act mainly like solids.

The central problem with fluids is that they’re indefinitely divisible. You can split them apart and combine them arbitrarily 2. If someone has a bottle of water and a glass, they should be able to fill the glass with water and have the excess remain in the bottle. This can be faked by giving all fluid-tight containers a pair of properties to indicate what fluid they have in them and how much, or it can be implemented “properly” by creating separate objects for each chunk of fluid that have their volume as a property tied to them. The latter is generally preferable because it means that fluids can be referenced and that they can exist independently of containers (for example, if you tip them out onto the ground). Tiresome players may create thousands of fluid objects by decanting from a large container into a tiny one many times, but so long as you’re aware of this possibility it shouldn’t be hard to prevent it from causing problems.

Beyond a certain size, large bodies of fluid can be regarded as generators. You can take as much saltwater as you want from the ocean, there’ll always be plenty left. In practice, the amounts of fluid that can be used as generators can be much smaller; a beach has an inexhaustible supply of sand, and even ponds and private swimming pools can be considered effectively always full. Because virtual worlds aren’t real, it’s even possible to have small containers generate infinite amounts of a fluid 3.

There are potential difficulties when fluid is tipped out of a container into the environment. It’s not a problem if there’s already a fluid on the surface, as a large body of any fluid can safely be assumed to absorb (or otherwise disperse) any chunk of fluid added to it. Emptying oil into a (virtual) freshwater lake just destroys the oil no matter how often a player does it.

When the surface does not already have a fluid on it, that’s another matter. On a smooth surface the fluid may flow away downhill, whereas on a rough one it could form pools or puddles; for a rocky surface or a boardwalk it could disappear immediately between cracks; for dry earth it could simply be absorbed. What actually happens depends on the surface and the fluid. At the very least, it implies that all surface types need to be classified so that the physics can determine what to do.

The final divisibility issue concerns leaks. Leaks can be regarded as loss to volume that occurs over time. Although in real life a fluid that seeps from a leaky container can leave a trail, this is quite hard to implement in practice. In general, if a bucket has a hole in it then all means is that the amount of fluid it contains will lessen at a constant rate until there’s none left. It doesn’t mean you can fill the bucket with sand and try to write your name on a field.


  1. Potions and ale are commonplace, too. ↩︎

  2. Assembly “atoms” can be split apart, too, but combining them takes more effort. ↩︎

  3. As in the joke where a man gets three wishes from a genie. On his first wish he asks for a never-ending bottle of beer. The genie obliges, and the man drinks enough from it to satisfy himself that it works. The genie asks him what his other wishes are. “I’ll have another two of these please,” he replies. ↩︎