2cc2a3bd87
- 30-tick cooldown after ghost-stuck/timeout ram exit prevents re-entry loop - enemy_tracker.update() skips dead bots to prevent same-tick scan resurrection - TFIL graphics cleared when ramming is active movement - [config] logs: white base with green-highlighted changes only - [ram:enter] logs trigger reason and key values on false→true transition - [death] and [target-invalid] logs retained for diagnostics
23 lines
884 B
Nim
23 lines
884 B
Nim
## 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
|
|
|
|
type LinearGun* = object
|
|
debugGraphics*: bool
|
|
|
|
proc predict*(g: var LinearGun, state: WorldState, bulletSpeed: float): GunPrediction =
|
|
let dist = hypot(state.enemyX - state.selfX, state.enemyY - state.selfY)
|
|
let ticksToArrive = dist / bulletSpeed
|
|
let headingRad = degToRad(state.enemyHeading)
|
|
var px = state.enemyX + cos(headingRad) * state.enemySpeed * ticksToArrive
|
|
var py = state.enemyY + sin(headingRad) * state.enemySpeed * ticksToArrive
|
|
# Clamp to arena bounds
|
|
px = clamp(px, 0.0, state.arenaWidth)
|
|
py = clamp(py, 0.0, state.arenaHeight)
|
|
GunPrediction(x: px, y: py)
|
|
|
|
proc onResult*(g: var LinearGun, e: FeedbackEvent) =
|
|
discard # analytical gun — no learning
|