cellular automaton GH2 ; /* Greenberg Hastings CA */ type celltype = 0..2; const dimension = 2; distance = 1; group neighbors2 = {*[0,1],*[0,-1],*[1,0],*[-1,0]}; initial [2] ~ x = lx/3 and (y = ly/2+2 or y = ly/2+3) ; [1] ~ x+1 = lx/3 and (y = ly/2+2 or y = ly/2+3) ; color [255,0,0] ~ *[0,0] = 2; [255,255,0] ~ *[0,0] = 1; var c: celltype; rule begin if *[0,0] = 0 then if one( c in neighbors2 : c = 2 ) then *[0,0] := 2 else *[0,0] := 0 else *[0,0] := *[0,0] - 1; end;