.velscalar
The bot's speed: the size of its velocity, regardless of which direction it is going.
Facts
- Address
- 196
- Name
.velscalar- Kind
- Sense: the engine writes it for the DNA to read
- Group
- Movement
- Written by
- The engine, in the movement phase, after moving the bot: the rounded speed. You read it in the next cycle.
- Cleared
- Nobody; the engine rewrites it every cycle.
- Range
- 0 to
.maxvel(never more than 200). It is 0 in the first cycle of life. - Mutations
- picked as a read (
*)
.velscalar is the size of the bot's velocity, rounded to the nearest integer: 0 if it is still or nearly so, and at most .maxvel. It doesn't say where it is going; for that there are .velup, .veldn, .veldx and .velsx, which break it down relative to the heading. The engine publishes it after moving the bot, so your DNA reads the velocity it moved with in the previous cycle, and in the first cycle it is 0.
It's useful for metering the thrust (not spending on .up when it is already going fast) or for detecting that something pushed it:
' only pushes if it is slow
cond
*.velscalar 10 <
start
10 .up store
stop