254c7dc997
- Gun harness: virtual bullet tracker, rolling fitness, auto-selector - Guns: head-on, linear (extrapolation), circular (integrated formula), tsetlin machine (learning) - Movement: phantom meteor gravity engine (danger histograms, phantom bullets, fire detection) - Radar: harness + radar_lock adapter - Color-coded modules: turret/bullet color per gun, body per movement, scan per radar - Beats Target, SpinBot, Crazy, TrackFire in 10-round battles
23 lines
871 B
Nim
23 lines
871 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
|
|
discard
|
|
|
|
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
|