.setboy
Raises or lowers the bot's buoyancy, which in pond mode with gravity decides what height it settles at.
Facts
- Address
- 314
- Name
.setboy- 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, if it is not 0: adds the value divided by 32000 to the buoyancy, which stays between 0 and 1.
- Cleared
- The engine, after using it.
- Range
- −32000 to 32000; 32000 sweeps the whole buoyancy range, from 0 to 1.
- Mutations
- picked as a store target
Buoyancy is a number between 0 and 1 that the bot carries with it. .setboy changes it: whatever you write is divided by 32000 and added to what it already had, so 8000 .setboy store raises it by a quarter and -8000 .setboy store lowers it by a quarter. The result never leaves the range 0 to 1. It applies in the same cycle and the engine clears the order. The new value is read in .rdboy, which publishes it multiplied by 32000 (from 0 to 32000).
It only has an effect with the Pond mode (light by depth) option on, gravity (Y gravity (downwards)) and a field with no connection between the top edge and the bottom edge. In that case buoyancy sets a height, measured from the bottom as a fraction of the field height: if the bot is above it, gravity sinks it; if it is below, gravity pushes it up. With buoyancy 0 it goes to the bottom, and with 1 it rises to the top. Keeping buoyancy above 0 costs energy every cycle, proportional to it and to the bot's mass (mass counts up to 192).
' It tries to float at mid height
cond
*.rdboy 16000 <
start
1000 .setboy store
stopIn 16 cycles this bot reaches a buoyancy of 16000 and stops. Children inherit their parent's buoyancy, although their .rdboy starts at 0 (see that page). More on the physics in Physics.