DarwinBotsManual
Open the app EspañolES

.refvelscalar

How fast what you are looking at is moving relative to you, regardless of direction.

Facts

Address
695
Name
.refvelscalar
Kind
Sense: the engine writes it for the DNA to read
Group
What it sees (ref*)
Written by
The engine, in the actions phase of every cycle: how fast what your focus eye sees is moving relative to you, regardless of direction. Also on colliding with a bot. You read it in the next cycle.
Cleared
The engine, every cycle, when the senses are cleared.
Range
0 to 32000; it is never negative.
Mutations
picked as a read (*)

.refvelscalar is the magnitude of the relative velocity of what your focus eye sees: the square root of .refvel squared plus .refveldx squared, rounded. With .refvel at 3 and .refveldx at 4 it gives 5. It is never negative.

It is useful when you don't care which way the other is moving, only whether it moves. Since it is relative, if you and the other are going side by side it is 0 even though both are running. It is the way to tell whether you have already caught up with it in a chase, or to tell an easy target from one that is going to be hard to hit.

' target still relative to me: I shoot
cond
*.eye5 0 >
*.refvelscalar 5 <
*.refeye *.myeye !=
start
-1 .shoot store
stop

If you see nothing, it is 0.