X-Git-Url: https://git.xandkar.net/?a=blobdiff_plain;f=001%2Fsrc%2Flife_time.erl;h=1b639a7326528f27a9a0fc806f8bf7ce8b968024;hb=3803d7be41afd2665d4e29850bf6327173a19ddd;hp=175321bb09b20f7458a3e9a7e898185da8e25829;hpb=81dbcc6e73c3bf9eba9f237b3db1d7a9de658ee0;p=cellular-automata.git diff --git a/001/src/life_time.erl b/001/src/life_time.erl index 175321b..1b639a7 100644 --- a/001/src/life_time.erl +++ b/001/src/life_time.erl @@ -17,11 +17,11 @@ ]). --define(INTERVAL, 100). % In milliseconds +-define(INTERVAL, 0). % In milliseconds -define(CHAR_DEAD, 32). % Space -define(CHAR_ALIVE, 111). % o --define(CHAR_BAR, 61). % = +-define(CHAR_BAR, 45). % - -record(state, {x :: integer() @@ -99,16 +99,20 @@ handle_cast({tock, {ID, CellState}}, 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], - 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_bar(X), + ok = timer:sleep(?INTERVAL), schedule_next_tick(), {noreply, NewState#state{state_pairs=[], gen_count=NewGenCount}};