DarwinBotsManual
Open the app EspañolES

.sun

It is 1 when the bot points toward the top of the screen (with about 10 degrees of margin); it has nothing to do with light.

Facts

Address
400
Name
.sun
Kind
Sense: the engine writes it for the DNA to read
Group
Position and surroundings
Written by
The engine, in the actions phase of every cycle: 1 if the bot is aiming up (heading between 278 and 350), 0 if not. You read it in the next cycle.
Cleared
Nobody; the engine rewrites it every cycle.
Range
0 or 1.
Mutations
picked as a read (*)

Despite the name, .sun doesn't measure light or the sun: it is a compass. It is 1 when the bot points toward the top of the screen, with a margin of about 10 degrees on each side, and 0 in any other direction. On the .aim scale, it turns on between 278 and 350 (314 is exactly up).

To know whether it is daytime or whether the sun is shining on a vegetable, the one to use is .daytime.

The engine publishes it at the end of the cycle, with the heading already turned, and in the first cycle of life it is 0. It is a cheap way to get your bearings without doing math with .aim, for example to look for north by turning a little at a time:

' turns until it ends up facing up
cond
*.sun 0 =
start
20 .aimsx store
stop

This bot stops at the first heading that falls inside the band (near 280, if it started from lower down). To point exactly up it is more direct to use 314 .setaim store.