open Acml type etat = L | R |N | G let transi x = let (a, b, c) = (x.(0),x.(1),x.(2)) in match b with R -> (match (a,c) with (R,x) -> if x = N then G else x | (L,_) -> L | (N,x) -> if x = G then L else N | (G,x) -> if x = R then L else G ) | L -> (match (a,c) with (R,x) -> if x = L then R else x | (L,x) -> if x = N then G else if x = G then N else R | (N,x) -> if x = G then N else R | (G,x) -> if x = R or x=L then R else G ) | N -> (match (a,c) with (R,x) -> if x = L then G else if x = G then L else x | (L,x) -> if x = R then N else L | (N,(R|G)) -> R | (N,L) -> N | (N,N) -> L | (G,(L)) -> G | (G,(R)) -> L | (G,N) -> R | (G,G) -> G ) | G -> (match (a,c) with (R,x) -> if x = L then N else x | (L,x) -> if x = R then G else L | (N,R) -> G | (N,L) -> L | (N,N) -> R | (N,G) -> N | (G,(N|L)) -> G | (G,R) -> R | (G,G) -> N ) let background start pos = if (pos - start) mod 2 = 0 then 0 else 1 let alphabet = AlphaArray [|L;R;N;G|] let maker a = ( set_dimension a 1; set_moore_neighbourhood a 1; set_name a "Universal 4-states"; poly_set_rule a ~alphabet transi; add_colormap a ~set:true "Custom 4-states" (fun i -> (Array.map (fun (a,b,c) -> Unicolor (a,b,c)) [|(50,50,50);(254,254,254);(0,0,200);(150,150,254)|]).(i)); add_modif a "Background left" (GeneralZone (fun c (start,_,_,_) pos dc -> background start pos)); add_modif a "Background right" (GeneralZone (fun c (start,_,_,_) pos dc -> background start (pos+1))); add_modif a "Dark" (Forced 2); add_modif a "Light" (Forced 3); ) let _ = valid maker