Right... THAT's how you pass a curried infix.
[cellular-automata.git] / forest-fire / 001 / src / forest_fire.ml
index 272815f..bd2ed19 100644 (file)
@@ -138,6 +138,8 @@ let new_state = function
 
 
 let print_forest forest =
+  term_reset ();
+
   Array.iter
   (
     fun row ->
@@ -166,7 +168,7 @@ let next_generation forest (width, height) prob =
           let neighbors = List.map (fun (ox, oy) -> ox + ix, oy + iy) offsets in
           let neighbors = List.filter (is_onside width height) neighbors in
           let neighbor_states = List.map (fun (x, y) -> forest.(y).(x)) neighbors in
-          let burning_states = List.filter (fun s -> s == Burning) neighbor_states in
+          let burning_states = List.filter ((==) Burning) neighbor_states in
           new_state (state, (List.length burning_states), prob)
       )
       row
@@ -175,10 +177,12 @@ let next_generation forest (width, height) prob =
 
 
 let rec burn forest size prob interval =
-  term_reset ();
   print_forest forest;
-  minisleep interval;
-  burn (next_generation forest size prob) size prob interval
+
+  if interval > 0.0 then minisleep interval;
+
+  let next_forest = next_generation forest size prob in
+  burn next_forest size prob interval
 
 
 let main argv =
@@ -188,6 +192,7 @@ let main argv =
   let forest = init_forest opts.size opts.prob in
 
   term_clear ();
+
   burn forest opts.size opts.prob opts.interval
 
 
This page took 0.018638 seconds and 4 git commands to generate.