From d545a6f95dfa56b0535de52c64bc8ab650d3c378 Mon Sep 17 00:00:00 2001 From: Davide Cappellini Date: Thu, 17 Sep 2026 08:30:52 +0200 Subject: [PATCH] =?UTF-8?q?experiment(SNNBot):=20power=202,=20tight=201?= =?UTF-8?q?=C2=B0=20fire=20gate,=20suppress=20cold-start=20fire?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Sonnet 4.6 --- SNNBot_garage/src/SNNBot.nim | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/SNNBot_garage/src/SNNBot.nim b/SNNBot_garage/src/SNNBot.nim index 9d32085..3525ead 100644 --- a/SNNBot_garage/src/SNNBot.nim +++ b/SNNBot_garage/src/SNNBot.nim @@ -72,8 +72,8 @@ const NOISE_AMP = 0.3 # exploration noise amplitude # ponytail: uniform exploration noise; upgrade to annealed Gaussian if convergence needs tuning ENERGY_GUARD = 5.0 # keep buffer; Walls hits us while we shoot - FIRE_POWER = 3.0 # fixed fire power - BULLET_SPEED = 11.0 # 20 - 3 * FIRE_POWER + FIRE_POWER = 2.0 # fixed fire power + BULLET_SPEED = 14.0 # 20 - 3 * FIRE_POWER COLD_K = 3 # exemplars needed before leaving cold start PATIENCE_TICKS = 5 # ticks before first fire allowed @@ -250,6 +250,7 @@ type bulletsFired: int # count of bullets fired this round bulletsHit: int # count of bullets that hit this round hitRateEMA: float # exponential moving average of hit rate + gridHasData: bool # false during cold-start (forward returned -999) # ── aimTo helper ────────────────────────────────────────────────────────────── @@ -313,6 +314,7 @@ method onRoundStarted*(bot: SNNBot, e: RoundStartedEvent) = bot.bulletsFired = 0 bot.bulletsHit = 0 bot.hitRateEMA = 0.5 # optimistic start + bot.gridHasData = false bot.lastEnemyX = 0.0 bot.lastEnemyY = 0.0 bot.lastAbsBearing = 0.0 @@ -376,6 +378,7 @@ method run*(bot: SNNBot) = bot.lastDecideGunDir = gunDir bot.lastAbsBearing = absBearing let rate = if bot.bulletsFired > 0: float(bot.bulletsHit) / float(bot.bulletsFired) * 100.0 else: 0.0 + bot.gridHasData = gridOffset > -999.0 if gridOffset <= -999.0: bot.targetAngle = absBearing echo "RES tick=" & $bot.tick & " hitEMA=" & formatFloat(bot.hitRateEMA * 100.0, ffDecimal, 0) & "% cold-start aim=" & formatFloat(absBearing, ffDecimal, 1) & " fired=" & $bot.bulletsFired & " hit=" & $bot.bulletsHit & " rate=" & formatFloat(rate, ffDecimal, 1) & "% energy=" & formatFloat(getEnergy(), ffDecimal, 0) & " cells=" & $bot.res.totalCount @@ -422,7 +425,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 < 2.0 and energy >= ENERGY_GUARD and bot.roundTick >= PATIENCE_TICKS + let readyToFire = err < 1.0 and energy >= ENERGY_GUARD and bot.roundTick >= PATIENCE_TICKS and bot.gridHasData if readyToFire: discard setFire(FIRE_POWER) bot.phase = EVALUATE