home
/
code
/
cellular-automata.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Set interval back to 0.1 sec.
[cellular-automata.git]
/
001
/
src
/
life_time.erl
diff --git
a/001/src/life_time.erl
b/001/src/life_time.erl
index
175321b
..
6827d29
100644
(file)
--- a/
001/src/life_time.erl
+++ b/
001/src/life_time.erl
@@
-21,7
+21,7
@@
-define(CHAR_DEAD, 32). % Space
-define(CHAR_ALIVE, 111). % o
-define(CHAR_DEAD, 32). % Space
-define(CHAR_ALIVE, 111). % o
--define(CHAR_BAR,
61). % =
+-define(CHAR_BAR,
45). % -
-record(state, {x :: integer()
-record(state, {x :: integer()
@@
-99,16
+99,20
@@
handle_cast({tock, {ID, CellState}},
case NewRepliesPending of
0 ->
NewGenCount = GenCount + 1,
case NewRepliesPending of
0 ->
NewGenCount = GenCount + 1,
- SortedStatePairs = lists:sort(NewStatePairs),
+ SortedStatePairs = lists:sort(
+ fun({A, _}, {B, _}) -> A < B end,
+ NewStatePairs
+ ),
StateChars = [state_to_char(S) || {_, S} <- SortedStatePairs],
StateChars = [state_to_char(S) || {_, S} <- SortedStatePairs],
- ok = do_print_bar(X),
+
ok = io:format(
"CELLS: ~b GENERATIONS: ~b~n",
[NumCells, NewGenCount]
),
ok = do_print_bar(X),
ok = io:format(
"CELLS: ~b GENERATIONS: ~b~n",
[NumCells, NewGenCount]
),
ok = do_print_bar(X),
+
ok = do_print_state_chars(X, StateChars),
ok = do_print_state_chars(X, StateChars),
- ok = do_print_bar(X),
+
ok = timer:sleep(?INTERVAL),
schedule_next_tick(),
{noreply, NewState#state{state_pairs=[], gen_count=NewGenCount}};
ok = timer:sleep(?INTERVAL),
schedule_next_tick(),
{noreply, NewState#state{state_pairs=[], gen_count=NewGenCount}};
This page took
0.027071 seconds
and
4
git commands to generate.