built by Francis A. Bitonti fadarch.com
contact Francis at fa@fadarch.com

download the cellular automata library

view the source code:

This library allows you to quickly and easily implement cellular automata calculations in your processing applets.
The results from the library are accurate and have been validated against results from mathematica.

For more information on cellular automata click this link.

currently available operations:

public cellularAutomata()
this operation will make a new celularAutomata matrix.
int[] numbers = {0,0,0,1,0,0,0,0};
cellularAutomata a = new cellularAutomata(numbers);

public cellularAutomata copy()
makes a copy of a cellularAutomata matrix

public static cellularAutomata calcCA( cellularAutomata x, number of evolutions)
performs a cellular automta calculation. input the cellularAutomata matrix and the number of
times you want it to evolve.

public void setValue(int place in matrix, int value you want to set it to 1 or 0)
allows you to manually set values in the matrix.

public float getNumber(int place in matrix)
retrieve values from the cellularAutomata
int good = int(a.getNumber(i));

public int sizeCA()
returns the size of a cellularAutomata.
s = a.sizeCA();

public void setRule(int a, int b,int c,int d,int e,int f,int g,int h)
set the CA rule.

current pattern
111 110 101 100 011 010 001 000
new state for center cell int a int b int c int d ind e int f int g int h



Examples


This browser does not have a Java Plug-in.
Get the latest Java Plug-in here.



a.setRule(1,1,0,0,0,0,1,0);

This browser does not have a Java Plug-in.
Get the latest Java Plug-in here.



a.setRule(1,1,0,1,0,1,1,1);

This browser does not have a Java Plug-in.
Get the latest Java Plug-in here.



a.setRule(0,1,1,0,1,1,1,0); //RULE 110

Source code: CAsample2

built by Francis A. Bitonti fadarch.com
contact Francis at fa@fadarch.com


The behavior of this simulation will change each time you refresh your browser.

import CellularAutomata.*;

int[] numbers;
int s;
color black = color(0);
color white = color(255);
int check;
cellularAutomata a;
cellularAutomata b;

void setup(){
size(300,100);
background(255);


numbers = new int[width];

s = 0;
for (int start=0; start<(width); start++) {

s = int(random(0, 2));
numbers[start]=s;

}
//CA rule110
a = new cellularAutomata(numbers);
a.setRule(0,1,1,0,1,1,1,0);
s = a.sizeCA();

}


void draw(){

for (int i=0; i<(height); i++) {

b = cellularAutomata.calcCA(a,i);

for(int j=0; j<(width); j++) {

check = int(b.getNumber(j));
if(check == 0){
set(j, i, white);
}
if(check == 1){
set(j, i, black);
}
}
}

}

 




This browser does not have a Java Plug-in.
Get the latest Java Plug-in here.

Source code: CAsample

built by Francis A. Bitonti fadarch.com
contact Francis at fa@fadarch.com

CAsample (code):

import CellularAutomata.*;

size(200, 200);
background(255);

int s = 0;


for (int f = 1; f < 8; f = f+1) {
int[] numbers = {0,0,0,1,0,0,0,0};
cellularAutomata a = new cellularAutomata(numbers);

//CA rule110
a.setRule(0,1,1,0,1,1,1,0);
a = cellularAutomata.calcCA(a,f);
s = a.sizeCA();


for (int i = 0; i < s; i = i+1) {
int good = int(a.getNumber(i));

fill(255);
if(good == 1) { //When "i" is less than "35"...
fill(0); //...set the color to black
}
ellipse(random(width), random(height), 10, 10);

print(good);
print(",");

}
print("\n");
}