diff --git a/test/wolfram-cellular-automaton/Makefile b/test/wolfram-cellular-automaton/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..3f567b254a37db9207e25ecec32b10a47f17ef48 --- /dev/null +++ b/test/wolfram-cellular-automaton/Makefile @@ -0,0 +1,25 @@ +# Time-stamp: <modified the 03/07/2023 (at 16:22) by Erwan Jahier> + +DECO_PATTERN="0-:p.ml" +-include ./Makefile.dot +-include ./Makefile.inc + +############################################################################## +# Non-regression tests + +test: chain10.gm_test chain10.rdbg-test demo50 clean + +# update golden-master tests (if necessary) +utest: + make chain10.ugm_test || echo "chain10 ok" + +# usage: make demo50 +demo%: + make chain$*.dot + sasa chain$*.dot --synchronous-daemon --length $(shell echo $$(( $* / 2 ))) \ + | grep outs | cut -d ' ' -f 2-$* \ + | sed -e "s/ //g" | sed -e "s/f/ /g" | sed -e "s/t/â–²/g" + + +clean: genclean + rm -f chain* diff --git a/test/wolfram-cellular-automaton/Makefile.dot b/test/wolfram-cellular-automaton/Makefile.dot new file mode 120000 index 0000000000000000000000000000000000000000..618c8ab02bdfa1c158e4fda4241e5fc0187b611c --- /dev/null +++ b/test/wolfram-cellular-automaton/Makefile.dot @@ -0,0 +1 @@ +../Makefile.dot \ No newline at end of file diff --git a/test/wolfram-cellular-automaton/Makefile.inc b/test/wolfram-cellular-automaton/Makefile.inc new file mode 120000 index 0000000000000000000000000000000000000000..b9a83c9dae3121bce33a41c0e052c2c405b90e26 --- /dev/null +++ b/test/wolfram-cellular-automaton/Makefile.inc @@ -0,0 +1 @@ +../Makefile.inc \ No newline at end of file diff --git a/test/wolfram-cellular-automaton/config.ml b/test/wolfram-cellular-automaton/config.ml new file mode 100644 index 0000000000000000000000000000000000000000..1e0e05f19ad1274feaf2190998a37dcab48e172f --- /dev/null +++ b/test/wolfram-cellular-automaton/config.ml @@ -0,0 +1,5 @@ + +let potential = None (* None => only -sd, -cd, -lcd, -dd, or -custd are possible *) +let legitimate = None (* None => only silent configuration are legitimate *) +let fault = None (* None => the simulation stop once a legitimate configuration is reached *) +let init_search_utils = None (* To provide to use --init-search *) diff --git a/test/wolfram-cellular-automaton/dune b/test/wolfram-cellular-automaton/dune new file mode 120000 index 0000000000000000000000000000000000000000..5cb715b83e3d6df4f6d2b21b7c883e6e633c30ec --- /dev/null +++ b/test/wolfram-cellular-automaton/dune @@ -0,0 +1 @@ +../dune2copy \ No newline at end of file diff --git a/test/wolfram-cellular-automaton/dune-project b/test/wolfram-cellular-automaton/dune-project new file mode 120000 index 0000000000000000000000000000000000000000..1c5c1f5066170326034eb2eb4de944b70866a2d1 --- /dev/null +++ b/test/wolfram-cellular-automaton/dune-project @@ -0,0 +1 @@ +../dune-project2copy \ No newline at end of file diff --git a/test/wolfram-cellular-automaton/dune-workspace b/test/wolfram-cellular-automaton/dune-workspace new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/test/wolfram-cellular-automaton/p.ml b/test/wolfram-cellular-automaton/p.ml new file mode 100644 index 0000000000000000000000000000000000000000..5fa45cefe91413b8421fbb9c0524ba5db9b73c11 --- /dev/null +++ b/test/wolfram-cellular-automaton/p.ml @@ -0,0 +1,39 @@ +(* Time-stamp: <modified the 10/07/2023 (at 11:36) by Erwan Jahier> *) + +(* Draw the Sierpinski triangle using Wolfram cellular automata + +https://mathworld.wolfram.com/ElementaryCellularAutomaton.html +*) + +let rule_nb = 126 (* Sierpinski rule *) +let _ = assert( 0 <= rule_nb && rule_nb <256 ) + +let rec to_bool_list n = if n = 0 then [] else (n mod 2 = 1)::(to_bool_list (n/2)) +let to_array l = + let a = Array.make 8 false in + let ll = List.length l in + List.iteri (fun i b -> a.(i+8-ll) <- b) l; a + +let rule_nb_array = rule_nb |> to_bool_list |> List.rev |> to_array + +(* For each rule, the next value (of x2) depends its value and the ones of its 2 neighbors *) +let b2i b = if b then 1 else 0 +let next x1 x2 x3 = + let index = 7 - ((b2i x1)*4 + (b2i x2)*2 + b2i x3) in + (* Printf.printf "index=%d\n%!" index; *) + rule_nb_array.(index) + +let cpt = ref 0 +let init_state _ _ = + cpt := (!cpt+1) mod Algo.card(); + let res = !cpt = Algo.card() / 2 in (* one cell is true, in the middle *) + (* Printf.printf "cell(%d)=%b\n%!" !cpt res; *) + res + + +let enable_f x2 nl = + match List.map Algo.state nl with + | [x1; x3] -> if next x1 x2 x3 = not x2 then ["flip"] else [] + | _ -> [] + +let step_f x _ _ = not x diff --git a/test/wolfram-cellular-automaton/ring.dot b/test/wolfram-cellular-automaton/ring.dot new file mode 100644 index 0000000000000000000000000000000000000000..bacf56c5919691c28fbb9f0178a43c4dbdfca30f --- /dev/null +++ b/test/wolfram-cellular-automaton/ring.dot @@ -0,0 +1,11 @@ +graph ring { + p1 [algo="p.ml"] + p2 [algo="p.ml"] + p3 [algo="p.ml"] + p4 [algo="p.ml"] + p5 [algo="p.ml"] + p6 [algo="p.ml"] + p7 [algo="p.ml"] + + p1 -- p2 -- p3 -- p4 -- p5 -- p6 -- p7 -- p1 +} diff --git a/test/wolfram-cellular-automaton/some_session b/test/wolfram-cellular-automaton/some_session new file mode 100644 index 0000000000000000000000000000000000000000..96b69b572b2550b34d05923df7442cd926d536d3 --- /dev/null +++ b/test/wolfram-cellular-automaton/some_session @@ -0,0 +1,7 @@ +n +n +n +n +wait 3 +print_event !e;; + diff --git a/test/wolfram-cellular-automaton/state.ml b/test/wolfram-cellular-automaton/state.ml new file mode 100644 index 0000000000000000000000000000000000000000..3a8ddee92a6438934703027c93b4855a9b4ec86f --- /dev/null +++ b/test/wolfram-cellular-automaton/state.ml @@ -0,0 +1,6 @@ + +type t = bool +let to_string = (fun s -> Printf.sprintf "%B" s) +let of_string = Some bool_of_string +let copy x = x +let actions = ["flip"]