Elementary cellular automaton: Difference between revisions

Content added Content deleted
(add FreeBASIC)
(ECA Rule30 on the Medland map. Change phase to get other rules.)
Line 1,786: Line 1,786:
* * * * * * * *
* * * * * * * *
* * * * * * * * * * * * * * * *</lang>
* * * * * * * * * * * * * * * *</lang>

=={{header|OCTAVE}}==
<lang OCTAVE>

clear all
E=200;
idx=round(E/2);
z(1:1:E^2)=0; % init lattice
z(idx)=1; % seed apex of triangle with a single cell
A=2; % Number of bits-1 rule30 uses 3 so A=2
for n=1:1:E^2/2-E-2; % n=lines
theta=0; % theta
for a=0:1:A;
theta=theta+2^a*z(n+A-a);
endfor
x=(asin(sin (pi/4*(theta-3/4))));
z(n+E+1)=round( (4*x+pi)/(2*pi) );
endfor
imagesc(reshape(z,E,E)'); % Medland map
</lang>



=={{header|Perl}}==
=={{header|Perl}}==