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,39 @@
|
||||
## Unit test for ModularBot gun selection
|
||||
import unittest
|
||||
import gun_harness/virtual_bullets as vb
|
||||
import gun_harness/selector
|
||||
import gun_harness/gun_interface
|
||||
|
||||
suite "Gun Selection":
|
||||
test "selector picks best gun and power":
|
||||
# Create a simple tracker with mock vbullets
|
||||
var t = initTracker(4)
|
||||
|
||||
# Spawn some bullets on gun 1 (linear) to simulate tracking history
|
||||
let state = WorldState(
|
||||
enemyX: 100, enemyY: 100, enemySpeed: 5.0, enemyHeading: 0.0,
|
||||
selfX: 50, selfY: 50, selfSpeed: 0.0, selfHeading: 0.0,
|
||||
selfRadarHeading: 0.0, selfEnergy: 100.0,
|
||||
arenaWidth: 800, arenaHeight: 600, tick: 1
|
||||
)
|
||||
|
||||
# Gun 1 (linear) predictions
|
||||
var linPreds: array[len(PowerBins), GunPrediction]
|
||||
for i in 0..<len(PowerBins):
|
||||
linPreds[i] = GunPrediction(x: 105.0 + i.float, y: 105.0 + i.float)
|
||||
|
||||
t.spawnBullets(1, linPreds, state)
|
||||
|
||||
# Simulate a hit on one of the linear gun bullets
|
||||
t.tickBullets(state, proc(gunId: GunId, binIdx: int, fe: FeedbackEvent) =
|
||||
if gunId == 1 and binIdx == 0:
|
||||
check fe.hit == false # Just verify callback works
|
||||
)
|
||||
|
||||
# Select best shot
|
||||
let (gunId, binIdx, power) = selectShot(t)
|
||||
|
||||
echo "[test] Selected gun=" & $gunId & " binIdx=" & $binIdx & " power=" & $power
|
||||
check gunId >= 0 and gunId < 4 # Should be one of 4 guns
|
||||
check binIdx >= 0 and binIdx < len(PowerBins) # Valid power bin
|
||||
|
||||
Reference in New Issue
Block a user