diff --git a/SNNBot_garage/SNNBot b/SNNBot_garage/SNNBot index 69a64f3..a2bfc31 100755 Binary files a/SNNBot_garage/SNNBot and b/SNNBot_garage/SNNBot differ diff --git a/SNNBot_garage/src/SNNBot.nim b/SNNBot_garage/src/SNNBot.nim index 3525ead..24c004d 100644 --- a/SNNBot_garage/src/SNNBot.nim +++ b/SNNBot_garage/src/SNNBot.nim @@ -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: diff --git a/SNNBot_garage/tests/test_bullet_economy.nim b/SNNBot_garage/tests/test_bullet_economy.nim index f801879..6d6ce59 100644 --- a/SNNBot_garage/tests/test_bullet_economy.nim +++ b/SNNBot_garage/tests/test_bullet_economy.nim @@ -31,7 +31,7 @@ const let wallsbotDir = sampleBotsDir / "Walls" -const ROUNDS = 20 +const ROUNDS = 50 let r = runBattle(@[snnbotDir, wallsbotDir], rounds = ROUNDS)