X-Git-Url: https://git.xandkar.net/?a=blobdiff_plain;f=001%2Fsrc%2Flife_god.erl;h=ea3b236cdba73e6e33899b38fc6be442a0720385;hb=HEAD;hp=8000eaa8866f0791ab7a79861883a587ee276ca3;hpb=1aa9333c0dab226e2e54ea60863c9e55523d77d7;p=cellular-automata.git diff --git a/001/src/life_god.erl b/001/src/life_god.erl deleted file mode 100644 index 8000eaa..0000000 --- a/001/src/life_god.erl +++ /dev/null @@ -1,41 +0,0 @@ --module(life_god). --behaviour(supervisor). - - -%% API --export([start_link/3]). - -%% Callbacks --export([init/1]). - - -%% Helper macro for declaring children of supervisor --define(CHILD(Type, I, Args), {I, {I, start_link, Args}, permanent, 5000, Type, [I]}). - - -%% ============================================================================ -%% API -%% ============================================================================ - -start_link(X, Y, CellData) -> - supervisor:start_link({local, ?MODULE}, ?MODULE, [X, Y, CellData]). - - -%% ============================================================================ -%% Callbacks -%% ============================================================================ - -init([X, Y, CellData]) -> - CellNames = [Name || {_, Name, _} <- CellData], - RestartStrategy = {one_for_one, 1000000, 1}, - Cells = [spec_cell(Datum) || Datum <- CellData], - Time = ?CHILD(worker, life_time, [X, Y, CellNames]), - Children = Cells ++ [Time], - {ok, {RestartStrategy, Children}}. - - -spec_cell({_, Name, _}=Datum) -> - M = life_cell, - F = start_link, - A = [Datum], - {Name, {M, F, A}, permanent, 5000, worker, [M]}.