DarwinBotsManual
Open the app EspañolES

.aim

Where the bot is pointing, on a scale of 0 to 1255 where 0 is the right of the screen and 314 is up.

Facts

Address
18
Name
.aim
Kind
Sense: the engine writes it for the DNA to read
Group
Movement
Written by
The engine, in the movement phase, after turning the bot. You read it in the next cycle; the other bots see it in .refaim.
Cleared
Nobody; the engine rewrites it every cycle. Writing to it does not turn the bot.
Range
0 to 1255 (1256 is one full turn); it can overshoot a little if something else turns the bot. It is 0 in the first cycle of life.
Mutations
picked as a read (*)

.aim is the bot's heading: where it faces, where .up pushes it, and where its eyes are measured from. A full turn is 1256: 0 faces the right of the screen, 314 faces up, 628 faces left and 942 faces down. The engine publishes it after applying the turns from .aimsx, .aimdx and .setaim; writing to it does not turn the bot.

If the bot turns for other reasons (a tie twisting it, Brownian motion) the value can drift a little outside the 0-1255 range.

Other bots see your heading in .refaim when they look at you. To turn around, just add half a turn to the current heading:

' turns around when something touches it from behind
cond
*.hitdn 0 !=
start
*.aim 628 add .setaim store
stop

.setaim accepts any number and keeps its remainder after dividing by 1256, so you don't need to correct the sum.