## Linear gun: predict enemy continues at current velocity and heading. ## Coordinate system: 0° = East, CCW positive (Tank Royale standard). import std/math import gun_harness/gun_interface import guns/lead_forecast type LinearGun* = object debugGraphics*: bool proc predict*(g: var LinearGun, state: WorldState, bulletSpeed: float): GunPrediction = # Self-consistent constant-velocity forecast: iterate the flight time until the # predicted point sits at the distance the virtual bullet actually travels. # Without the iteration the bullet resolves early/late whenever the target # moves radially, which is why this gun scored 87% (p3.0 = 63/100) on the # constant-velocity fixture where a self-consistent forecast scores 100%. let f = forecastLinear(state, bulletSpeed) GunPrediction(x: clamp(f.x, 0.0, state.arenaWidth), y: clamp(f.y, 0.0, state.arenaHeight)) proc onResult*(g: var LinearGun, e: FeedbackEvent) = discard # analytical gun — no learning