Project: atomswarm / Class: AtomGenetic

Processing swarm classes with genetic and metabolic extensions.

Class: AtomGenetic

Subclass of Atom.

Adds a virtual genome and hormone set, and modulates these hormones over time as per the system's specifications.


Variables

  • float gene[] - array of genetic values ranging [0..1], with indices G_XXXX defined in AtomGenConst.
  • float hormone[] - array of hormonal values ranging [-1..1], with indices H_XXXX defined in AtomGenConst.
  • AtomGenetic parent - reference to the peer that gave birth to this agent (or null)

Methods

AtomGenetic (AtomSwarmGenetic swarm)
Allocates a new agent in the given swarm and initialises its genome and hormone set to uniformly random values. Must then be added to that swarm's agent list with swarm.add(atom).
void eat (AtomFood food)
Consumes the specified food object, removing it from the swarm's environment and increasing the agent's H_LEPTIN level.
AtomGenetic reproduce ()
Creates a new 'offspring' agent with the same class as the parent. Spawns at the parent's x/y position ±10 pixels, and duplicates the parent's genome, with each chromosome varied by ±w_gene_variation (default 0.1), and mutated to a uniformly random value with probability w_gene_mutate_chance (default 0.05).
void calculateMetabolism ()

Calculates the agent's current hormonal levels based on its previous levels, its age and genome, and the time within the swarm. Destroys agent if its hormonal levels reach fatal values (see specifications).

Called each frame by the agent's move() method.

void calculateVector ()
Calculates the agent's current vector based on the environment's physical rule set modified by the agent's genome and metabolic state.