Waves/Precise Intersection

From RoboWiki
Jump to: navigation, search
Plain wave intersection
First intersection range
Augmented intersection range
The steps repeated

The Precise Intersection of a robot and a wave can be analyzed to find the exact range of firing angles that would hit the robot. The calculation involves simulating the movement of both the bot and the wave on every tick that a bullet collision could take place and deducing the minimum and maximum firing angles that would hit the bot.

An estimation of this range is used in many bots. An angular range of Math.atan(18/distance) * 2 assumes a stationary bot with a bot width of 18. Simply (18/distance) * 2 is accurate at most distances, as well, without any trig operations.


Note that in Robocode physics, bullets act as a line segment. Between ticks:

  • Bullets advance, forming a line segment.
  • Robocode checks for collisions - any intersection of a bullet line segment and a robot bounding box.
  • Robots move.

So you need to examine the area covered by the advancing wave and the initial position of the target bot. Specifically, you need to account for:

  • Points of intersection between the robot bounding box and the wave's initial position.
  • Points of intersection between the robot bounding box and the wave's final position.
  • Any corners of the robot bounding box that lie between the two wave circles.

The minimum and maximum angles from the wave source to any of these points form the precise intersection range for this tick. Combine the ranges from every tick to get the entire range of firing angles that would hit the target bot.

Bot using this technique

  • Garm: The first implementation.
  • RougeDC: The original ideas was posted under the name of "Super Bot Width", used in both gun and movement.
  • DrussGT: Current RoboRumble King, uses precise intersection in his gun.
  • PolishedRuby: Same gun as RougeDC.
  • Polylunar: Used to determine when a certain angle is going to hit an enemy no matter how they move (only occurs at close range)
  • Wintermute: Newer robot, used in both gun and movement.
  • Seraphim: Movement and gun in version 2.
  • Nene: Precise Intersection made sense, unlike the traditional intersection methods.
  • GresSuffurd: Gun since 0.2.26.
  • Diamond: Movement since 1.471, gun since 1.5.30.

See also

Personal tools