Saturday, January 2, 2021

Genuary 2021 Day 2: "Rule 30"

 


"Rule 30" here, refers to one of Stephen Wolfram's elementary (1d) cellular automata. If your cell's state is related to the state of the cells in the previous generation to the left and right and it's own previous state, that's 3 different bits of input for the current state. That's 2^3 = 8 possible input combinations. Each combination needs to be specified by your rule for whether that leads to an "alive" or "dead" state in the new generation, so 2^8 = 256 possible 1d cellular automata if you only look one cell left or right.

In this rendering, I (ab)used my ray marcher, and created a material that evaluated the cellular automaton for rule 30. I converted the x,y position where the ray hit the floor plane into an integer x,y value. I used x to represent the spatial dimension of the CA, and y to represent the generation number, where x,y = (0, 0) was a "seed" value of "alive", and y=0, x != 0 was seeded to "dead".

I maintained a table to cache my previously evaluated values of whether (x,y) was alive or dead. I imagined requiring around 30 generations of data, which amounted to around 1000 bits of information in my table, so not out of control.

If the (x,y) value was "alive" in my table, I colored it a sort of teal color. If it was not alive, I marched back in time to see how long it had been since that x-value was alive, with an upper limit of 10. Each step back in time faded the teal color towards the base color (which is a pale gray, which I chose because maybe it looks nicer than a harsh pure white). 

Tools Used: my ray marcher

Languages Used:  Python3

Evaluation Time: 337 seconds

Development Time: ~90 minutes


No comments:

Post a Comment