# Troubleshooting

Open the replay's decision trace and find the first tick where the bot behaves unexpectedly. Compare what the pilot saw with the command it tried and its result.

| Symptom | What to inspect | What to try |
| --- | --- | --- |
| The bot stops just out of range | Compare the stop distance and any hardcoded firing threshold with `mountState(slot)`. | Keep closing until inside the range the pilot actually uses. Leave a margin for movement and prediction error. |
| The bot starts a turn, then gives up | Movement and chassis turns queue for one tick. Look for a gap in accepted commands. | Repeat the movement or turn while it is needed. Use a reachable waypoint after contact or repeated obstruction. |
| The bot faces a target and never fires | Check aim, readiness, ammo, energy, stun, and whether the code actually requests `fire()`. | Aim during cooldown and refresh the point while the target is moving. Fire when the slot is ready and the estimated shot is in range. |
| Aiming works but shots pass behind targets | Look at target velocity, turret alignment time, projectile travel, movement before launch, and old pending points. | Use `estimateIntercept()` for moving contacts and retest on a wider arena. Use the scanned position when velocity is temporarily unavailable. |
| Hits register but hull barely changes | Look at shields, damage type, distance, armor, and splash falloff. | Aim for a better line or distance, sustain pressure, or choose a different weapon or component pairing. |
| The bot runs out of ammo or energy | Look at the last ready shot and equipment active around that time. | Reserve the next shot's cost. Delay repair, shield recharge, or powered movement until their benefit outweighs the next shot. |
| It fires at empty ground after losing contact | A pending shot retains the old aim point, and cloaked targets can disappear from scans. | Cancel an obsolete aimed order and choose a fresh visible target or a search waypoint. |
| The bot gets stuck behind an ally | Check contact, friendly-fire forecasts, and whether a declined shot leaves the bot idle. | Add a side-step or retreat plan and test with friendly fire enabled. |
| The code compiles but a battle stops | Find the reported line and trace step, then inspect nulls, array bounds, helper types, and work limits. | Guard missing data, bound loops, and cache repeated reads within a tick. |
| My published bot behaves like an older build | Check the published checkpoint and the date of the replay. | Publish the intended checkpoint and launch a new match. Past replays play their recorded versions. |

## A range bug to look for

A pilot can stop at 26 units, then refuse to fire unless the enemy reaches 24 units. If both bots follow that policy, neither approaches or fires even if their equipped weapons could hit. Compare the distance gates before tuning the loadout. Treat holding range and opening fire as one decision.

See [combat strategy](combat-strategy.md), [PHP syntax and limits](php-syntax.md), and [testing and iteration](testing.md) for ways to reproduce and repair these failures.
