DarwinBotsManual
Open the app EspañolES

Mutations

How DNA changes by chance, during life and at birth: the mutation types, what they do to instructions, how to read the rates, and how to turn them on or off.

Mutations are the engine of evolution: random changes to the DNA that get passed on to the children. Most of them break something, some change nothing you can notice, and every once in a while one comes out better than the original. If that bot leaves more children than its neighbors, the change stays.

In DarwinBots the DNA changes at two moments: during life, little by little, and at birth, when the parent's DNA is copied (or mixed, in sexual reproduction) for the child.

Who mutates

For a bot to mutate, two things have to hold:

  1. The simulation's mutations are on: this is the app's Mutations switch. With it off, nobody mutates, no matter what.
  2. The bot's own mutation table is on. Every bot carries a table with a rate for each mutation type, which it inherits from its parent. A type with rate 0 never happens.

The app seeds every species with the table on and the factory rates (see below), so in practice the switch is all you need. An off table, or one with rates at 0, only shows up in the bots of a saved simulation that came with it that way.

The mutation types

TypeWhenWhat it does to the DNATypical span
PointDuring lifeChanges a short run of instructions3 (± 1)
DeltaDuring lifeDoesn't touch the DNA: changes one of the bot's own rates—
Copy errorAt birthChanges instructions1
InsertionAt birthAdds new instructions1
InversionAt birthReverses the order of a run3 (± 1)
Major deletionAt birthDeletes a run3 (± 1)
Minor deletionAt birthDeletes one instruction1

The typical span is how many instructions each mutation touches: the engine draws it around that value. The birth mutations are applied in the order of the table, one pass of each type over the child's DNA. The during-life ones run in the actions phase of every cycle (see The cycle and the order of actions).

The major and minor deletions are the same mechanism with a different span.

The engine has four more types that come switched off and that the app doesn't turn on: a second point mutation, a second copy error, translocation (moves a run to another place in the DNA) and amplification (duplicates it).

What happens to an instruction

The point mutation and the copy error change instructions one by one. With the factory settings, out of every five changes four touch the value and one the type:

Since addresses are numbers, a value mutation on .up can leave you writing to a different address: 10 .up store turns into 10 .dn store, or into a number that isn't a sysvar and ends up as free memory.

There are two things no mutation does: touch the end that closes the DNA and create a new one.

We saw these changes happen in children of a one-gene bot, starting from cond *.robage 5 > start … stop:

cond *.robage 5 > 291 start …   insertion: a loose number before start
cond *.robage > start …         minor deletion: the 5 is gone
cond > 5 *.robage start …       inversion of the run “*.robage 5 >”
cond *.robage 5 > … stop        deletion of the start: the body became a condition

The last one is a good example of a lethal mutation: without start, the gene's stores end up in the condition section and write nothing (see Genes: cond, start, else and stop). That bot no longer reproduces.

The rates

Each rate is a number N that reads as “one in N”: the bigger it is, the rarer the mutation. The factory value is 5000 for all types, and it's what the species the app seeds get.

TypeProbability
BirthOne in N per instruction of the DNA, at every birth, for each type.
PointOne in 1000 × N per instruction, in every cycle of life.
DeltaOne in 100 × N per cycle of life.

With the rates at 5000 and a 100-instruction DNA:

A longer DNA mutates more, because there are more instructions to draw on.

The rates are inherited, and the delta mutation keeps moving them: when it happens, it picks a type at random and changes its rate by a few hundred up or down. That way a lineage can become more stable or more changeable over time.

Reproduce to explore: .mrepro

.mrepro works like .repro, but the child is born with the mutation table divided by 10 for that birth only: each birth type is ten times more likely. A type with rate 0 becomes 1000. The child also mutates even if its table was off; the only thing that prevents it is turning off Mutations.

After the birth the child goes back to the inherited table: during life it mutates like its parent, and so do its own children born with .repro.

With the factory rates, in a population of 20-instruction bots, about 1 child in 60 was born with some change when reproducing with .repro, and almost 1 in 5 with .mrepro.

The idea is to save .mrepro for when it pays to try new things. The Bestiary's Animal_Minimalis_mod_stress reproduces with .repro under normal conditions and with .mrepro when it's in trouble. A minimal version, which explores if it's been losing energy (.pain):

' If it has been losing energy, explore; otherwise, copy itself
cond
 *.nrg 4000 >
 *.pain 0 >
start
 33 .mrepro store
stop
cond
 *.nrg 4000 >
 *.pain 1 <
start
 33 .repro store
stop

What else changes when a bot mutates

The oscillation

The engine can multiply the probabilities of all bots at once, alternating periods of heavy change with periods of calm: up to 16 or 20 times more mutations on the way up and as many times fewer on the way down. The inheritable rates don't change; the factor is applied on top, at the moment of each draw. It comes switched off and the app has no control to turn it on. The details are in The cycle and the order of actions.

How to turn them on and off

You wantDo this
Nobody to mutateTurn off Mutations. It's the only way to stop .mrepro as well.
The children the bot picks to mutate moreUse .repro for the normal birth and .mrepro to explore: those children mutate ten times more.
Different children without mutationsUse sexual reproduction: the mixing already varies the DNA.

The engine also has three mechanisms that come switched off and that the app doesn't offer: an alternative regime in which each child's rates drift at random at every birth, self-speciation (a bot that has accumulated many mutations founds a new species under another name) and the epigenetic reset (a heavily mutated lineage stops inheriting the genetic memory, see Free and epigenetic memory).