Balistic Aggregation Model
@author
int[] stacks;
void setup(){
size(300, 300);
frameRate(360);
noFill();
stroke(0);
initialize();
}
void mousePressed(){
initialize();
}
void initialize(){
background(255);
stacks = new int[width];
for(int i = 0; i < width; i++){
stacks[i] = height;
}
}
void draw(){
int x = int(random(1, width - 1));
if(stacks[x - 1] < stacks[x] && stacks[x - 1] < stacks[x + 1]){
stacks[x] = stacks[x - 1];
} else if(stacks[x + 1] < stacks[x] && stacks[x + 1] < stacks[x - 1]){
stacks[x] = stacks[x + 1];
} else {
stacks[x] -= 1;
}
point(x, stacks[x]);
}