Aslak Grinsted‎ > ‎Misc. Debris‎ > ‎

Game of Life

posted Feb 8, 2010, 1:20 AM by Aslak Grinsted   [ updated Feb 8, 2010, 1:55 AM ]
Here's a very short version of Conways Game of Life for Matlab. In fact it is so short that it would fit in a tweet:

a=rand(128)>0.8;
for ii=1:500
  spy(a);
  drawnow;
  a=abs(filter2(ones(3),a)*2-6-a)<2;
end

And here's a High-life version:

a=rand(256)>0.8;
for ii=1:500
spy(a);
drawnow;
f=filter2(ones(3),a);
a=(f-6)+2*a==0|f==3;
end







Cellular automata are fun. Here's an automaton which generates labyrinths (although i am not sure if it technically fits the classification).



And here's the matlab code which generates the above video:

c=-ones(5); c(2:4,2:4)=2; c(3,3)=13; c=c/8;
A=rand(300,400)>.995;
for ii=1:600
  A=max(min(filter2(c,A),1),0);
  imagesc(A==0);
  drawnow;
end


This is based on a music visualisation for WinAmp AVS i made years ago.
Comments