DarwinBotsManual
Open the app EspañolES

Advanced

Angles, distances, roots, powers, trigonometry, caps and debugging: the math that is not plain arithmetic.

Cost: Advanced command; debugint and debugbool are free

OperatorWhat it does
angleGives the angle from the bot to a point x y, in the same units as .aim: ready to store in .setaim.
distGives the straight-line distance from the bot to a point x y.
ceilSets a ceiling: of the top two numbers on the stack it leaves the smaller, so x 100 ceil never goes above 100.
floorSets a floor: of the top two numbers on the stack it leaves the larger, so x 0 floor never goes below 0.
sqrReplaces the top number of the stack with its rounded square root; if it isn't positive, it gives 0.
powRaises the lower number to the power of the upper one: 2 10 pow gives 1024. The exponent is limited to ±10.
pythGives the hypotenuse of the top two numbers of the stack, the square root of a² + b²: the length of a vector.
anglecmpCompares two angles and gives the shortest difference between them, signed, between −628 and 628: how much and which way to turn.
rootGives the b-th root of the lower number: 27 3 root gives 3. It ignores signs and, with b at 0, gives 0.
logxGives the logarithm of the lower number in the base of the upper one, rounded: 1000 10 logx gives 3.
sinGives the sine of an angle in .aim units, multiplied by 32000: 314 sin gives 32000.
cosGives the cosine of an angle in .aim units, multiplied by 32000: 0 cos gives 32000.
debugintNotes the number on top of the integer stack so you can look at it from the bot's console, without popping it and at no cost.
debugboolNotes the value on top of the boolean stack so you can look at it from the bot's console, at no cost.

The advanced operators take numbers from the integer stack and leave one, just like the basic ones, but they do more elaborate math. They are grouped like this:

Angles use the same units as .aim: a full turn is about 1256 units (2π × 200), 0 points right and the angle grows counterclockwise, so 314 is up.

In the Bestiary, the ones that appear in the most bots, by far, are angle, floor and ceil. The first, for aiming at what a bot sees; the other two, to keep a value from leaving a range.

Saber, by abyaly, computes the value that its venom writes to the victim (.venval) and keeps it between 5 and 50 in a single line:

cond
start
  1000 *.refbody div 50 ceil 5 floor .venval store
stop

Every advanced operator executed costs Advanced command (free under the F1 rules), except debugint and debugbool, which never cost anything.