Body, energy and state
The sysvars that describe the bot itself: energy, body, mass, age, clock, kills and waste, plus the commands to move energy into body and back.
| Address | Sysvar | Kind | Summary |
|---|---|---|---|
| 9 | .robage | Sense | The bot's age in cycles: 0 in its first cycle of life, it goes up by 1 and stops at 32000. |
| 10 | .mass | Sense | The bot's mass: it comes from the body, the shell and above all the chloroplasts, and decides how much each push moves it. |
| 12 | .timer | Input and output | A clock that adds 1 per cycle, that you can write to and that the child inherits from the parent: useful for synchronizing a lineage. |
| 220 | .kills | Sense | How many bots this bot has killed, with shots or through a tie; the engine updates it only when it kills. |
| 310 | .nrg | Sense | The bot's energy, between 0 and 32000: what it spends on every action and what keeps it alive. |
| 311 | .body | Sense | The bot's body, between 0 and 32000: a reserve worth 10 energy per point that sets its size and its weight. |
| 312 | .fdbody | Command | Converts body into energy: up to 100 energy per cycle, at 10 energy per body point. |
| 313 | .strbody | Command | Stores energy as body: up to 100 energy per cycle, which turns into 10 body. |
| 314 | .setboy | Command | Raises or lowers the bot's buoyancy, which in pond mode with gravity decides what height it settles at. |
| 315 | .rdboy | Sense | The bot's buoyancy, from 0 to 32000, as it was left the last time it changed it with .setboy. |
| 828 | .waste | Sense | The waste the bot has accumulated: in excess it writes random numbers into its memory; it is thrown away with a -4 shot. |
| 829 | .pwaste | Sense | Permanent waste: a remainder left every time the bot dumps waste, which can no longer be eliminated. |
This group is the bot's dashboard: what the engine tells it about itself at the end of every cycle, plus a couple of commands to manage its reserves. The most-read sysvars in all of DarwinBots are here: almost any bot has some condition on .nrg or .body.
A bot keeps its wealth in two currencies. Energy (.nrg) is the one that gets spent: every instruction, every movement, every shot consumes it, and if it runs out the bot dies. Body (.body) is a slower reserve that also makes it bigger and heavier (.mass). Between the two there is a fixed exchange rate of 10 to 1: .strbody stores 100 of energy as 10 of body, and .fdbody does the reverse. With that you can build a piggy bank, as in this bot:
' Keeps energy between 2000 and 5000 using body as a reserve
cond
*.nrg 5000 >
start
100 .strbody store
stop
cond
*.nrg 2000 <
*.body 100 >
start
100 .fdbody store
stopThe rest of the group is clocks and counters: .robage (the age, which starts at 0), .timer (a clock that is inherited from parent to child and that you can write) and .kills (how many you have killed). .waste and .pwaste measure waste, which in excess corrupts the bot's memory. .setboy and .rdboy handle buoyancy in pond mode.
The senses in this group arrive one cycle late, and a freshly loaded bot reads them as 0 in its first cycle (except .timer, which starts at random): *.nrg 500 < is true there even if it has plenty of energy. How energy is charged and gained is covered in Energy, body and waste; the changes from one cycle to the next, in Gains and losses.