.nrg
The bot's energy, between 0 and 32000: what it spends on every action and what keeps it alive.
Facts
- Address
- 310
- Name
.nrg- Kind
- Sense: the engine writes it for the DNA to read
- Group
- Body, energy and state
- Written by
- The engine, in the actions phase; also at birth, for the parent and the child. You read it in the next cycle.
- Cleared
- No: the engine rewrites it every cycle.
- Range
- 0 to 32000; internally it can go negative, but you never read it that way.
- Note
- A freshly loaded bot reads it as 0 in its first cycle; a child, by contrast, is born with its energy already published.
- Mutations
- picked as a read (
*)
It's the most-read sysvar in DarwinBots. Everything costs energy: running instructions, moving, turning, shooting, having a body and a long DNA, reproducing. You gain it by eating (shooting other bots, see Shots), with chloroplasts in the sun (see Chloroplasts and vegetables) or by breaking down body with .fdbody.
The engine publishes it at the end of the cycle, clamped between 0 and 32000. Internally, the energy can go negative while costs are being charged, but you will never read a negative number. When it drops below 0.5 the bot dies; if the option Corpses is on, already below 15 it turns into a corpse (see Death and corpses).
' With no energy to spare, stay still; with energy, move forward
cond
*.nrg 1000 >
start
20 .up store
stopWhat it gained or lost in the last cycle is in .pleas and .pain; the energy of the bot in front of you is in .refnrg.