Multiple Neighborhood Cellular Automata

I have always found the different models of self-organizing systems fascinating. They can exhibit many unique, interesting and sometimes life-like behaviors. A classic example would be Conway's Game of Life, but there are of course many more (Lenia, boids, etc.) In the past, I have experimented with particles in continuous space and with simple cellular automata of my own.

Recently, I have written a simple implementation of a multiple-neighborhood cellular automaton, based both on my own experiments and inspired by those of Softology and Slackermanz. It is written in C and uses Raylib for displaying graphics. My version is quite primitive, based purely on my own intuition and experimentation, also the results are not as impressive, but I still hope anyone reading enjoys playing around with this.

Here is a simple explanation of the underlying mechanism: The algorithm operates on a grid of tiles with floating-point values. Each tile scans pixels within a certain pre-determined range of itself, performs a function (average, standard deviation etc.) on them and applies different weights and biases based on the Euclidean distance of the pixel. The resulting values are then collected and clamped using a hyperbolic tangent function. Of course, I suck at these kinds of explanations and source code is worth a thousand words, so you can look at it yourself.

Each time you run the program, or reset the rules, a random set of parameters is set. Most of the combinations result in collapse, homogenous patterns, chaos or inertia, but you can sometimes also get unique results. This makes playing around fun and a bit addicting, since you can't possibly know what you will see next.

I might add more features in the future, such as a GUI, parallel processing (through pthreads, wgpu-native, or something else, idk ¯\_(ツ)_/¯), proper multi-channel support, or maybe even turn this into full neural cellular automata. For now, I'm just sharing it as it is.

Check the repository out here: https://codeberg.org/greenfieldsoftware/mnca-c