Skip to content

Precise Prediction ​

Origins

Albert Perez's FuturePosition class was one of the first Precise Prediction implementations. The RoboWiki community developed the idea further through movement simulators such as Rozu's Apollon code, which the Wave Surfing Tutorial uses.

At full speed, a bot cannot turn as sharply as a bot that is stopped. It also brakes twice as quickly as it accelerates. Any predictor that moves a point in a straight line and fixes it afterward will eventually choose a position the bot could never reach.

Precise prediction advances a full movement state one turn at a time under the battle rules. Wave surfers use it to compare reachable paths before a wave arrives. Predictive guns use the same idea when replaying a likely enemy path.

Simulate the rules, not a sketch ​

The state usually includes position, heading, velocity, remaining movement, and remaining turn. Each simulated turn applies the engine's acceleration, braking, turn-rate limit, motion, and wall handling in the same order as the game. The exact command stream must be known or hypothesized. No predictor can know an enemy's next command by physics alone.

For both platforms, maximum body turn rate in degrees per turn is 10−0.75∣v∣10 - 0.75|v|, where vv is velocity in units per turn. A bot accelerates by at most 1 unit per turn, brakes by up to 2, and its speed is capped at 8 units per turn. Those limits turn an attractive destination into a reachable trajectory.

Physics limits make only some paths reachable before a bullet wave arrives.
Physics limits make only some paths reachable before a bullet wave arrives.

The prediction loop ​

Run the simulation until an event provides the stopping condition. For surfing, it is the turn an enemy wave intersects the simulated bot. For an intercept calculation, stop when bullet travel has caught up with the predicted enemy position. Keep the predictor independent of scan and gun code so it can be tested with recorded states.

txt
state = current movement state
while not stoppingCondition(state, turn):
    allowedTurn = 10 - 0.75 * abs(state.velocity)
    state.heading += clamp(requestedTurn, -allowedTurn, allowedTurn)
    state.velocity = applyAccelerationOrBrake(state.velocity, requestedMove)
    state.position = moveAndResolveWalls(state.position, state.heading, state.velocity)
    turn += 1
return state.position

The order is deliberate. A simulator with the right constants but the wrong update order is still not precise. Compare each predicted next state with a replay or an on-screen trace before building larger surfing or targeting decisions on top of it.

Where precision helps and where it cannot ​

Precision is most valuable near walls, at high speed, and when a wave is only a few turns away. It prevents a surfer from rating impossible escape paths as safe and prevents a replaying gun from carrying an enemy through a wall.

It cannot repair an incorrect behavior model. A pattern matcher may replay the wrong sequence, and a gun does not know whether the enemy will reverse next turn. Precise prediction reduces physics error. It does not remove uncertainty about decisions.

Platform notes ​

Tank Royale documents the movement limits used above, including its 8-units-per-turn speed cap and turn-rate formula. Classic Robocode uses the same familiar constraints, but classic headings are compass-style while Tank Royale headings are mathematical. Put that conversion at the edge of the predictor, then keep its internal angles consistent.

Further Reading ​

Based on RoboWiki content (CC BY-SA 3.0) for classic Robocode and the official Robocode Tank Royale documentation.