DarwinBotsManual
Open the app EspañolES

.refxpos

The x coordinate of what you are looking at: together with .refypos and the angle operator, it lets you aim right at it.

Facts

Address
689
Name
.refxpos
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, with the x published by the bot your focus eye sees; with a shape, a point on it. 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 31999, in the same units as .xpos.
Mutations
picked as a read (*)

.refxpos is the horizontal coordinate of the bot your focus eye sees, in the same units as your own .xpos. Its counterpart is .refypos.

With both coordinates, the angle operator computes which way the other bot lies, and writing that angle to .setaim leaves you aiming straight at it. It is the most precise way not to lose a moving target: turning blindly with .aimdx lets it slip out of the front eye, which is narrow.

cond
*.eye5 0 =
start
40 .aimdx store
stop

' I have it in sight: aim at its center
cond
*.eye5 0 >
start
*.refxpos *.refypos angle .setaim store
stop

In a test against a bot moving sideways, a bot with these two genes kept it in .eye5 along its whole path.

What you get is the position the other bot published, not its exact position at this moment: depending on the order in which the engine processes the bots, it can be one cycle late. When what you see is a shape (.reftype at 1), it is a point of the shape, and it is only reliable if the focus eye is the front one: with another eye (.focuseye) the position of a shape is stale or 0. If you don't see anything, it is 0.