(* Time-stamp: <modified the 21/06/2019 (at 17:54) by Erwan Jahier> *) (* This is algo 5.3 in the book *) open Algo open P let (init_state: int -> 'v) = fun i -> { P.d = Random.int P.d; P.par = -1; } let (enable_f:'v neighbor list -> 'v -> action list) = fun nl st -> if st.d <> 0 then ["CD"] else [] let (step_f : 'v neighbor list -> 'v -> action -> 'v) = fun _nl st -> function | _ -> { st with P.d = 0 } let () = Algo.register { algo = [ { algo_id = "root"; init_state = init_state; actions = Some ["CD"]; enab = enable_f; step = step_f; }; { algo_id = "p"; init_state = P.init_state; actions = Some P.actions; enab = P.enable_f; step = P.step_f; } ]; state_to_string = P.state_to_string; state_of_string = (Some P.parse_state); copy_state = P.copy_state; }