Genes

The Bibites have genes that dictate some of their characteristics and behaviors.

These are specific and unique for each Bibites and will mutate through generations according to mutation settings and specific genes influencing mutations like Mutation Chance (gene) and Mutation Variance (gene).

## Mutation and Evolution

Every time a new egg is laid, it will inherit its parent's genes, with possible mutations.

The mutation process of genes is governed by two main genes : Mutation Chance and Mutation Variance.

Whenever the genetic code has the possibility to mutate (for now only whenever a new bibite is born), a random number of mutation events will be generated.

The actual number of mutation events will be decided by the Mutation Chance gene, following a Poisson distribution. Then, for each mutation event, a random gene will be selected (all equally probable). The new amount by which that gene's value will vary (relative to its present value) is randomly generated using the Mutation Variance gene following a Gaussian Distribution.

In order to generate a uniform variation and prevent a biased mutation process that would force variation in a particular direction, the following formula is used to generate the mutation value:

# u
G
a
u
s
s
i
a
n
(

x
¯

=
0
,
# σ
1
)

{\displaystyle u = Gaussian(\bar{x} = 0, \sigma = 1)}

 //We generate a random value following a gaussian distribution

# v
(
1
M
u
t
a
t
i
o
n
V
a
r
i
a
n
c
e

)

u

{\displaystyle v = (1 + Mutation Variance)^{u}}

 //We use that value to scale the variation uniformly in any direction

N
e
w
G
e
n
e
V
a
l
u
# e
v
∗
P
r
e
v
i
o
u
s
G
e
n
e
V
a
l
u
e

{\displaystyle New Gene Value = v\* PreviousGeneValue}

 //Influences the previous gene's value relatively

A far smaller absolute variation will also be added on top following again a gaussian distribution based on the mutation variance. This is done to also allow for non-relative variation since purely relative variation could cause some edge-cases like getting a gene stuck at 0 and unable to change. That absolute value is calculated as follow:

# u
G
a
u
s
s
i
a
n
(

x
¯

=
0
,
# σ
0.01
M
u
t
a
t
i
o
n
V
a
r
i
a
n
c
e

/

20
)

{\displaystyle u = Gaussian(\bar{x} = 0, \sigma = 0.01 + Mutation Variance/20)}

//Generate a random value again

N
e
w
G
e
n
e
V
a
l
u
# e
P
r
e
v
i
o
u
s
G
e
n
e
V
a
l
u
e
u

{\displaystyle New Gene Value = PreviousGeneValue + u}

 //Influences the previous gene's value

This process is completely random and has no implicit bias. As a result, it's very possible that a mutation occurs which would leave the Bibite worse-off and less adapted to its environment. Natural selection is the only mechanism by which evolution will occur, allowing more adapted Bibites to better compete for food and energy.

## List of all Bibite Genes

This is a list of all the genes possessed by a bibite. All Bibites have their own copy of those genes.

* Red Color
* Green Color
* Blue Color
* Gene Mutation Chance
* Gene Mutation Variance
* Brain Mutation Chance
* Strength
* Defence
* Diet
* Size Ratio
* Speed Ratio
* Lay Time
* Brood Time
* Hatch Time
* Mouth Strength
* View Angle
* View Radius
* Internal Clock Period
* Pheromone Sensibility
* Base Immune Activation
* Herd Separation Weight
* Herd Alignment Weight
* Herd Cohesion Weight
* Herd Velocity Weight
* Herd Separation Distance
* Growth Scale
* Growth Maturity Factor
* Growth Maturity Exponent

In some cases, a Bibite could not present any behavior or use of a particular genes while still displaying a value for it. As an example, Bibites could have a genetic Internal Clock Period of 1.27s while not having any brain connections making use of their internal clock.