feat(ModularBot): pluggable bot with 4 guns, phantom meteor movement, radar harness
- 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
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
## Gun harness — shared types and Gun concept.
|
||||
## Coordinate system: 0° = East, CCW positive (Tank Royale standard).
|
||||
## Bullet speed formula: 20 - 3 * power.
|
||||
|
||||
import std/math
|
||||
|
||||
const BotRadius* = 18.0 ## hit detection radius in px
|
||||
|
||||
type
|
||||
WorldState* = object
|
||||
## All raw data given to every gun every tick.
|
||||
# Enemy
|
||||
enemyX*, enemyY*: float
|
||||
enemySpeed*, enemyHeading*: float
|
||||
# Self
|
||||
selfX*, selfY*: float
|
||||
selfSpeed*, selfHeading*: float
|
||||
selfRadarHeading*: float
|
||||
selfEnergy*: float
|
||||
enemyEnergy*: float
|
||||
# Arena
|
||||
arenaWidth*, arenaHeight*: float
|
||||
# Meta
|
||||
tick*: int
|
||||
|
||||
GunPrediction* = object
|
||||
## Absolute (x, y) where the gun predicts the enemy will be.
|
||||
x*, y*: float
|
||||
|
||||
FeedbackEvent* = object
|
||||
## Outcome of a resolved virtual bullet.
|
||||
prediction*: GunPrediction
|
||||
bulletPower*: float
|
||||
missDistance*: float ## px; < BotRadius = hit
|
||||
hit*: bool
|
||||
|
||||
proc bulletSpeed*(power: float): float {.inline.} =
|
||||
20.0 - 3.0 * power
|
||||
|
||||
## Gun concept — any type T implementing these two procs is a valid gun.
|
||||
template isGun*(T: typedesc): bool =
|
||||
compiles(
|
||||
block:
|
||||
var g: T
|
||||
let ws = WorldState()
|
||||
let p: GunPrediction = g.predict(ws, 0.0)
|
||||
let fe = FeedbackEvent()
|
||||
g.onResult(fe)
|
||||
)
|
||||
Reference in New Issue
Block a user