Rule30: Difference between revisions

615 bytes added ,  2 years ago
Algebraic recurrence relation for rule 30,
(Wolfram "Rule 30" cellular automata)
 
(Algebraic recurrence relation for rule 30,)
 
(7 intermediate revisions by 2 users not shown)
Line 1:
{{alertbox|Pink|Duplicate of task [[Elementary cellular automaton/Random Number Generator]] please merge with that page pending deletion.}}
 
 
[[Category:Cellular Automata]]
{{task|Rule 30}} '''Rule 30''' is a simple binary cellular automaton introduced by Stephen Wolfram on his book "A New Kind of Science" (1983).
 
This rule is of particular interest because it produces complex, seemingly random patterns from simple, well-defined rules. Because of this, Wolfram believes that Rule 30, and cellular automata in general, are the key to understanding how simple rules produce complex structures and behaviour in nature.
 
Rule 30 has also been used as a random number generator in Mathematica,[3] and has also been proposed as a possible stream cipher for use in cryptography.
 
;Task:
Write a program that prints out the evolution of the rule 30th30 1-dimensionalon 1D celular automata as consecutive rows of ASCII characters. all formingShowing the classic triangle:
 
<center>
. . . . . . . . . . . . . . . . . . . . . . . # . . . . . . . . . . . . . . . . . . . . . . .
Line 35 ⟶ 39:
</center>
 
(For standarizationstandardization propuseproposes, use rows of 8050 cells, and just run the 40first 25th iterations.)
 
For standarization propuse, use rows of 80 cells, and just run the 40 iterations.
 
=={{header|C}}==
Line 43 ⟶ 47:
<lang c>
#include <stdio.h>
#define N 8050
#define N_ITER 4025
 
int rule30(int x1, int x2, int x3){
int out= return !((x1 & (x2 | x3)) | (!x1 & !x2 & !x3));
return out;
}
 
Line 68 ⟶ 71:
}
printf("\n");
temp=p1;p1=p2;p2=temp; //swap array's pointers del array
}
 
return 0;
}</lang>
 
 
=={{header|Octave}}==
<lang OCTAVE>
clear all
E=256;
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 rule30 uses 3
for n=1:1:E^2/2-E-2; % lines
theta=0; % theta
for a=0:1:A;
theta=theta+2^a*z(n+A-a);
endfor
delta=(asin(sin (pi/4*(theta-3/4))));
z(n+E+1)=round( (4*delta + pi) / (2*pi) );
endfor
imagesc(reshape(z,E,E)');
</lang>
Anonymous user