From: Siraaj Khandkar Date: Mon, 6 Aug 2012 19:30:18 +0000 (-0400) Subject: Print char representation of cell state. X-Git-Url: https://git.xandkar.net/?a=commitdiff_plain;ds=inline;h=d91a53d58008caf9fa9459e3d7474e1c7c3f63d8;p=cellular-automata.git Print char representation of cell state. --- diff --git a/002/src/life.ml b/002/src/life.ml index 5e9d6f5..552c1dc 100644 --- a/002/src/life.ml +++ b/002/src/life.ml @@ -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