The entirety of this post is largely a rehash of this post. They go over the algorithm and post some really cool images. I thought a good way to get into generative art would be to code it up in Julia, so that is what I did. Directly from the linked blog:
The basic rule is you fill an image with random colors and set an update probability. For each pixel see if a random value is less than the probability. If it is then change the pixel to the color of one of its neighbor cells (this can be the 4 N,S,E,W Von-Neumann neighbors or all 8 closest cells in the Moore neighborhood). Griffeath’s original uses a 50/50 chance of each cell being changed and uses the Von-Neumann neighborhood.
The code is pretty simple in Julia, especially with the Images package. Originally I thought about using no external packages / dependencies. It's not so bad if you use a PPM format, but there is so much redundant data and no compression, so I decided against it. The code is below,
imgc is a matrix of random pixels and
chance is a number between 0 and 1- I chose
0.5f. It doesn't matter so much, but I iterated over the rows and then the columns, but Julia is column major so I should have switched that. It would be interesting to see the performance inhancements.
If you iterate over a 1000x1500 matrix 1000 times, you get something like the image below. You can also click the image to open an mp4 of the animation. (Note: it is not optimized for web browsing!)