Top level script is xmaslights-cellular-automata.py
This implementation involves the following 3 steps (plus some initialization):
- Initialize a color map (spatial modulus, in this case), random states, and a random "history" used for deciding when to stop
- Comptue the K Nearest Neighbors (n=8, by default) for each LED on the christmas tree, define this as the "neighborhood" for each LED
The result looks like this:
- Run Conway's Game of Life rules over the states of the LEDs using the neighborhood from (1)
- Compute the exponentially weighted moving average for a window of mean of the LED states and take its standard deviation - if it exceeds a threshold, reinitalize
The result looks like this (sped up substantially):