program of three-color one-dimensional CA
in
Programming Questions
•
2 years ago
Hi
I want to know how I can write a three-color totalistic one-dimensional Cellular Automata (CA) in processing ?
I know how to program the two-color one-dimensional Cellular Automata. I put the code of the two-color below.
Can anyone help me to write a program that implements three-color totalistic one-dimensional CA?
Thanks
The code of the two-color is:
int y;
int rule=129;
void setup()
{
size(256,256,P3D);
background(0);
set(width/2,0,~0);
}
void draw()
{
for(int x=1; x<width-1; x++)
{
int pix1= (get(x-1,y)&1)<<2;
int pix2= (get(x,y)&1)<<1;
int pix3= get(x+1,y)&1;
int bits=pix1+pix2+pix3;
if((rule&(1<<(bits)))>0) //test pattern in rule
set(x,y+1,~0);
}
if(++y>height)
exit();
}
1