This library allows you to make art in Processing using cellular automata. See Conway's Game of Life for an example of a well known cellular automaton.
- Install Processing
- Download the latest automata.zip
- Extract the zip file to the "libraries" sub-folder of your Processing documents folder
- Launch Processing, go to File → Examples, and browse the Cellular Automata examples
// Import the library
import com.grough.automata.*;
// Create your own animation by extending the base class.
// Choose a data type for your cells. In this case we use Boolean.
class MyAnimation extends Automaton<Boolean> {
// Populate the initial cell values.
Boolean populate() {
return random(0, 1) < 0.5;
}
// Calculate the next cell value based on the previous cell value.
Boolean evolve() {
if (random(0, 1) < 0.1) {
return self();
} else {
return !self();
}
}
// Assign the cell a color based on its value.
int shade() {
return self() ? 0 : 255;
}
}
MyAnimation animation = new MyAnimation();
void setup() {
size(640, 640);
}
void draw() {
// Advance to the next animation frame each time we draw.
animation.next();
// Draw the animation's graphics on the screen.
image(animation.graphics(), 0, 0, 640, 640);
}