diag(SNNBot): revert to baseline, add bias diagnostics
Reverted fire gate from 1° back to 2°, removed gridHasData cold-start guard so bot fires on straight aim during cold-start. Added /tmp/snnbot_bias_debug.log BIAS entries in EVALUATE phase logging gridOffset, correctOffset, bias, vPerp, dist per cycle. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Binary file not shown.
@@ -18,6 +18,7 @@ import reservoir
|
||||
let diagnosticLog = "/tmp/snnbot_diagnostic.log"
|
||||
let roundStatsLog = "/tmp/snnbot_round_stats.log"
|
||||
let aimDebugLog = "/tmp/snnbot_aim_debug.log"
|
||||
let biasDebugLog = "/tmp/snnbot_bias_debug.log"
|
||||
|
||||
proc diagLog(s: string) =
|
||||
try:
|
||||
@@ -334,6 +335,7 @@ method onGameStarted*(bot: SNNBot, e: GameStartedEventForBot) =
|
||||
bot.res = initLeadGrid()
|
||||
truncateLog(roundStatsLog)
|
||||
truncateLog(aimDebugLog)
|
||||
truncateLog(biasDebugLog)
|
||||
|
||||
|
||||
method onBulletFired*(bot: SNNBot, e: BulletFiredEvent) =
|
||||
@@ -425,7 +427,7 @@ method run*(bot: SNNBot) =
|
||||
let leadOffset = normalizeRelativeAngle(bot.targetAngle - bot.lastAbsBearing)
|
||||
appendLog(aimDebugLog, fmt"TICK t={bot.roundTick} err={err:.2f} offset={leadOffset:.2f} vPerp={bot.lastVPerp:.2f} dist={bot.enemyDist:.1f}")
|
||||
|
||||
let readyToFire = err < 1.0 and energy >= ENERGY_GUARD and bot.roundTick >= PATIENCE_TICKS and bot.gridHasData
|
||||
let readyToFire = err < 2.0 and energy >= ENERGY_GUARD and bot.roundTick >= PATIENCE_TICKS
|
||||
if readyToFire:
|
||||
discard setFire(FIRE_POWER)
|
||||
bot.phase = EVALUATE
|
||||
@@ -451,6 +453,9 @@ method run*(bot: SNNBot) =
|
||||
# correctOffset: angle offset from bare bearing that a bullet at BULLET_SPEED needs
|
||||
let correctOffset = normalizeRelativeAngle(correctAngle - bot.lastAbsBearing)
|
||||
let producedOffset = bot.res.forward(bot.lastVPerp, bot.enemyDist)
|
||||
# Bias diagnostics: log grid offset vs correct offset to detect systematic error
|
||||
let biasVal = producedOffset - correctOffset
|
||||
appendLog(biasDebugLog, fmt"BIAS tick={bot.roundTick} gridOffset={producedOffset:.3f} correctOffset={correctOffset:.3f} bias={biasVal:.3f} vPerp={bot.lastVPerp:.3f} dist={bot.enemyDist:.1f}")
|
||||
|
||||
# Learn if: cold start OR error > dead zone
|
||||
if producedOffset > -999.0:
|
||||
|
||||
@@ -31,7 +31,7 @@ const
|
||||
|
||||
let wallsbotDir = sampleBotsDir / "Walls"
|
||||
|
||||
const ROUNDS = 20
|
||||
const ROUNDS = 50
|
||||
|
||||
let r = runBattle(@[snnbotDir, wallsbotDir], rounds = ROUNDS)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user