falling sand game with regular parallel arrays.
If you want more performance, falling sand simulators can further be made parallel by implementing them using Margolus Neighbourhoods, as in Falling Turnip: https://github.com/tranma/falling-turnip
The idea is that a single iteration divides the world into 2x2 squares and then applies effects sequentially within each square, but not between the squares. This means each square can be processed independently. In the next iteration, the division into squares shifts right and down by one cell each direction. This does mean you need more steps than in a sequential implementation, but I found it to be quite a principled approach to parallelizing cellular automata when I first read about it. One interesting side effect of this design is that falling particles end up being separated by blank space, as shown here: https://futhark-lang.org/static/falling-sand-2016.12.04.webm I wonder if that is fixable.
A falling sand game as a cellular automaton, powered by WebGL.
Another way to do this (albeit without simple support for fluids) is to use the Moore neighborhood and use a left and right "bias" to decide which direction a grain should fall towards if it can't fall straight down. This works pretty well as a shader, and has the same side effect with the horizontal lines.
Appwrite - The Open Source Firebase alternative introduces iOS support . Appwrite is an open source backend server that helps you build native iOS applications much faster with realtime APIs for authentication, databases, files storage, cloud functions and much more!
Cellular Automata Machine (CAM6) Simulator
Typically a cellular automata simulation will have some edge condition like wrapping or mirroring an adjacent cell.
A nice optimization trick is to make the cell buffers 2 cells wider and taller (or two times whatever the neighborhood radius is), and then before each generation you update the "gutter" by copying just the wrapped (or mirrored) pixels. Then your run the rule on the inset rectangle, and the code (in the inner loop) doesn't have to do bounds checking, and can assume there's a valid cell to read in all directions. That saves a hell of a lot of tests and branches in the inner loop.
Also, the Margolus neighborhood can be defined in terms of the Moore neighborhood + vertical phase (even/odd row) + horizontal phase (even/odd column) + time phase (even/odd time). Then you can tell if you're at an even or odd step, and which of the four squares of the grid you're in, to know what to do.
That's how the CAM6 worked in hardware: it used the x/y/time phases as additional bits of the index table lookup.
Here's how my CAM6 emulator computes the Margolus lookup table index, based on the 9 Moore neighbors + phaseTime, phaseX, and phaseY:
How to improve drawing speed with rust piston-2d
2 projects | reddit.com/r/rust_gamedev | 16 Aug 2022
How do I implement a bug fix from GitHub?
2 projects | reddit.com/r/openrct2 | 16 Aug 2022
Buzzwords - a word game about using letter tiles to capture territory, single player vs bots and two player
1 project | reddit.com/r/WebGames | 15 Aug 2022
An online snake game that you can't play- you need to program a bot to compete for you
1 project | reddit.com/r/programming | 15 Aug 2022
"Merchant doesn't trust you enough"
1 project | reddit.com/r/cataclysmdda | 15 Aug 2022