From: Siraaj Khandkar Date: Sat, 21 Jul 2012 16:37:48 +0000 (-0400) Subject: Printing bar to visually mark the borders of the board. X-Git-Url: https://git.xandkar.net/?a=commitdiff_plain;h=a3eea437ed58b7e8b20ce05cfca86747396a58b9;p=cellular-automata.git Printing bar to visually mark the borders of the board. --- diff --git a/001/life.erl b/001/life.erl index fd3acc9..9c84bd8 100644 --- a/001/life.erl +++ b/001/life.erl @@ -6,11 +6,15 @@ -define(DIRECTIONS, ['N', 'NE', 'E', 'SE', 'S', 'SW', 'W', 'NW']). + -define(X, 230). --define(Y, 60). +-define(Y, 58). + -define(INTERVAL, 0). % In milliseconds --define(CHAR_DEAD, <<" ">>). --define(CHAR_ALIVE, <<"o">>). + +-define(CHAR_DEAD, $-). +-define(CHAR_ALIVE, $O). +-define(CHAR_BAR, $=). main( ) -> bang(?X, ?Y). @@ -80,7 +84,9 @@ tock(X, All, [], StatePairs) -> [], lists:sort(StatePairs) ), + ok = do_print_bar(X), ok = do_print_states(X, States), + ok = do_print_bar(X), ok = timer:sleep(?INTERVAL), tick(X, All); @@ -191,5 +197,10 @@ do_print_states(X, States) -> do_print_states(X, RestStates). +do_print_bar(X) -> + Chars = [$+ | [?CHAR_BAR || _ <- lists:seq(1, X - 1)]], + io:format("~s~n", [Chars]). + + state_to_char(0) -> ?CHAR_DEAD; state_to_char(1) -> ?CHAR_ALIVE.