Print char representation of cell state.
[cellular-automata.git] / 002 / src / life.ml
index 5e9d6f5..552c1dc 100644 (file)
@@ -6,6 +6,16 @@ let directions =
   [N; NE; E; SE; S; SW; W; NW]
 
 
+let char_dead  = ' '
+let char_alive = 'o'
+
+
+let char_of_state = function
+  | 0 -> char_dead
+  | 1 -> char_alive
+  | _ -> assert false
+
+
 let offset = function
   (* direction -> x, y *)
   | N  ->  0, -1
@@ -28,7 +38,14 @@ let init_board x y =
 
 
 let print_board board =
-  Array.iter (fun row -> Array.iter (print_int) row; print_newline ()) board
+  Array.iter
+  (fun row ->
+    Array.iter
+    (fun state -> print_char (char_of_state state))
+    row;
+    print_newline ()
+  )
+  board
 
 
 let new_state = function
This page took 0.027256 seconds and 4 git commands to generate.