Advanced
Angles, distances, roots, powers, trigonometry, caps and debugging: the math that is not plain arithmetic.
Cost: Advanced command; debugint and debugbool are free
| Operator | What it does |
|---|---|
angle | Gives the angle from the bot to a point x y, in the same units as .aim: ready to store in .setaim. |
dist | Gives the straight-line distance from the bot to a point x y. |
ceil | Sets a ceiling: of the top two numbers on the stack it leaves the smaller, so x 100 ceil never goes above 100. |
floor | Sets a floor: of the top two numbers on the stack it leaves the larger, so x 0 floor never goes below 0. |
sqr | Replaces the top number of the stack with its rounded square root; if it isn't positive, it gives 0. |
pow | Raises the lower number to the power of the upper one: 2 10 pow gives 1024. The exponent is limited to ±10. |
pyth | Gives the hypotenuse of the top two numbers of the stack, the square root of a² + b²: the length of a vector. |
anglecmp | Compares two angles and gives the shortest difference between them, signed, between −628 and 628: how much and which way to turn. |
root | Gives the b-th root of the lower number: 27 3 root gives 3. It ignores signs and, with b at 0, gives 0. |
logx | Gives the logarithm of the lower number in the base of the upper one, rounded: 1000 10 logx gives 3. |
sin | Gives the sine of an angle in .aim units, multiplied by 32000: 314 sin gives 32000. |
cos | Gives the cosine of an angle in .aim units, multiplied by 32000: 0 cos gives 32000. |
debugint | Notes 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. |
debugbool | Notes 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:
- Geometry:
angle(which way a point lies),dist(how far away it is),anglecmp(how much to turn from one angle to another) andpyth(the length of a vector). - Caps:
ceilsets a maximum andfloora minimum. The names are confusing:ceilis the ceiling, so it gives the smaller of the two. - Math:
sqr,pow,rootandlogx, all with a rounded integer result. - Trigonometry:
sinandcos, with the result multiplied by 32000 so it is not lost to rounding. - Debugging:
debugintanddebugbool, which leave the stack as it is and note its value so you can look at it from the console.
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
stopEvery advanced operator executed costs Advanced command (free under the F1 rules), except debugint and debugbool, which never cost anything.