Rename Conway to Life.
[cellular-automata.git] / polymorphism / 001 / src / polymorphism.ml
index 6cf2d8e..3c90972 100644 (file)
@@ -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
@@ -288,11 +288,10 @@ module ForestFire : RULE = struct
     Random.int 3 |> state_of_int |> cell_of_state
 
   let f = 0.000001  (* Probability of spontaneous ignition *)
-  let p = 0.1   (* Probability of spontaneous growth *)
+  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
This page took 0.022787 seconds and 4 git commands to generate.