Printing bar to visually mark the borders of the board.
authorSiraaj Khandkar <siraaj@khandkar.net>
Sat, 21 Jul 2012 16:37:48 +0000 (12:37 -0400)
committerSiraaj Khandkar <siraaj@khandkar.net>
Sat, 21 Jul 2012 16:37:48 +0000 (12:37 -0400)
001/life.erl

index fd3acc9..9c84bd8 100644 (file)
@@ -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.
This page took 0.02604 seconds and 4 git commands to generate.