Complex Behaviour from Simple Rules: 3 Simulations
https://www.youtube.com/watc...A small display of some of the surprisingly intricate patterns and behaviours that can arise from relatively simple rules. More information about each of the simulations below.
These simulations were made in Unity, and coded with C# and HLSL.
You can find the project files at the links below.
Reaction-Diffusion: https://github.com/SebLague/Reaction-Diffusion
Cellular Automata: https://github.com/SebLague/MN-Cellular-Automata
Slime mould: https://github.com/SebLague/Slime-Simulation
If you'd like to support my work, you can do so on Patreon: https://www.patreon.com/SebastianLague
---- 1. Reaction-Diffusion ----
This is a simulation of two chemicals (A and B). Both diffuse over time (A faster than B).
The simulation space is initially filled with A, and just a small region has some of chemical B. Over time, more A is gradually added (controlled by a parameter called feedRate), while B is gradually removed (controlled by the parameter removeRate). Finally, there's a reaction that takes place: when one particle of chemical A is in the presence of two particles of chemical B, it will be converted into B.
One could simulate the individual particles of both chemicals, but more common (and the approach I went with as well) is to just store a value for the concentrations of both chemicals at each pixel. The probability of an A particle coming into contact with two B particles can be determined by the equation: probablityOfReaction = concentrationA * concentrationB * concentrationB. Here is the tutorial I followed when creating my implementation: https://www.karlsims.com/rd.html
The colours in the simulation are mainly based on the concentrations of the two chemicals, but to spice things up I also added some colouring based on how fast the concentrations are changing at each point.
---- 2. Multiple Neighbourhood Cellular Automata ----
This is a technique developed by someone who goes by Slackermanz online (you can find many awesome examples under that name on Twitter).
In this simulation, the state of each pixel (called a cell) is initially randomized between 0 and 1. On every frame, the state of each cell is updated based on the states of all the cells inside various "neighbourhoods" around it. These neighboughhoods are ring-shaped, with each ring defined by a min and max radius, along with two min/max values called 'alive' and 'dead'. Once all the states inside a ring have been added up, the sum is compared to the ring's alive and dead ranges, and depending on which range the sum falls into, the cell's state increases or decreases by some small amount (if the sum is inside neither range, the state remains the same).
This already gives interesting results, but there are some more nuances that can be added. For example, instead of the rings directly affecting the cell's state, they can contribute to several 'potential' states, and whichever of these is most different from the cell's current state becomes the new state.
My implementation is based on Slackermanz code, which you can find here: https://github.com/Slackermanz/VulkanAutomata
Slackermanz also has a YouTube channel here: https://www.youtube.com/channel/UCmoNsNuM0M9VsIXfm2cHPiA
---- 3. Slime Mould Simulation ----
In this simulation we have a lot lot of particles, each of which leaves a trail behind itself as it moves. These trails diffuse and evaporate over time. Each particle also has three circular sensors arranged in an arc in front it. These are used to detect the intensity of the trail, and the particle turns towards whichever detects the highest intensity. Some randomness is added to the turning as well.
The idea for this comes from this paper: https://uwe-repository.worktribe.com/output/980579
I also have a video exploring it in some more depth: https://youtu.be/X-iSQQgOd1A
Music:
Beneath the Stars by Joshua Spacht
Nowhere I Can Go by The Stolen Orchestra
The Art of Loneliness by Anbr
Selfless by Eleven Tales
Life by Anbr
Chapters:
00:00 Reaction-Diffusion Simulation
02:50 Multi-Neighbourhood Cellular Automata
07:23 Slime Mould Simulation