Skip to content
Snippets Groups Projects
root.ml 721 B
Newer Older
(* Time-stamp: <modified the 11/06/2019 (at 16:38) 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 ->
    set empty_env "d" (I (Random.int d))
let (enable_f:neighbor list -> local_env -> action list) =
  fun nl e ->
    if (get e "d") <> I 0 then ["CD"] else []
let (step_f : neighbor list -> local_env -> action -> local_env) =
  fun nl e ->
    function  | _ -> set e "d" (I 0)

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;
  Algo.reg_actions   algo_id ["CD"];