diff --git a/SNNBot_garage/src/SNNBot.nim b/SNNBot_garage/src/SNNBot.nim index c83a373..de9781b 100644 --- a/SNNBot_garage/src/SNNBot.nim +++ b/SNNBot_garage/src/SNNBot.nim @@ -46,6 +46,9 @@ const # ponytail: uniform exploration noise; upgrade to annealed Gaussian if convergence needs tuning FIRE_POWER = 1.0 # fixed firing power; bullet speed = 20 - 3*FIRE_POWER BULLET_SPEED = 20.0 - 3.0 * FIRE_POWER + AIM_SMOOTH_MIN = 0.3 # close range — responsive + AIM_SMOOTH_MAX = 0.9 # long range — heavy smoothing + SMOOTH_DIST_MAX = 600.0 # distance at which max smoothing kicks in # ── SNN types ───────────────────────────────────────────────────────────────── @@ -345,11 +348,12 @@ method run*(bot: SNNBot) = let binInput = toBinaryInput(relBearing, bot.velDirDeg, bot.velSpeed, bot.hasLastPos) let winBin = bot.res.forward(binInput) let aimAngle = bot.res.interpolatedAngle(winBin) - const AIM_SMOOTH = 0.6 # 60% old, 40% new — dampens flicker - # ponytail: AIM_SMOOTH=0.6 balances tracking vs stability; lower if gun lags, raise if gun dances + # Far → more smoothing (less jitter). Close → less smoothing (faster tracking). + # ponytail: linear ramp; tune MIN/MAX if gun lags close or jitters far + let alpha = clamp(bot.enemyDist / SMOOTH_DIST_MAX, AIM_SMOOTH_MIN, AIM_SMOOTH_MAX) let aimRad = degToRad(aimAngle) - bot.smoothSin = AIM_SMOOTH * bot.smoothSin + (1.0 - AIM_SMOOTH) * sin(aimRad) - bot.smoothCos = AIM_SMOOTH * bot.smoothCos + (1.0 - AIM_SMOOTH) * cos(aimRad) + bot.smoothSin = alpha * bot.smoothSin + (1.0 - alpha) * sin(aimRad) + bot.smoothCos = alpha * bot.smoothCos + (1.0 - alpha) * cos(aimRad) let smoothedAim = radToDeg(arctan2(bot.smoothSin, bot.smoothCos)) bot.lastBinInput = binInput bot.targetAngle = gunDir + smoothedAim