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 and most of the results suck, but you can still see some complex behavior in certain configurations.

The algorithm operates on a grid of cells with one floating-point value per channel. There are 2 channels by default. Each cell scans pixels within a certain pre-determined range of itself, performs a sum function on each range separately then applies a weight (multiplication) and bias (addition/subtraction) using values from the configuration. Every result is clamped using tanh, then they are all summed up and clamped again.

Each time you run the program, or reset the rules (R key), 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.

Some of the configurations may flash rapidly, so do not use this program if that's a problem for you.

I might add more features in the future, such as a GUI, parallel processing (through pthreads, wgpu-native, or something else) 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