X-Git-Url: https://git.xandkar.net/?a=blobdiff_plain;f=001%2Fsrc%2Flife_cell.erl;h=4ee07acdd3b09b70fd667726b55eda7f1052e361;hb=bdfda001fb7cb77f29552bca0071ff3d389b5fd7;hp=9f7b1717d3fd6eafd0f713bb13ac103a1d052c63;hpb=90456d0857c0e6ac3f9550cc18f27ad158fa8dd8;p=cellular-automata.git diff --git a/001/src/life_cell.erl b/001/src/life_cell.erl index 9f7b171..4ee07ac 100644 --- a/001/src/life_cell.erl +++ b/001/src/life_cell.erl @@ -73,11 +73,11 @@ handle_cast({next_gen, GenID}, ,early_msgs=EarlyMsgs }=State) -> - ok = cast_one2all(Neighbors, {state_broadcast, GenID, CellState}), + ok = life_lib:cast_one2all(Neighbors, {state_broadcast, GenID, CellState}), % Put stashed messages back in the mailbox, % now that we're ready to handle them - ok = cast_all2one(Name, EarlyMsgs), + ok = life_lib:cast_all2one(Name, EarlyMsgs), NewState = State#state{replies_pending=NumNeighbors ,gen_id=GenID @@ -141,20 +141,6 @@ handle_cast(_Msg, State) -> %% Internal %% ============================================================================ -% Cast all messages to one destination -cast_all2one(_, []) -> ok; -cast_all2one(Server, [Msg | Msgs]) -> - ok = gen_server:cast(Server, Msg), - cast_all2one(Server, Msgs). - - -% Cast one message to all destinations -cast_one2all([], _) -> ok; -cast_one2all([Server | Servers], Msg) -> - ok = gen_server:cast(Server, Msg), - cast_one2all(Servers, Msg). - - new_state(1, LiveNeighbors) when LiveNeighbors < 2 -> 0; new_state(1, LiveNeighbors) when LiveNeighbors < 4 -> 1; new_state(1, LiveNeighbors) when LiveNeighbors > 3 -> 0;