home
/
code
/
cellular-automata.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Printing bar to visually mark the borders of the board.
[cellular-automata.git]
/
001
/
life.erl
diff --git
a/001/life.erl
b/001/life.erl
index
fd3acc9
..
9c84bd8
100644
(file)
--- a/
001/life.erl
+++ b/
001/life.erl
@@
-6,11
+6,15
@@
-define(DIRECTIONS, ['N', 'NE', 'E', 'SE', 'S', 'SW', 'W', 'NW']).
-define(DIRECTIONS, ['N', 'NE', 'E', 'SE', 'S', 'SW', 'W', 'NW']).
+
-define(X, 230).
-define(X, 230).
--define(Y, 60).
+-define(Y, 58).
+
-define(INTERVAL, 0). % In milliseconds
-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).
main( ) -> bang(?X, ?Y).
@@
-80,7
+84,9
@@
tock(X, All, [], StatePairs) ->
[],
lists:sort(StatePairs)
),
[],
lists:sort(StatePairs)
),
+ ok = do_print_bar(X),
ok = do_print_states(X, States),
ok = do_print_states(X, States),
+ ok = do_print_bar(X),
ok = timer:sleep(?INTERVAL),
tick(X, All);
ok = timer:sleep(?INTERVAL),
tick(X, All);
@@
-191,5
+197,10
@@
do_print_states(X, States) ->
do_print_states(X, RestStates).
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.
state_to_char(0) -> ?CHAR_DEAD;
state_to_char(1) -> ?CHAR_ALIVE.
This page took
0.027941 seconds
and
4
git commands to generate.