X-Git-Url: https://git.xandkar.net/?a=blobdiff_plain;f=polymorphism%2F001%2Fsrc%2Fpolymorphism.ml;h=3c90972c2f30b410ba86bf3c088d30db254d8722;hb=029c4a1fb08156883feafa3b0d0008bf06304b88;hp=aae480b44315dc5f5462444244290a12eb99ab58;hpb=3ac904c025187fa279cb311a7fa0ce668c85fa4c;p=cellular-automata.git diff --git a/polymorphism/001/src/polymorphism.ml b/polymorphism/001/src/polymorphism.ml index aae480b..3c90972 100644 --- a/polymorphism/001/src/polymorphism.ml +++ b/polymorphism/001/src/polymorphism.ml @@ -187,7 +187,7 @@ module type RULE = sig end -module Conway : RULE = struct +module Life : RULE = struct type state = D | A let state_of_string : (string -> state) = function @@ -290,9 +290,8 @@ module ForestFire : RULE = struct let f = 0.000001 (* Probability of spontaneous ignition *) let p = 0.1 (* Probability of spontaneous growth *) - let is_probable = function - | probability when (Random.float 1.0) <= probability -> true - | _ -> false + let is_probable p = + (Random.float 1.0) <= p let next state ~burning_neighbors = match state, burning_neighbors with @@ -388,7 +387,7 @@ let main () = let rows, columns = Or_error.ok_exn Linux_ext.get_terminal_size () in let interval = 0.1 in let rules = - [ (module Conway : RULE) + [ (module Life : RULE) ; (module ForestFire : RULE) ] in