Skip to content

Bullet Travel & Bullet Physics

Bullets are pure energy projectiles fired by your bot's gun. Firing costs energy, your gun must cool down between shots, and the bullet travels across the battlefield until it hits a bot or a wall (or leaves the arena). Mastering these basics helps you choose when and how hard to fire.

Bullet power and cost

Understanding bullet power is really about understanding what happens to your bot’s energy when you fire and how close you are to being disabled or dying.

Diagram: Bot energy across important states: full → firing → low → disabled → dead

  1. You start a turn with full energy (100)
  2. fire a bullet and drop a little energy (~97). The energy drop is marked as yellow
  3. later might be low but still alive (~15)
  4. can hit 0 and become disabled (0)
  5. and finally go below 0 and die (−2)

The red horizontal line at 0 highlights the critical boundary between alive and disabled/dead. This makes it clear why energy management and bullet power choices matter.

  • Bullet power is the energy you spend for a shot.
  • Typical valid range: 0.1 to 3.0 power.
  • You need at least 0.1 energy to fire the gun. If you request more power than your remaining energy, the game clamps to your current energy (but never below 0.1 to create a shot).
  • Higher power does not make the bullet faster—it makes it slower but potentially more damaging (see bullet damage below).

How bullets are fired

  • You aim with the gun, not the bot body; the gun can turn independently of the bot.
  • A bullet travels in a straight line along the gun’s heading at the instant you fired.
  • Bullet speed is determined only by bullet power and engine rules; it does NOT inherit your bot’s current velocity.
  • A shot is created only when your gun is cool, and you have enough energy. On fire(power), energy is deducted immediately.
  • The bullet then flies until it hits a bot, a wall, leaves the arena, or even collides with another bullet.

When can you fire? (gun cooldown)

  • At round start: Bots begin with gun heat of 3.0. With the default cooling rate of 0.1/turn, the first shot is possible on turn 30.
  • After you fire, the gun becomes hot and must cool before the next shot.
  • Conceptually: each shot adds heat; every turn, some heat is removed. You can only fire when the heat reaches zero.
  • Classic Robocode specifics you will see in the docs:
    • Cooling happens at a constant rate per turn.
    • Heat added depends on bullet power, so bigger shots generally mean a longer wait.

Practical takeaway: you cannot fire every turn. Larger bullet power means a longer interval until the next legal shot.

Timeline of firing and cooldown

Timeline diagram: start → fire → heat rises → cooldown → ready for next shot

Bullet speed and travel time

Bullet speed formula

Bullet Trajectory & Speed Comparison
Illustration: Two bullets fired by a bot — a high-power bullet (slower, shown in red/orange) and a low-power bullet (faster, shown in green/orange) — demonstrating their different trajectories and speeds.

Classic Robocode bullet speed:

speed (units/turn)=203×bulletPower\text{speed (units/turn)} = 20 - 3 × \text{bulletPower}

The table below shows bullet speed for common power levels:

Bullet PowerSpeed (units/turn)
0.119.7
1.017
2.014
3.011

Chart: Bullet Power vs Bullet Speed. The bars and line show decreasing speed as bullet power increases.

Travel time formula

traveltime(turns)distance/speedtravel time (turns) ≈ distance / speed

Example: target at 400 units with power 2.0 → 40014\frac{400}{14} ≈ 29 turns of flight

Notes:

  • Slower (high-power) bullets take longer to arrive, giving moving targets more time to dodge.
  • Faster (low-power) bullets arrive sooner, cost less energy, but do less damage.
  • Bullet motion is straight-line at constant speed; it is independent of your bot’s movement after the shot.

Bullet Power vs Bullet Speed

Bullet PowerSpeed (units/turn)Example Travel Time (400 units)
0.119.720
1.01724
2.01429
3.01136

A quick visual: higher bullet power reduces speed (see the formula and the table above). Use lower power for faster bullets when you need shorter travel time, and higher power for more damage when you can accept slower travel.

Bullet damage

Chart: Bullet power vs. damage and energy reward. Damage (red) increases faster than reward (green) as power rises.

The table below shows how bullet power translates to damage and energy reward:

Bullet PowerDamage FormulaExample DamageEnergy Reward
0.1 - 1.04 × bulletPower0.5 → 23 × bulletPower
> 1.04 × bulletPower + 2 × (power − 1.0)2.0 → 8
3.0 → 12
3 × bulletPower

Formula:

damage=4×bullet power+max(0,2×(bullet power1.0))\text{damage} = 4 × \text{bullet power} + max(0, 2 × (\text{bullet power} − 1.0))

energy reward=3×bullet power\text{energy reward} = 3 × \text{bullet power}

Notes:

  • If a bullet hits a wall, it does not deal damage.
  • When your bullet hits, you gain back energy as shown above.

Platform note: Collision detection

The way bullets detect hits on bots differs between platforms:

  • Classic Robocode: Uses an axis-aligned bounding box (36×36 units) that does not rotate with the bot's heading. A bullet hits if it passes within the square's bounds.
  • Tank Royale: Uses a bounding circle (radius 18 units) that is independent of the bot's heading. A bullet hits if it comes within 18 units of the bot's center.

Firing constraints and safety

  • You cannot fire when your bot is disabled (energy = 0).
  • Firing reduces your energy immediately by the bullet power.
  • Be careful not to drop yourself to zero energy (= disabled): a disabled bot becomes an easy target and can be killed by a fast small bullet.
  • In team battles, bullets can hit allies (friendly fire). Always consider the line of fire.

Friendly Fire Vignette
Friendly fire scenario where a bot accidentally hits a teammate. Always check your line of fire in team battles.

How often can I fire a bullet?

  • As often as the gun cooldown allows. The sequence is:

    fire → gun heats up → wait while it cools → fire again.

  • Bigger shots mean longer waits. If you need a faster cadence, prefer lower-power shots.

Radar and visibility

  • Radar does not detect bullets.
  • You can often infer a shot by observing a scanned enemy's energy dropping by the amount they spent to fire.

Minimal example (Robocode-style pseudocode)

text
if (gunIsCool() and myEnergy > 0.1) {
  distance = distanceTo(target)
  // Simple distance-based power choice: closer → higher power, farther → lower power
  power = clamp(map(distance, 0..800, 2.5..0.5), 0.1, 3.0)
  turnGunTo(bearingTo(target))
  fire(power)
}

Key Takeaways

  • Bullet power determines energy cost, speed, and damage.
  • You can only fire when your gun is cool, and you have enough energy.
  • Higher bullet power means slower bullets but more damage; lower power is faster but less damaging.
  • Gun cooldown depends on bullet power—bigger shots require longer waits.
  • Bullets travel in straight lines at constant speed, unaffected by your bot's movement after firing.
  • Hitting an enemy with a bullet rewards you with energy; hitting a wall does not.
  • Friendly fire is possible in team battles—always check your line of fire.
  • Radar does not detect bullets, but you can infer shots by watching energy drops.
  • Energy management is crucial: avoid disabling yourself by firing recklessly.

Further Reading

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