1. Conway's life.
    The rule is:
    • Sum the 8 nearest neighbors
    • If the sum=2 then the state does not change
    • If the sum=3 then the state=1
    • Otherwise the state=0
    The code:
    x = 2:n-1;
    y = 2:n-1;
    %nearest neighbor sum
    sum(x,y) = cells(x,y-1) + cells(x,y+1) + ...
    cells(x-1, y) + cells(x+1,y) + ...
    cells(x-1,y-1) + cells(x-1,y+1) + ...
    cells(3:n,y-1) + cells(x+1,y+1);
    % The CA rule
    cells = (sum==3) | (sum==2 & cells);

'Biologically Inspired Images > Science' 카테고리의 다른 글

what is the Higgs?  (0) 2013.10.16
built by Francis A. Bitonti fadarch.com  (0) 2010.08.23
Moore Neighborhood  (0) 2010.08.23
von Neumann Neighborhood  (0) 2010.08.23
Cellular Automaton  (0) 2010.08.23

+ Recent posts