Code covered by the BSD License  

Highlights from
Digital Karma: State Graphing

image thumbnail
from Digital Karma: State Graphing by Aman Siddiqi
Evolutionary Simulation, Interaction Graph

rules_twod_custom.m
% Neural Network
nn=a(:,:,end);
for ro = 2:(totalrows-1);
    for col = 2:(columns-1);
        neighbor1=a(ro+1,col,end); neighbor2=a(ro+1,col+1,end); neighbor3=a(ro,col+1,end); neighbor4=a(ro-1,col+1,end);
        neighbor5=a(ro-1,col,end); neighbor6=a(ro-1,col-1,end); neighbor7=a(ro,col-1,end); neighbor8=a(ro+1,col-1,end);
        neighbors=a(ro-1,col,end)+a(ro+1,col,end)+a(ro,col-1,end)+a(ro,col+1,end)+a(ro-1,col-1,end)+a(ro-1,col+1,end)+a(ro+1,col-1,end)+a(ro+1,col+1,end);
        if neighbors==1; %Moving piece or tail end on corner piece
            nn(ro,col)=1;
        end;
        if (neighbors==0 |neighbors==1 | neighbors==4 | neighbors==5 | neighbors==6 | neighbors==7 | neighbors==8);
            nn(ro,col)=0;
        end;
    end;
end;
a(:,:,end)=nn;

Contact us at files@mathworks.com