(* Time-stamp: <modified the 09/03/2019 (at 12:47) by Erwan Jahier> *) (* This is algo 5.3 in the book *) open Algo let vars = ["d",It] let d=10 let (init_vars: neighbor list -> local_env) = fun _nl -> function _ -> I (Random.int d) let (enable_f:neighbor list -> local_env -> action list) = fun nl e -> if (e "d") <> I 0 then ["CD"] else [] let (step_f : neighbor list -> local_env -> action -> local_env) = fun nl e -> function | _ -> (function "d" -> I 0 | _ -> assert false) let () = let algo_id = "root" in Algo.reg_vars algo_id vars; Algo.reg_init_vars algo_id init_vars; Algo.reg_enable algo_id enable_f; Algo.reg_step algo_id step_f; ()