This browser has no WebGPU, so the sketch cannot run here. The program is below, and it runs in a current Chrome, Edge or Safari.

Elementary Automata

encode Wolfram's rules as combinations of neighborhood states

Open in new tab ↗ · 1dbinarycawolfram

// ── main ──
/////////////////////////////////////////////////////////////////
// elementary-automata
// encode Wolfram rules as combinations of neighborhood states
// evolve a 1D automaton through a 2D field

// * see RULES on tab 2 

// https://mathworld.wolfram.com/ElementaryCellularAutomaton.html
/////////////////////////////////////////////////////////////////

&scl = (0.5,0.25,1);
&spc = (1.1, 0.75, 0);
&seed = mlt(eql(C.x, (0.501)), eql(C.y, (0.99)));
&row = eql( rnd(mlt( sub(1, C.y), 129)), add(step,1) );
&dim =  (128,64,1);
&eps = 0.004;

#R45{
   dim = &dim;
   coord_dom = UNIT; val_dom = UNIT;
   mode = U8; eps = &eps; bound = ZERO;
   set = &seed;
   run = add(#, mlt(&row, &R45));
}

#R30{
   dim = &dim;
   coord_dom = UNIT; val_dom = UNIT;
   mode = U8; eps = &eps; bound = ZERO;
   set = &seed;
   run = add(#, mlt(&row, &R30));
}

#R110{
   dim = &dim;
   coord_dom = UNIT; val_dom = UNIT;
   mode = U8; eps = &eps; bound = ZERO;
   set = &seed;
   run = add(#, mlt(&row, &R110));
}

#R105{
   dim = &dim;
   coord_dom = UNIT; val_dom = UNIT;
   mode = U8; eps = &eps; bound = ZERO;
   set = &seed;
   run = add(#, mlt(&row, &R105));
}

#R41{
   dim = &dim;
   coord_dom = UNIT; val_dom = UNIT;
   mode = U8; eps = &eps; bound = ZERO;
   set = &seed;
   run = add(#, mlt(&row, &R41));
}

#R57{
   dim = &dim;
   coord_dom = UNIT; val_dom = UNIT;
   mode = U8; eps = &eps; bound = ZERO;
   set = &seed;
   run = add(#, mlt(&row, &R57));
}

#R54{
   dim = &dim;
   coord_dom = UNIT; val_dom = UNIT;
   mode = U8; eps = &eps; bound = ZERO;
   set = &seed;
   run = add(#, mlt(&row, &R54));
}

#R225{
   dim = &dim;
   coord_dom = UNIT; val_dom = UNIT;
   mode = U8; eps = &eps; bound = ZERO;
   set = &seed;
   run = add(#, mlt(&row, &R225));
}

#R75{
   dim = &dim;
   coord_dom = UNIT; val_dom = UNIT;
   mode = U8; eps = &eps; bound = ZERO;
   set = &seed;
   run = add(#, mlt(&row, &R75));
}

#R158{
   dim = &dim;
   coord_dom = UNIT; val_dom = UNIT;
   mode = U8; eps = &eps; bound = ZERO;
   set = &seed;
   run = add(#, mlt(&row, &R158));
}

#R90{
   dim = &dim;
   coord_dom = UNIT; val_dom = UNIT;
   mode = U8; eps = &eps; bound = ZERO;
   set = &seed;
   run = add(#, mlt(&row, &R90));
}

#R109{
   dim = &dim;
   coord_dom = UNIT; val_dom = UNIT;
   mode = U8; eps = &eps; bound = ZERO;
   set = &seed;
   run = add(#, mlt(&row, &R109));
}

~R45{ col = #R45; scl = &scl; pos =   (mlt(-1.5, &spc.x), mlt(1.0, &spc).y , 0 );}
~R30{ col = #R30; scl = &scl; pos =   (mlt(-0.5, &spc.x), mlt(1.0, &spc).y , 0 );}
~R110{ col = #R110; scl = &scl; pos = (mlt(0.5, &spc.x), mlt(1.0, &spc).y , 0 );}
~R105{ col = #R105; scl = &scl; pos =   (mlt(1.5, &spc.x), mlt(1.0, &spc).y , 0 );}

~R41{ col = #R41; scl = &scl; pos = (mlt(-1.5, &spc.x), mlt(0, &spc).y , 0 );}
~R57{ col = #R57; scl = &scl; pos = ( mlt(-0.5, &spc).x, mlt(0, &spc).y , 0 );}
~R54{ col = #R54; scl = &scl; pos = ( mlt(0.5, &spc).x, mlt(0, &spc).y , 0 );}
~R225{ col = #R225; scl = &scl; pos = ( mlt(1.5, &spc).x, mlt(0, &spc).y , 0 );}

~R75{ col = #R75; scl = &scl; pos = ( mlt(-1.5, &spc).x, mlt(-1, &spc).y , 0 );}
~R158{ col = #R158; scl = &scl; pos = ( mlt(-0.5, &spc).x, mlt(-1, &spc).y , 0 );}
~R90{ col = #R90; scl = &scl; pos = ( mlt(0.5, &spc).x, mlt(-1, &spc).y , 0 );}
~R109{ col = #R109; scl = &scl; pos = ( mlt(1.5, &spc).x, mlt(-1, &spc).y , 0 );}



// ── RULES ──
///////////////////////////////
// ELEMENTARY CA RULE MINTERMS
// Neighborhood order follows Wolfram ECA convention:
//
//   111 110 101 100 011 010 001 000
//
// &VL  = left value
// &V   = center value
// &VR  = right value
//
// &NVL = not left
// &NV  = not center
// &NVR = not right
//
// These minterms are mutually exclusive, 
// so add() behaves like OR for binary values.
//////////////////////////////////////////////

// sample left / center / right cells and their inverses
&V = #(0, 1);
&NV = sub(1, &V);
&VL = #(-1, 1);
&NVL = sub(1, &VL);
&VR = #(1, 1);
&NVR = sub(1, &VR);

// encode the 8 possible neighborhood states
&M111 = mlt(&VL,  &V,  &VR);
&M110 = mlt(&VL,  &V,  &NVR);
&M101 = mlt(&VL,  &NV, &VR);
&M100 = mlt(&VL,  &NV, &NVR);
&M011 = mlt(&NVL, &V,  &VR);
&M010 = mlt(&NVL, &V,  &NVR);
&M001 = mlt(&NVL, &NV, &VR);
&M000 = mlt(&NVL, &NV, &NVR);

// combine neighborhood states to define Wolfram rules
&R0 = 0;
&R1 = add(&M000);
&R2 = add(&M001);
&R3 = add(&M001, &M000);
&R4 = add(&M010);
&R5 = add(&M010, &M000);
&R6 = add(&M010, &M001);
&R7 = add(&M010, &M001, &M000);
&R8 = add(&M011);
&R9 = add(&M011, &M000);
&R10 = add(&M011, &M001);
&R11 = add(&M011, &M001, &M000);
&R12 = add(&M011, &M010);
&R13 = add(&M011, &M010, &M000);
&R14 = add(&M011, &M010, &M001);
&R15 = add(&M011, &M010, &M001, &M000);
&R16 = add(&M100);
&R17 = add(&M100, &M000);
&R18 = add(&M100, &M001);
&R19 = add(&M100, &M001, &M000);
&R20 = add(&M100, &M010);
&R21 = add(&M100, &M010, &M000);
&R22 = add(&M100, &M010, &M001);
&R23 = add(&M100, &M010, &M001, &M000);
&R24 = add(&M100, &M011);
&R25 = add(&M100, &M011, &M000);
&R26 = add(&M100, &M011, &M001);
&R27 = add(&M100, &M011, &M001, &M000);
&R28 = add(&M100, &M011, &M010);
&R29 = add(&M100, &M011, &M010, &M000);
&R30 = add(&M100, &M011, &M010, &M001);
&R31 = add(&M100, &M011, &M010, &M001, &M000);
&R32 = add(&M101);
&R33 = add(&M101, &M000);
&R34 = add(&M101, &M001);
&R35 = add(&M101, &M001, &M000);
&R36 = add(&M101, &M010);
&R37 = add(&M101, &M010, &M000);
&R38 = add(&M101, &M010, &M001);
&R39 = add(&M101, &M010, &M001, &M000);
&R40 = add(&M101, &M011);
&R41 = add(&M101, &M011, &M000);
&R42 = add(&M101, &M011, &M001);
&R43 = add(&M101, &M011, &M001, &M000);
&R44 = add(&M101, &M011, &M010);
&R45 = add(&M101, &M011, &M010, &M000);
&R46 = add(&M101, &M011, &M010, &M001);
&R47 = add(&M101, &M011, &M010, &M001, &M000);
&R48 = add(&M101, &M100);
&R49 = add(&M101, &M100, &M000);
&R50 = add(&M101, &M100, &M001);
&R51 = add(&M101, &M100, &M001, &M000);
&R52 = add(&M101, &M100, &M010);
&R53 = add(&M101, &M100, &M010, &M000);
&R54 = add(&M101, &M100, &M010, &M001);
&R55 = add(&M101, &M100, &M010, &M001, &M000);
&R56 = add(&M101, &M100, &M011);
&R57 = add(&M101, &M100, &M011, &M000);
&R58 = add(&M101, &M100, &M011, &M001);
&R59 = add(&M101, &M100, &M011, &M001, &M000);
&R60 = add(&M101, &M100, &M011, &M010);
&R61 = add(&M101, &M100, &M011, &M010, &M000);
&R62 = add(&M101, &M100, &M011, &M010, &M001);
&R63 = add(&M101, &M100, &M011, &M010, &M001, &M000);
&R64 = add(&M110);
&R65 = add(&M110, &M000);
&R66 = add(&M110, &M001);
&R67 = add(&M110, &M001, &M000);
&R68 = add(&M110, &M010);
&R69 = add(&M110, &M010, &M000);
&R70 = add(&M110, &M010, &M001);
&R71 = add(&M110, &M010, &M001, &M000);
&R72 = add(&M110, &M011);
&R73 = add(&M110, &M011, &M000);
&R74 = add(&M110, &M011, &M001);
&R75 = add(&M110, &M011, &M001, &M000);
&R76 = add(&M110, &M011, &M010);
&R77 = add(&M110, &M011, &M010, &M000);
&R78 = add(&M110, &M011, &M010, &M001);
&R79 = add(&M110, &M011, &M010, &M001, &M000);
&R80 = add(&M110, &M100);
&R81 = add(&M110, &M100, &M000);
&R82 = add(&M110, &M100, &M001);
&R83 = add(&M110, &M100, &M001, &M000);
&R84 = add(&M110, &M100, &M010);
&R85 = add(&M110, &M100, &M010, &M000);
&R86 = add(&M110, &M100, &M010, &M001);
&R87 = add(&M110, &M100, &M010, &M001, &M000);
&R88 = add(&M110, &M100, &M011);
&R89 = add(&M110, &M100, &M011, &M000);
&R90 = add(&M110, &M100, &M011, &M001);
&R91 = add(&M110, &M100, &M011, &M001, &M000);
&R92 = add(&M110, &M100, &M011, &M010);
&R93 = add(&M110, &M100, &M011, &M010, &M000);
&R94 = add(&M110, &M100, &M011, &M010, &M001);
&R95 = add(&M110, &M100, &M011, &M010, &M001, &M000);
&R96 = add(&M110, &M101);
&R97 = add(&M110, &M101, &M000);
&R98 = add(&M110, &M101, &M001);
&R99 = add(&M110, &M101, &M001, &M000);
&R100 = add(&M110, &M101, &M010);
&R101 = add(&M110, &M101, &M010, &M000);
&R102 = add(&M110, &M101, &M010, &M001);
&R103 = add(&M110, &M101, &M010, &M001, &M000);
&R104 = add(&M110, &M101, &M011);
&R105 = add(&M110, &M101, &M011, &M000);
&R106 = add(&M110, &M101, &M011, &M001);
&R107 = add(&M110, &M101, &M011, &M001, &M000);
&R108 = add(&M110, &M101, &M011, &M010);
&R109 = add(&M110, &M101, &M011, &M010, &M000);
&R110 = add(&M110, &M101, &M011, &M010, &M001);
&R111 = add(&M110, &M101, &M011, &M010, &M001, &M000);
&R112 = add(&M110, &M101, &M100);
&R113 = add(&M110, &M101, &M100, &M000);
&R114 = add(&M110, &M101, &M100, &M001);
&R115 = add(&M110, &M101, &M100, &M001, &M000);
&R116 = add(&M110, &M101, &M100, &M010);
&R117 = add(&M110, &M101, &M100, &M010, &M000);
&R118 = add(&M110, &M101, &M100, &M010, &M001);
&R119 = add(&M110, &M101, &M100, &M010, &M001, &M000);
&R120 = add(&M110, &M101, &M100, &M011);
&R121 = add(&M110, &M101, &M100, &M011, &M000);
&R122 = add(&M110, &M101, &M100, &M011, &M001);
&R123 = add(&M110, &M101, &M100, &M011, &M001, &M000);
&R124 = add(&M110, &M101, &M100, &M011, &M010);
&R125 = add(&M110, &M101, &M100, &M011, &M010, &M000);
&R126 = add(&M110, &M101, &M100, &M011, &M010, &M001);
&R127 = add(&M110, &M101, &M100, &M011, &M010, &M001, &M000);
&R128 = add(&M111);
&R129 = add(&M111, &M000);
&R130 = add(&M111, &M001);
&R131 = add(&M111, &M001, &M000);
&R132 = add(&M111, &M010);
&R133 = add(&M111, &M010, &M000);
&R134 = add(&M111, &M010, &M001);
&R135 = add(&M111, &M010, &M001, &M000);
&R136 = add(&M111, &M011);
&R137 = add(&M111, &M011, &M000);
&R138 = add(&M111, &M011, &M001);
&R139 = add(&M111, &M011, &M001, &M000);
&R140 = add(&M111, &M011, &M010);
&R141 = add(&M111, &M011, &M010, &M000);
&R142 = add(&M111, &M011, &M010, &M001);
&R143 = add(&M111, &M011, &M010, &M001, &M000);
&R144 = add(&M111, &M100);
&R145 = add(&M111, &M100, &M000);
&R146 = add(&M111, &M100, &M001);
&R147 = add(&M111, &M100, &M001, &M000);
&R148 = add(&M111, &M100, &M010);
&R149 = add(&M111, &M100, &M010, &M000);
&R150 = add(&M111, &M100, &M010, &M001);
&R151 = add(&M111, &M100, &M010, &M001, &M000);
&R152 = add(&M111, &M100, &M011);
&R153 = add(&M111, &M100, &M011, &M000);
&R154 = add(&M111, &M100, &M011, &M001);
&R155 = add(&M111, &M100, &M011, &M001, &M000);
&R156 = add(&M111, &M100, &M011, &M010);
&R157 = add(&M111, &M100, &M011, &M010, &M000);
&R158 = add(&M111, &M100, &M011, &M010, &M001);
&R159 = add(&M111, &M100, &M011, &M010, &M001, &M000);
&R160 = add(&M111, &M101);
&R161 = add(&M111, &M101, &M000);
&R162 = add(&M111, &M101, &M001);
&R163 = add(&M111, &M101, &M001, &M000);
&R164 = add(&M111, &M101, &M010);
&R165 = add(&M111, &M101, &M010, &M000);
&R166 = add(&M111, &M101, &M010, &M001);
&R167 = add(&M111, &M101, &M010, &M001, &M000);
&R168 = add(&M111, &M101, &M011);
&R169 = add(&M111, &M101, &M011, &M000);
&R170 = add(&M111, &M101, &M011, &M001);
&R171 = add(&M111, &M101, &M011, &M001, &M000);
&R172 = add(&M111, &M101, &M011, &M010);
&R173 = add(&M111, &M101, &M011, &M010, &M000);
&R174 = add(&M111, &M101, &M011, &M010, &M001);
&R175 = add(&M111, &M101, &M011, &M010, &M001, &M000);
&R176 = add(&M111, &M101, &M100);
&R177 = add(&M111, &M101, &M100, &M000);
&R178 = add(&M111, &M101, &M100, &M001);
&R179 = add(&M111, &M101, &M100, &M001, &M000);
&R180 = add(&M111, &M101, &M100, &M010);
&R181 = add(&M111, &M101, &M100, &M010, &M000);
&R182 = add(&M111, &M101, &M100, &M010, &M001);
&R183 = add(&M111, &M101, &M100, &M010, &M001, &M000);
&R184 = add(&M111, &M101, &M100, &M011);
&R185 = add(&M111, &M101, &M100, &M011, &M000);
&R186 = add(&M111, &M101, &M100, &M011, &M001);
&R187 = add(&M111, &M101, &M100, &M011, &M001, &M000);
&R188 = add(&M111, &M101, &M100, &M011, &M010);
&R189 = add(&M111, &M101, &M100, &M011, &M010, &M000);
&R190 = add(&M111, &M101, &M100, &M011, &M010, &M001);
&R191 = add(&M111, &M101, &M100, &M011, &M010, &M001, &M000);
&R192 = add(&M111, &M110);
&R193 = add(&M111, &M110, &M000);
&R194 = add(&M111, &M110, &M001);
&R195 = add(&M111, &M110, &M001, &M000);
&R196 = add(&M111, &M110, &M010);
&R197 = add(&M111, &M110, &M010, &M000);
&R198 = add(&M111, &M110, &M010, &M001);
&R199 = add(&M111, &M110, &M010, &M001, &M000);
&R200 = add(&M111, &M110, &M011);
&R201 = add(&M111, &M110, &M011, &M000);
&R202 = add(&M111, &M110, &M011, &M001);
&R203 = add(&M111, &M110, &M011, &M001, &M000);
&R204 = add(&M111, &M110, &M011, &M010);
&R205 = add(&M111, &M110, &M011, &M010, &M000);
&R206 = add(&M111, &M110, &M011, &M010, &M001);
&R207 = add(&M111, &M110, &M011, &M010, &M001, &M000);
&R208 = add(&M111, &M110, &M100);
&R209 = add(&M111, &M110, &M100, &M000);
&R210 = add(&M111, &M110, &M100, &M001);
&R211 = add(&M111, &M110, &M100, &M001, &M000);
&R212 = add(&M111, &M110, &M100, &M010);
&R213 = add(&M111, &M110, &M100, &M010, &M000);
&R214 = add(&M111, &M110, &M100, &M010, &M001);
&R215 = add(&M111, &M110, &M100, &M010, &M001, &M000);
&R216 = add(&M111, &M110, &M100, &M011);
&R217 = add(&M111, &M110, &M100, &M011, &M000);
&R218 = add(&M111, &M110, &M100, &M011, &M001);
&R219 = add(&M111, &M110, &M100, &M011, &M001, &M000);
&R220 = add(&M111, &M110, &M100, &M011, &M010);
&R221 = add(&M111, &M110, &M100, &M011, &M010, &M000);
&R222 = add(&M111, &M110, &M100, &M011, &M010, &M001);
&R223 = add(&M111, &M110, &M100, &M011, &M010, &M001, &M000);
&R224 = add(&M111, &M110, &M101);
&R225 = add(&M111, &M110, &M101, &M000);
&R226 = add(&M111, &M110, &M101, &M001);
&R227 = add(&M111, &M110, &M101, &M001, &M000);
&R228 = add(&M111, &M110, &M101, &M010);
&R229 = add(&M111, &M110, &M101, &M010, &M000);
&R230 = add(&M111, &M110, &M101, &M010, &M001);
&R231 = add(&M111, &M110, &M101, &M010, &M001, &M000);
&R232 = add(&M111, &M110, &M101, &M011);
&R233 = add(&M111, &M110, &M101, &M011, &M000);
&R234 = add(&M111, &M110, &M101, &M011, &M001);
&R235 = add(&M111, &M110, &M101, &M011, &M001, &M000);
&R236 = add(&M111, &M110, &M101, &M011, &M010);
&R237 = add(&M111, &M110, &M101, &M011, &M010, &M000);
&R238 = add(&M111, &M110, &M101, &M011, &M010, &M001);
&R239 = add(&M111, &M110, &M101, &M011, &M010, &M001, &M000);
&R240 = add(&M111, &M110, &M101, &M100);
&R241 = add(&M111, &M110, &M101, &M100, &M000);
&R242 = add(&M111, &M110, &M101, &M100, &M001);
&R243 = add(&M111, &M110, &M101, &M100, &M001, &M000);
&R244 = add(&M111, &M110, &M101, &M100, &M010);
&R245 = add(&M111, &M110, &M101, &M100, &M010, &M000);
&R246 = add(&M111, &M110, &M101, &M100, &M010, &M001);
&R247 = add(&M111, &M110, &M101, &M100, &M010, &M001, &M000);
&R248 = add(&M111, &M110, &M101, &M100, &M011);
&R249 = add(&M111, &M110, &M101, &M100, &M011, &M000);
&R250 = add(&M111, &M110, &M101, &M100, &M011, &M001);
&R251 = add(&M111, &M110, &M101, &M100, &M011, &M001, &M000);
&R252 = add(&M111, &M110, &M101, &M100, &M011, &M010);
&R253 = add(&M111, &M110, &M101, &M100, &M011, &M010, &M000);
&R254 = add(&M111, &M110, &M101, &M100, &M011, &M010, &M001);
&R255 = add(&M111, &M110, &M101, &M100, &M011, &M010, &M001, &M000);