Saturday, June 15, 2019

Cellular Automata!

If you've never heard of Cellular Automata here is the tl;dr.

Make a line of "cells," each cell can be on or off. Look at each cell and its neighbours, according to a set of rules you update the state of the cell in the middle. Do this for every cell in the line and then print the states of the cells on the screen as light and dark pixels. If you put each new line below the last it might look something like this.


If the 3 cells in a row form the pattern 100, 011, 010 or 001 then the middle cell will be 1 on the next generation.
All other combinations result in a 0.


Despite the simple rules, some very complex patterns or even randomness can come from the 255 rules of 1 dimensional cellular automata (the images are 2D because we are showing time starting at the top and moving downward). I've been playing with discrete automata, where the cells are either on or off, for a long time but only recently started looking at continuous automata.

In continuous automata each cell can be any value from 0 to 1 and on each step you perform a continuous function, like y = mx + b. Being continuous there is a MUCH bigger space to map, you could do any function and make infinitesimally small changes to it while still observing different results. To start I have been looking at simple rules, these look at 5 cells in a row, average them together with different 'weights' and then add a constant. If the result is greater than one then the only the fractional part is kept (the one is dropped).

For example, here are two images of continuous automata with very simple rules, they both take the average of a cell and its two nearest neighbours then add a constant value, in the first image that value is 0.04 in the second it is 0.041.



Each new cell is equal to the average of itself and its neighbours, plus an additional constant. 
New cell(n) = constant + (cell(n-1) + cell(n) + cell(n+1))/3


It becomes easy to see how many possibilities there are to generate unique patterns when adding 1/1000 to each cell makes such a big difference. To better map the possibilities I made a tool that lets me change the starting conditions (a single point or a random line of values), the weights used to average the cells together and the constant that is added to each cell on each step. Using this tool I have scanned through a few thousand rules and picked out the most interesting below, I highly recommend zooming in to see some of the fine details in the larger structures.