Brain

The Bibites is built upon one idea. that creatures can evolve to become better at what they do best; *survive*.

Their brain follows a custom algorithm loosely based on the rt-NEAT algorithm.

Bibites can evolve nodes and synapses in order to connect their Sensory Layer (input nodes) to their Behavior Layer (output nodes), resulting in complex behaviors which are dependent on the perceived state of their surroundings, as well as their internal state. List of Input and Output Neurons here.

At every frame of the simulation, their senses are recorded and their brain connections are processed in order to compute the activation level of every neuron of their Behavioral Layer. The behavioral layer is then used by the Bibite's system to produce its actual behavior.

A pdf linked in the simulation has some good information on the brains, starting on page 3.

## Mutations

The structure, as well as the tuning of that brain structure, can change through mutations, and be subject to natural selection.

The mutation process is similar to the genetic mutation process in the sense that a gene (Brain mutation Chance) is used to randomly select how many (or any at all) mutation events occur when a new Bibite is birthed.

If a mutation event is triggered, we then have to determine what type of mutation the brain undergoes.

#### Possible brain mutations

* Change Synapse Strength
* Flip Synapse Strength
* Toggle Synapse (disable/enable)
* Add a new Synapse
* Remove an existing Synapse
* Change a Neuron's Activation Function
* Adding of a new Neuron
* Removing an existing Neuron

The probability of each happening is decided by related Simulation Settings:

#### Brain mutation settings

* Synapse Mutation Chance
* Neuron Mutation Chance
* Synapse Change Chance
* Synapse Flip Chance
* Synapse Toggle Chance
* Synapse Add Chance
* Synapse Remove Chance
* Neuron Change Chance
* Neuron Add Chance
* Neuron Remove Chance

It is important to note that Input and Output Neurons are locked and can't be subjected to mutation. Only Hidden Neurons can mutate and evolve. No restrictions are placed on synapses since they are not part of the fixed structures.

## List of Neurons

Bibites can grow to have an infinite number of neurons and synapses (aside from energy limitations). However, they have a fixed (for now) number of Input neurons on their sensory layer and of output neurons in their behavioral layer. There is a more complete list here.

### Input Neurons

Bibites have a fixed number of input neurons based around specific systems, which serves as senses for the bibites. They are updated each frames from the Bibite's internal state and it's environment.

Metabolic

* Constant
* Energy Ratio
* Maturity
* Stomach Fullness
* Health Ratio
* Infection Ratio

Behavioral

* Speed
* Is Grabbing Object

Internal Clock

* Tic (heartbeat)
* Time Alive (age)
* Minute (internal chronometer)

Vision

* Bibite Concentration Closeness
* Bibite Concentration Angle
* Number of Visible Bibites
* Closest Bibite Red Color
* Closest Bibite Green Color
* Closest Bibite Blue Color
* Plant Concentration Closeness
* Plant Concentration Angle
* Number of Visible Plants
* Meat Concentration Closeness
* Meat Concentration Angle
* Number of Visible Meats

Pheromones

* Red Pheromone Strength
* Blue Pheromone Strength
* Green Pheromone Strength
* Red Pheromone Direction
* Blue Pheromone Direction
* Green Pheromone Direction
* Red Pheromone Heading (not yet implemented)
* Blue Pheromone Heading (not yet implemented)
* Green Pheromone Heading (not yet implemented)

### Output Neurons

Bibites then have a fixed number of output neurons, which are used to update their behavior and interaction with their environment.

* Accelerate
* Rotate
* Herding Desire
* Lay Desire
* Eat Desire
* Stomach Activation (Digestion)
* Grab
* Reset Clock (internal clock)
* Red Pheromone Production
* Green Pheromone Production
* Blue Pheromone Production
* Growth
* Healing Strength
* Want to Attack (aggressiveness)
* Immune System Activation