Mutation Mechanics

Mutations are a fickle thing, both in the real world and the simulated. Not only do mutations allow agent traits to vary between generations, the exact chances and magnitudes that agents balance into change almost every version number as refinements and tweaks are made to the code.

Mutation Mechanics Overview

Agents have four trait values: brain_mutation_chance, brain_mutation_size, gene_mutation_chance, and gene_mutation_size.

  • The "chance" values hold a number, typically between (0,1) but sometimes exceeding 1, that indicates the chance that a certain type of mutation will occur (usually modified by hard-coded multipliers). A random float in range (0,1) is picked and, if it's less than the chance value, the mutation can occur.

  • The "size" values hold a different number that is also in range (0,1), and it represents the size of the mutation where applicable. Not every mutation is affected by the size value (for example, randomizer mutations). Others are scaled up by certain factors in order to put the change in a range that's usually an integer value, for example.

  • There are a differentiation between "brain" and "gene" chances and sizes. This was done to allow agents to refine a brain or adapt to the environment selectively, without forcing the other to also happen. Very often, with the unified solution, agents would die because their mutation chances too often broke something about their brain, but their body could have adapted to a new climate if it would only be given a chance.

These values are all saved and loaded, and are affected by the META mutation rate, another set of settings that mutate the mutation rates. Mutation chances and sizes can also change with live mutation events, simulating entropy.

Since gene mutations will alter just about every agent trait, we won't cover them here except to say that, once a gene system is implemented, we will cover them in much more detail.


Brain Connection Mutations

Here is a list of every mutation the brain can have, and the rarity (note the actual chances of each are much more nuanced than this would lead you to believe, but since I change them so often, it would be futile to give actual numbers):

Extraordinary (Brain Mutation Chance / 100 or more):

  • New connection: create a brand new connection and add it to the list.

  • Boxify: a dead box is located, reset to allow simple passing of input, and then a new connection and the original connection is attached, so that for [A]-a->[B], box [*C] and conn *b is created but without effecting the expected sum* on [B]: [A]-a->[*C]-*b->[B] (*note: it is not possible to perfectly simulate the same sum because of the Sigmoid function).

  • Random type: Connections can either be change-sensitive or direct addition. This changes the type randomly.

  • Random source ID: A random input index is chosen for the connection. It could be an input (negative) or a box (positive).

  • Random target ID: A random output index is chosen for the connection. Only box indexes are allowed.

Rare (Brain Mutation Chance / 10 or more):

  • Target ID bump: The current target box index is "bumped", potentially setting it to another index +/- a range scaled with Brain Mutation Size (size of 0.03 translates to a range of (-3,3))

  • Source ID bump: The current input box/input index is "bumped". It is possible to cross over at 0, switching from input reference to brain box reference, or vice versa.

  • Mirror connection: the connection has its weight set to negative its current value.

  • Split connection: a new connection is created with the same settings as this one, and both get a weight / 2.

Common:

  • Random weight: A random weight is assigned to the connection.

  • Weight wither: If a connection is close to 0 (in range (-5,5), and the closer to 0 the more likely) then it can get set to 0.

  • Weight jiggle: push the connection's weight +/- a small amount.



Brain Box Mutations

Extraordinary (Brain Mutation Chance / 100 or more):

  • Copy box: A random box is selected; this box becomes a copy of that box.

  • Random bias: A random bias value is set.

  • Random global weight: A random Global Weight value is set for the box.

Rare (Brain Mutation Chance / 10 or more):

  • Mirror global weight: The box has its global weight set to negative its current value.

  • Mirror bias: The box has its bias set to negative its current value.

Common:

  • Random kp: A random dampening factor is set.

  • Kp jiggle: push the box's dampening factor +/- a small amount.

  • Global weight jiggle: push the box's global weight +/- a small amount.

  • Bias jiggle: push the box's bias +/- a small amount.