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 X and Y in the status bar.
[cellular-automata.git]
/
001
/
src
/
life_time.erl
diff --git
a/001/src/life_time.erl
b/001/src/life_time.erl
index
6827d29
..
6f9d859
100644
(file)
--- a/
001/src/life_time.erl
+++ b/
001/src/life_time.erl
@@
-3,7
+3,7
@@
%% API
%% API
--export([start_link/
2
+-export([start_link/
3
,tock/2
]).
,tock/2
]).
@@
-25,6
+25,7
@@
-record(state, {x :: integer()
-record(state, {x :: integer()
+ ,y :: integer()
,cells :: list(atom())
,num_cells :: integer()
,state_pairs :: list(tuple(integer(), integer())) | []
,cells :: list(atom())
,num_cells :: integer()
,state_pairs :: list(tuple(integer(), integer())) | []
@@
-37,9
+38,9
@@
%% API
%% ============================================================================
%% API
%% ============================================================================
-start_link(X, Cells) ->
+start_link(X,
Y,
Cells) ->
ServerName = {local, ?MODULE},
ServerName = {local, ?MODULE},
- Args = [X, Cells],
+ Args = [X,
Y,
Cells],
Opts = [],
gen_server:start_link(ServerName, ?MODULE, Args, Opts).
Opts = [],
gen_server:start_link(ServerName, ?MODULE, Args, Opts).
@@
-52,8
+53,9
@@
tock(CellID, CellState) ->
%% Callbacks
%% ============================================================================
%% Callbacks
%% ============================================================================
-init([X, Cells]) ->
+init([X,
Y,
Cells]) ->
State = #state{x=X
State = #state{x=X
+ ,y=Y
,cells=Cells
,num_cells=length(Cells)
,state_pairs=[]
,cells=Cells
,num_cells=length(Cells)
,state_pairs=[]
@@
-86,6
+88,7
@@
handle_cast(next_tick,
handle_cast({tock, {ID, CellState}},
#state{x=X
handle_cast({tock, {ID, CellState}},
#state{x=X
+ ,y=Y
,state_pairs=StatePairs
,replies_pending=RepliesPending
,gen_count=GenCount
,state_pairs=StatePairs
,replies_pending=RepliesPending
,gen_count=GenCount
@@
-106,8
+109,8
@@
handle_cast({tock, {ID, CellState}},
StateChars = [state_to_char(S) || {_, S} <- SortedStatePairs],
ok = io:format(
StateChars = [state_to_char(S) || {_, S} <- SortedStatePairs],
ok = io:format(
- "CELLS: ~b GENERATIONS: ~b~n",
- [NumCells, NewGenCount]
+ "
X: ~b Y: ~b
CELLS: ~b GENERATIONS: ~b~n",
+ [
X, Y,
NumCells, NewGenCount]
),
ok = do_print_bar(X),
),
ok = do_print_bar(X),
This page took
0.03243 seconds
and
4
git commands to generate.