2D Liquid Simulator with Cellular Automaton (2017)
jgallant.com
jgallant.com
That is the source file shown at the beginning of the video... it compiles without warnings, runs a full blown fluid dynamics sim with surface tension and everything, can take itself as its own input... truly a work of art.
Another classic: http://david.li/fluid/
And indeed it's at least 11 years old according to this youtube video https://www.youtube.com/watch?v=R0O_9bp3EKQ
Code: https://github.com/PWhiddy/Growing-Neural-Cellular-Automata-...
Demo: https://transdimensional.xyz/projects/neural_ca/index.html
make a 3x3 block, delete the middle, hold down the "spawn water" button for as long as you like while the mouse is on the empty block then remove the top block to create an explosion of water.
For GoL, the speedups are just insane. The linked wiki shows a simulation: The 6,366,548,773,467,669,985,195,496,000 (6 octillionth) generation of a Turing machine in Life computed in less than 30 seconds on an Intel Core Duo 2GHz CPU using Hashlife
But then of course, Game of Life has loads of 'boring' repeating stuff and is much more discrete compared to physical fluid dynamics simulation.
> Computed by detecting a repeating cycle in the pattern, and skipping ahead to any requested generation.
[1]: https://tomforsyth1000.github.io/papers/cellular_automata_fo...
I'm curious why the simulator never reaches a complete, steady state? It seems to settle mostly and then a few squares flicker rapidly. Is this just floating point math doing its thing, or ?
You can get really interesting mixing behaviour by varying the density of the particles - https://en.wikipedia.org/wiki/Rayleigh–Taylor_instability
Shameless plug, in 194 bytes:
https://www.youtube.com/watch?v=nF7cdUVgvNc https://github.com/tterrasson/liquid-simulator-godot/
especially the part where the falling cells are being rendered as full cells made me go "waaait a minute, this would look slightly weird in exactly the same way that ONI water does when it falls". Does anyone maybe with ONI modding experience insights on wether that's really how the game implemented liquids? The release date certainly wasn't too far off.
Great writeup and a fun exercise to implement by oneself as a learning project.
But as soon as you dive into a tiny bit of detail, no, this violates those equations at basically every iteration.
https://gamedevelopment.tutsplus.com/tutorials/make-a-splash...
If you create a closed container with zigzagging tubes, you would expect water to go fast through the tubes but it won't.
Watch your faucet run into a partially full sink: there’s a small depression where the stream impacts it — while the pressurized region under the stream pushes the water out and away.
This is in contrast to honey, which will form a mound when a stream hits, because of its higher viscosity.
First questions on my mind : Can it do surface tension? Pressure?