//Cellular Automaton //Implements a simple eight-cell, two-state grid //evolving according to a randomly selected Wolfram rule. int rule[8]; int config[8]; int gen; int which_rule; 0 => gen; 0 => which_rule; for (int x; x<8; x++) { Std.rand2(0,1)=>rule[x]; Std.rand2(0,1) => config[x]; <<>>; } for (int j; j<8; j++) { (which_rule + Math.pow(2,(7-j)) * rule[j])$ int => which_rule; } <<<"We are now using rule">>>; <<>>; while(true) { for (int y;y<8;y++) { if (config[(y+7)%8]==1){ if (config[y]==1) { if (config[(y+1)%8]==1) { rule[0] => config[y]; } else if (config[(y+1)%8]==0) { rule[1] => config[y]; } } else if (config[y]==0){ if (config[(y+1)%8]==1) { rule[2] => config[y]; } else if (config[y+1]==0) { rule[3] => config[y]; } } } else if (config[(y+7)%8]==0){ if (config[y]==1) { if (config[(y+1)%8]==1) { rule[4] => config[y]; } else if (config[(y+1)%8]==0) { rule[5] => config [y]; } } else if (config[y]==0){ if (config[(y+1)%8]==1) { rule[6] => config[y]; } else if (config[(y+1)%8]==0) { rule[7] => config[y]; } } } } 250::ms=>now; }