Flocking
- “neu” examples
- optimization
Cellular Automata
- What
- Wolfram 1D
Class 1-4
- Game of life 2D
2D array
OOP?
- Eduges
- Variations
– hexagonal
– probabilistic
– continuous
– historical
– moving?
### ALIGNMENT
- average velocity
###COHESION

- Average Location
Calculate the center of everyone and apply force
PVector cohesion (ArrayList
PVector sum = newPVector(0,0);
or(Boid b: boids) {
sum.add(b.loc);
}
sum.div(boids.size());
PVector force = seek(sum);
return force;
}
Interesting to consider, Boids that had eyes and had periphery. Map out it’s peripheral view and maybe have it move or attract accordingly.
Collision: Can make the computational part overwhelming and frame rate will plummet.
How can we make it more effecient?
1. ArrayList to keep track of every element ONCE
2. ArrayList of a grid of screen?
-or-
1. Each “thing” register in grid
2. Check for intersection
CHECK INTERSECTION SLOW vs INTERSECTION
Random suggestion:
Making a sin/cos look up table
- useful if you need more speed (less computational work)
###CELLULAR AUTOMATA
Definition:
- grid of cells 1D, 2D, 3D…?
- each cell has a finite number of states
– 0 or 1 ([on/off??] encoding & expression/genotype & phenotype)
– a state can drive the behavior of an object
- each cell has a neighborhood
– in flocking, the state has a lot to do with what’s happening w/ neighbor and neighborhood
___ eg. one member in flock dies, surrounding dies, etc. States change from 1 to 0 or whatever.
___ eg. water coloring sketch. Center pixel has color, but surrounding cells fade out to imitate the spread of color (a lot you can do with pixels based on CA rules)
- good reading: game of life
WOLFRAM’S SYSTEM
Have to have at least 1 dimension
Does the neighborhood include itself? Yes
1. 8 combinations of 3 digits of zeros and ones: 2^3 = 8
2. 8 combinations of 2 digits of zeros and ones 2^8 = 256 total combinations
These combinations can be divided into 4 classes:
class 1 – homogenous
class 2 – oscillating (“pattern”)
class 3 – random (“chaotic”)
class 4 – 2&3 together (“complexity”)
Though this really really basic process of 1s & 0s, we can generate patterns of randomness.
mathworld.wolfram.com/ElementaryCellularAutomaton.html
“Digital Physics” – can all of our world be descibed in a series of zeros and ones.
- there’s a book about it that starts with a Z.
EDGES: They may not have neighbors. What to do?
Common Options:
1. Treat them as a constant
2. Create an edge rule set
3. Wrap around **most common solution**
Why relevant to projects we may do:
1D CA vs 2D CA
1D – look to your neighbors left & right: 3 cells total
2D – look up, down, left, right (all around): 9 cells total
1- (0 or 1)
0 – (1 or 0)
3 real possible outcomes.
Birth
Death
Stasis
2D array
array [][]
Reads the old array, writes a new array, then re-writes to the original
int[][] old_board, new_board;
-or-
OOP
Cell[][] grid;
- You can explore a hexagonal pattern
- Or a probabilistic approach. Having a 90% chance of dying instead of just dying. They dont’ have to be so precise and accurate
- maybe determine things based on it’s history. How long it’s been around etc. If it’s been alive for 50 frames in a row, maybe it’s brighter etc.
3D – 27 neighbors!!
- just a lot more coding to do
FRACTAL – shape that when broken into parts, parts, approximate the whole
- when broken into small parts, is identical to whole

Fractal Broccoli

- natural forms that cannot be described Euclidian geometry
- self-similar structure
- defined with a recursive function (code friendly)
- fine structures at small scales
– when you zoom into fractal the pattern repeats itself
Production rule
1. line segment
2. cut into 4 lines
3. each of those segments are then cut into 4 lines again… and repeat
Koch Curve -or- Koch Snowflake


Theoretically, INFINITE lines being created in a limited space – may explain why this pattern appears so often in nature. Evolutions, tends towards it…blood vessels, leopard spots, ferns…
Because of this parado of infinite growth in limited space sometimes called Koch Monster
CONTINUATION OF TREE DATA/LISTSERV VIZ:
Fractal tree: has to control, but in combination with ArrayLists, to draw leaves/ellipses at the ends of the branches
LSYSTEM
“Strangely foreshadowing… cellular automata…au-tah-mah-tah? auto-mah-tah? *mumbles away*”









