// Wolfram Cellular Automata // Daniel Shiffman // Simple demonstration of a Wolfram 1-dimensional cellular automata // Mouse click restarts as well // 3-state 1-D CA // Andy Doro // March 20, 2007 CA ca; // An instance object to describe the Wolfram basic Cellular Automata void setup() { size(600,600); frameRate(30); background(0); int[] ruleset = {0,1,0,1,1,0,1,0,2,2,0,1,2,1,2,0,2,1,2,1,2,0,1,1,1,1,1 }; // An initial rule system //int[] ruleset = {0,1,2,0,0,1,1,0,1,0,0,0,1,2,1,2,1,2,0,0,2,2,1,2,2,2,0 }; // An initial rule system //int[] ruleset = {2,1,2,0,2,2,1,1,0,2,1,0,1,0,2,2,2,1,1,0,2,0,0,0,2,1,1 }; // An initial rule system ca = new CA(ruleset); // Initialize CA } void draw() { ca.render(); // Draw the CA ca.generate(); // Generate the next level /* if (ca.finished()) { // If we're done, clear the screen, pick a new ruleset and restart } */ } void mousePressed() { background(0); ca.randomize(); ca.restart(); }