DarwinBotsManual
Open the app EspañolES

Death and corpses

When a bot dies (out of energy, out of body, from a shot, from shock or from memory pressure), what a corpse is, how it decays and what happens to its ties.

In DarwinBots there is no old age or disease: a bot dies because it runs out of something. Almost always it is energy; sometimes the body, a shot that empties it all at once, or a rule of the world that prunes the population. What is left depends on how it died and on the configuration: a corpse that stays around as food, or nothing.

This page describes the causes of death, at what point in the cycle they happen, what a corpse is and how it disappears.

The causes

CauseWhenLeaves a corpse?
Out of energy.nrg below 15, with Corpses on; below 0.5 if it is offYes, if corpses are turned on
Out of body.body below 0.5No
A shot that empties itan energy (−1) or body (−6) shot leaves it with 0.5 or less of energy or bodyNo
Shockit loses more than half its energy in one cycle and still has more than 3000 leftYes: the energy it had left goes to the body
Memory pressurethe DNA of the whole world together goes over 4 million wordsNo

Out of energy

This is everyday death. Everything costs energy (see Energy, body and waste), and the accounting has no floor: within a cycle the energy can end up negative, even though your DNA never reads a number below 0. At the end of the cycle, if it ended up below 15, the bot turns into a corpse.

This bot moves its energy into its body 100 per cycle with .strbody, without checking how much it has left:

' Moves all its energy into its body, 100 per cycle
cond
start
 100 .strbody store
stop
end

Seeded with 350 energy, it ends cycle 3 with 50 and cycle 4 with −50: in that cycle it turns into a corpse, with 1040 of body. If Corpses is off, in that same cycle 4 it disappears without leaving anything.

Out of body

A living bot whose body drops below 0.5 dies even if it has plenty of energy, and it leaves no corpse: there is nothing to leave.

Killed by a shot

When an energy or body shot leaves the victim with 0.5 or less of energy or body, the engine marks it as dead, adds one death to the shooter's .kills and, at the end of the cycle, removes it from the world without a corpse. In one test, a hunter that approached a motionless bot with 300 energy firing −1 landed two shots on it in the same cycle: the first took 198 from it and the second, the rest. The bot disappeared in that cycle and the hunter was left with .kills at 1.

A bot that is left thin but above that line (between 0.5 and 15 of energy) does end up as a corpse at the end of the cycle.

Shock

If a bot that isn't a vegetable loses more than half of the energy it had in a single cycle, and still has more than 3000 left, it suffers a shock: all the energy it had left is moved into its body, at a rate of 10 to 1, and it is left at

  1. Since that leaves it below 15, it turns into a corpse in the same cycle. A bot

with 20000 energy that spends 12000 at once on a shot ends up as a corpse with 1800 of body (it had 1000, plus 8000 / 10). How it worked in the original, and another example, in Energy, body and waste.

No old age and no giants

There is no maximum age. What there can be is a cost per age, which grows with .robage and ends up starving the bot: Age cost, starting from Age at which the cost starts cycles of life, constant, logarithmic (Logarithmic age cost) or linear (Linear age cost, with slope Age cost linear fraction).

The code also has a rule for killing giants (an enormous body with few chloroplasts, or more than five victims), but its threshold is a body greater than 32100, and the body never goes over 32000: in practice it never fires, in the original or in the port.

Memory pressure

The last step of each cycle adds up the DNA length of all the bots in the world, corpses included. If it goes over 4,000,000 words, the engine kills the poorest ones in one go: it looks for the bot with the least energy plus ten times its body, removes it, and repeats. How many depends on the population and the average DNA length: with an average DNA of 425 words it is about 1500, and fewer if the average DNA is longer.

It is a rule so that the simulation doesn't run out of memory, but it is also selective pressure: in a huge world it punishes the poor just when the population's genome grows. It happens in very populated, long simulations, with thousands of bots.

At what point in the cycle

The phases of the cycle (see The cycle and the order of actions) are: DNA → senses cleared → shots → forces and collisions → movement → actions → births and deaths → the sun. Death touches several of them:

Something unintuitive follows from this: a bot that dies in this cycle can still have a child, because its reproduction request is handled before its death. A bot marked by a shot even runs its actions for that cycle (it shoots, it reproduces) before leaving. It is the same in the original, and evolved bots were able to take advantage of it.

A corpse leaves the world when its body reaches 0, in the count that is done between forces and collisions and movement: in the same cycle if it was finished off by being eaten with a shot, or in the next one if it ran out through decay or through a tie.

Corpses

A corpse is a bot that has stopped living but is still in the world. It keeps its body, its position, its velocity and its ties, and loses everything else:

The others see it like any bot. .refbody brings its real body, but .refnrg is 0 and so is its whole signature (.refeye and company): facing a corpse, *.refeye *.myeye != gives true, as if it were another species (see Its own signature (my*)).

Eating a corpse

What a corpse is worth is its body, and the only way to take it is through the body: with −6 shots (see .shoot), which against a corpse yield four times more than against a living bot, or by sucking body out of it through a tie (see Ties and multicellular bots). An energy shot (−1) takes nothing from it, because it has no energy left.

Ursus Detrivoris, from the Bestiary, has a gene for that, commented “eat corpses (or harmless bots)”: if what it sees doesn't shoot (its .refshoot is 0, like the signature of every corpse), it shoots at the body.

' Eats corpses (or harmless bots)
cond
 *.eye5 30 >
 *.refshoot 1 <
start
 -6 .shoot store
stop

Decay

If nobody eats it, a corpse can rot. Three parameters regulate it:

ParameterWhat it does
Body decay per cycleHow much it decays at each step. The corpse loses a tenth of this value in body.
Decay delay (cycles)Every how many cycles it takes a step.
Decay typeWhether at each step it releases a shot, in a random direction: waste (−4) or energy (−2), with the value of the decay parameter (or the body it has left, if that is less).

With decay 1000 and a pause of 2 cycles, the corpse from the first example loses 100 of body every two cycles: it goes from 1040 to 40 in about twenty cycles and disappears shortly after. With the “energy shot” type, each step is also a small ration that anyone passing nearby can eat; with the “waste shot” type, it dirties the neighbors.

The default value of decay is 0: corpses don't rot and stay in the world until someone eats them.

Ties

Turning into a corpse doesn't cut ties: the bot that was tied stays tied, and can keep taking body out of it that way. Ties are cut when the bot leaves the world, whether it is a living bot that dies without a corpse or a corpse that ran out of body; at that moment the partner loses them and its .numties goes down.

In this bot the mother has a daughter at 3 cycles (who is born tied to her) and then lets herself die; the daughter, since she already has a tie, does nothing:

' The mother has a daughter at 3 cycles and then lets herself die;
' the daughter is born tied to her and does nothing
cond
 *.robage 3 =
 *.numties 0 =
start
 50 .repro store
 1 50 store
stop
cond
 *50 1 =
start
 100 .strbody store
stop
end

With 1000 energy at the start, the mother is a corpse in cycle 9 and the daughter keeps reading .numties at 1. With fast decay (2000, no pause), the corpse is used up in cycle 13 and from then on the daughter reads 0.

When a bot leaves the world, the virus it had stored for shooting is also lost (see Viruses). Its shots that are already in flight, on the other hand, keep going on their way.

The parameters

ParameterWhat for
CorpsesWhether those that starve are left as corpses.
Body decay per cycle, Decay delay (cycles), Decay typeDecay.
Age cost and the other costs per ageDeath from old age, if you want it.
Record dead bots, Exclude vegetablesSaving a profile of every bot that dies.

In the world view the corpses are counted separately; in Analyze (see Analyze) there is a chart of corpses and another of bots with and without them.