DarwinBotsManual
Open the app EspañolES

Free and epigenetic memory

The map of a bot's 1000 memory cells: which ones the engine uses, which ones are yours, what gets cleared on its own and what is passed on to children.

Every bot has a memory of 1000 cells, numbered 1 to 1000. Each cell holds an integer; whatever the DNA writes always ends up between −32000 and 32000 (see Writing to memory). Some cells have a name and the engine uses them to talk to the bot (these are the sysvars); the rest are yours. This page is the map.

The map from 1 to 1000

The named cells are grouped by topic. The full list, with what each one does, is in All sysvars.

CellsWhat is thereGroup
1–12, 18–19Movement and shooting commands, age, mass, .timerMovement, Body, energy and state
194–221What happened in the cycle: speed, collisions, flavors, edge, position, day (nobody writes cell 221: see below)Collisions and hits, Position and surroundings
300–303, 310–315Reproduction, energy, bodyReproduction, Body, energy and state
330–331, 335–341Ties, DNA and virusesDNA and viruses
400–402Sun and bot countPosition and surroundings
410–429, 800–819Communication channelsInputs and outputs
437–487Ties and what is felt through themTies, What it feels through a tie (tref*)
501–539Eyes and their configurationEyes
685–715What the central eye seesWhat it sees (ref*)
721–731The bot's own signatureIts own signature (my*)
820–839Defenses and wasteDefenses
900–901, 920–924Backward shot, chloroplastsShots, Chloroplasts and light
971–990Genetic memory, unnamedInstant genetic memory (971-975), Deferred genetic memory (976-990)

Free memory

More than 700 cells have no name and the engine never touches them. They are these:

13–17, 20–193, 222–299, 304–309, 316–329, 332–334, 342–399, 403–409, 430–436, 472, 500, 512–520, 530, 540–684, 691–694, 700, 716–720, 732–799, 840–899, 902–919, 925–970, 991–1000

The 20–193 range is the classic place for your own variables: most bots in the Bestiary put their def variables at 50, 51, 52… What you store in a free cell stays there for the bot's whole life, until you change it. It is also saved along with the simulation.

Cell 221 has a name (.hitang), but in DarwinBots 2.48.32 nothing ever writes to it: in practice it is just one more free cell.

Named cells are no good for storing things

If you write to a cell the engine uses, the engine overwrites it. Look at this bot:

' The .nrg cell is no good for storing anything
def antes 60
def libre 61

cond
start
*.nrg .antes store
1 .nrg store
1 .libre store
stop

When you run it, .nrg goes back to holding the real energy (3000) every cycle (except the first, where a freshly seeded bot still reads it as 0), and that is what cell 60 copies on the next cycle: the 1 was lost. Cell 61, on the other hand, keeps its 1. Writing to .nrg doesn't change the bot's energy either: it is just a number the engine publishes.

Who else can write to your free memory

“Free” means the engine doesn't use it, not that it is safe. There are four ways it can be changed from outside:

What the engine clears, and when

The DNA runs in the middle of the cycle; almost everything else (physics, vision, shots) happens afterwards (see The cycle and the order of actions). That gives four behaviors:

Type of cellExamplesWhat happens
Senses.eye5, .edge, .refxposThe engine writes them after the DNA; your DNA reads them in the next cycle and they are cleared right afterwards. They always arrive one cycle late.
Published data.nrg, .body, .robage, .aimThe engine rewrites them every cycle. Whatever you store there is lost.
Commands.up, .shoot, .aimdxYou write them; the engine carries them out and sets them to 0 in the same cycle.
Configuration.focuseye, .eye5dir, .memloc, .out1The engine reads them but doesn't clear them: they hold until you change them.

Some commands are not always cleared, and it is worth knowing which:

At birth

A child is born with its entire memory at 0. Then the engine fills in its own part (the energy, the DNA length, the number of genes and a few more) and passes two things on from the parent: the .timer, which keeps counting from the parent's value, and the genetic memory. The variables in your free memory are not inherited: the child starts with them at 0.

Genetic memory (971–990)

Cells 971 to 990 have no name, but the engine treats them differently: they are the only memory bridge between a bot and its children. There are two zones.

971–975, instant. At birth, the child gets a copy of those five cells from the parent. They are already there in its first cycle of life. See Instant genetic memory (971-975).

976–990, deferred. At birth, the parent's fifteen cells are set aside in a reserve belonging to the child, and they reach it one per cycle, in order: first 976, then 977, and so on up to 990, about fifteen cycles after birth. Each delivery has two conditions:

See Deferred genetic memory (976-990).

This bot counts generations in cell 971:

' Counts generations in genetic memory
def generacion 971
def listo 50

' Once in a lifetime: adds 1 to what I inherited
cond
*.listo 0 =
start
.generacion inc
1 .listo store
stop

' Reproduces at 10 cycles of life
cond
*.robage 10 =
start
50 .repro store
stop

The founder sets 971 to 1. Its child is born with 971 = 1 (instant copy) and raises it to 2 in its first cycle. The flag in cell 50 keeps it from adding more than once, and it works precisely because cell 50 is not inherited: the child gets it at 0.

A few more details:

Address 0

The DNA can't reach a cell 0: every address is adjusted into the range 1..1000, and when reading, 0 falls on 1000 (*0 and 0 * read cell 1000). A store to address 0 does nothing. The rules, with examples, are in Numbers and addresses and Numbers and addresses.

Internally a cell 0 does exist, but only the engine uses it, as a dumping ground: if a venom or poison attack aims at 340 (.delgene, the one that deletes genes), the hit is diverted to cell 0 so it can't delete anyone's genes. Nobody reads it. See Address 0.