If there is a single tool suited perfectly to RoboWar, it would have to be trigonometry. Anyone can make a robot that moves horizontally or vertically, but to make an accurate diagonal move requires more than arithmetic.
For the Uninitiated:
To understand what trigonometry is good for, just think of this example: Robot A has been put in an awkward position. He has just fired a swarm of powerful missiles out 45 degrees ahead of him. Behind him is coming the RoboWar equivalent of a tank: Voodoo Turtle. In order to escape, he has to run away at a speed of 5 pixels per chronon. But Voodoo Turtle is diagonally from him, so Robot A must move on a course of 30 degrees! The means of doing so is trigonometry. The calculation aim 30 + dup 5 sin speedx' store -5 cos speedy' store sends him safely on his way.
Trigonometry is the mathematics of triangles. Using trigonometry, it was possible for Robot A to launch on a specific heading at a specific speed. Other uses include leading shots, chasing enemies, and heading towards a specific point.
For the Initiated:
RoboWar has a coordinate and angle system that is... original. Angles are measured in degrees, incrementing clockwise with 0 degrees being straight up. The x axis runs left to right (0 at the left, 300 at the right), and the y axis runs top to bottom (0 at the top, 300 at the bottom). As a result, using trig functions can get a little weird.
RoboWar supports the basic trig operations. My descriptions of them are based on the RoboWar manual:
arccos
arcsin
arctan
arctan removes the top two operands and returns the arctangent of y/x. The result is in degrees between 0 and 359, with 0 degrees pointing up, just as with AIM angles. Also remember that the positive x values are on the right side of the arena, while positive y values are on the bottom of the arena.
cos
cos removes the top two arguments and returns the hypotenuse times the cosine of the angle, truncated to an integer value. The angle must be between 0 and 359 or the result is undefined. Also, note that while 0 degrees is pointing straight up on the turret, the cosine of 90 degrees is still 0 (e.g. cos uses the standard trig coordinate system).
sin
sin removes the top two arguments and returns the hypotenuse times the sine of the angle, truncated to an integer value. The angle must be between 0 and 359 or the result is undefined. Also, note that while 0 degrees is pointing straight up on the turret, the sine of 0 degrees is 0 (e.g. sin uses the standard trig coordinate system).
tan
sin and cos, but computes the tangent function. If the result is greater than 19999 it is clipped to 19999; if the result is less than -19999, it is clipped to -19999.
The uses for trigonometry in RoboWar are numerous. The most useful ones are listed below:
n is the desired speed, the formula is aim n sin speedx' store aim n chs cos speedy' store. The chs operator changes the sign of a number (multiplies by -1). It has to be used because the Y-coordinate system in RoboWar is upside-down.
h is the target x coordinate, and i is the target y coordinate, use: h x - i y - arctan aim' store.
aim 5 cos speedx' store aim 5 sin speedy' store moves the robot at a speed of 5 to the right; using -5 instead of 5 moves it left.
n is the projectile speed with the sign changed (ie -12 for bullets), doppler n arctan aim + aim' store. Even though using a sin or arcsin function would be more accurate, arctan doesn't produce bugs when the doppler register reads higher than the projectile speed.
aim 1 tan returns a 1 if the aim is more up and down, and a 0 if the aim is more side to side. aim 10 cos 7 / is a more approximate way of doing it. This can be used instead of the aim 45 > routine.
These little trig tricks can be "mixed and matched" in many ways. Try them out!
The next section is on Continuous Tracking Routines.