xxxxxxxxxx
30
// The Nature of Code
// Daniel Shiffman
// http://natureofcode.com
// Wolfram Cellular Automata
// Simple demonstration of a Wolfram 1-dimensional cellular automata
let ca;
let delay = 0;
function setup() {
createCanvas(600, 600);
background(51);
let ruleset = [0, 1, 0, 1, 1, 0, 1, 0];
ca = new CA(ruleset);
}
function draw() {
ca.show();
ca.generate();
if (ca.finished()) {
delay++;
if (delay > 30) {
background(51);
ca.randomize();
ca.restart();
delay = 0;
}
}
}