.strbody
Stores energy as body: up to 100 energy per cycle, which turns into 10 body.
Facts
- Address
- 313
- Name
.strbody- Kind
- Command: the bot writes it and the engine reads it and usually consumes it
- Group
- Body, energy and state
- Written by
- Your DNA.
- Read by
- The engine, in the actions phase of the same cycle: moves that energy into the body, 1 body for every 10 energy. It does not check whether you have enough.
- Cleared
- The engine, after using it. A negative value is also cleared, with no effect.
- Range
- −32000 to 32000; only 1 to 100 count (more than 100 counts as 100).
- Mutations
- picked as a store target
Write how much energy you want to store and the engine converts it in the same cycle: 100 .strbody store subtracts 100 from .nrg and adds 10 to .body. It is the inverse operation of .fdbody. Bots use it so as not to keep all their wealth in energy: body makes the bot bigger and it can be recovered later.
Some details:
- Cap of 100 per cycle. A larger value counts as 100.
- It is cleared when used, so you have to write it every cycle in which you want it. Negatives do nothing: the engine clears them without converting (in the original DarwinBots they stayed written; the port fixed that).
- It doesn't check how much energy you have. With 50 energy,
100 .strbody storecharges the full 100 anyway: the bot ends up with no energy and dies. Always put a condition on*.nrg. - Body doesn't go past 32000. Above that, the energy is charged and the body doesn't grow.
' With energy to spare, it stores it in the body
cond
*.nrg 4000 >
start
100 .strbody store
stopThis bot drops 100 energy and gains 10 body per cycle as long as it has more than
- The complete piggy-bank example, with both orders, is in