Project: atomswarm / Class: AtomSwarm
- classes:
- Atom
- AtomGenetic
- AtomSwarm
- AtomSwarmGenetic
- AtomFood
Processing swarm classes with genetic and metabolic extensions.
Class: AtomSwarm
Encapsulates a population of Atom objects.
Variables
- Atom [] atoms - array containing the swarm's population of agents
- int size - size of the current population
- float meanX, meanY - mean X/Y positions across the current population
- float meanvX, meanvY - mean X/Y velocities across the current population
- float age - the age (in frames) of the swarm as a whole
- float rate - rate at which swarm movement is depicted
- boolean paused - is the swarm currently paused?
Methods
AtomSwarm ()
Creates a new swarm with empty population.
void add (Atom atom))
Adds an atom to the swarm.
void remove (Atom atom)
Removes an atom from the swarm.
void scatter()
Iterates through the swarm and calls each agent's scatter() method.
void calculateNorms()
Calculates meanX, meanY, meanvX, meanvY based on the swarm's current population.
void move ()
Iterates through the swarm and calls each agent's move() method. To be called each frame.
void display ()
Iterates through the swarm and calls each agent's display() method. To be called each frame after move().
void destroy ()
Iterates through the swarm and calls each agent's destroy() method.

