Skip to content
Snippets Groups Projects
Commit 6adad1cb authored by erwan's avatar erwan
Browse files

test: add a Sierpinski triangle generation based on cellular automata

parent 463e719e
No related branches found
No related tags found
No related merge requests found
...@@ -19,6 +19,7 @@ test: ...@@ -19,6 +19,7 @@ test:
cd toy-example-a5sf/ && make test cd toy-example-a5sf/ && make test
cd k-clustering/ && make test cd k-clustering/ && make test
cd ghosh/ && make test cd ghosh/ && make test
cd sierpinski/ && make test
echo "Every test went fine!" echo "Every test went fine!"
clean: clean:
...@@ -42,6 +43,7 @@ clean: ...@@ -42,6 +43,7 @@ clean:
cd toy-example-a5sf/ && make clean cd toy-example-a5sf/ && make clean
cd k-clustering/ && make clean cd k-clustering/ && make clean
cd ghosh/ && make clean cd ghosh/ && make clean
cd sierpinski/ && make clean
utest: utest:
cd skeleton/ && make test cd skeleton/ && make test
...@@ -63,5 +65,6 @@ utest: ...@@ -63,5 +65,6 @@ utest:
cd toy-example-a5sf/ && make utest cd toy-example-a5sf/ && make utest
cd k-clustering/ && make utest cd k-clustering/ && make utest
cd ghosh/ && make utest cd ghosh/ && make utest
cd sierpinski/ && make utest
-include Makefile.untracked -include Makefile.untracked
# Time-stamp: <modified the 27/02/2023 (at 16:05) by Erwan Jahier> # Time-stamp: <modified the 30/06/2023 (at 17:41) by Erwan Jahier>
# #
# Define some default rules that ought to work most of the time # Define some default rules that ought to work most of the time
# #
...@@ -112,3 +112,6 @@ endif ...@@ -112,3 +112,6 @@ endif
%.rdbgui: %.cma %.rdbgui: %.cma
ledit -h rdbg-history -x rdbgui4sasa -sut "sasa $*.dot" -l 10000 ledit -h rdbg-history -x rdbgui4sasa -sut "sasa $*.dot" -l 10000
%.simu:
make $*.rdbgui4sasa
# 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*
../Makefile.dot
\ No newline at end of file
../Makefile.inc
\ No newline at end of file
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 *)
../dune2copy
\ No newline at end of file
../dune-project2copy
\ No newline at end of file
(* Time-stamp: <modified the 03/07/2023 (at 16:19) by Erwan Jahier> *)
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
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
}
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"]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment