fix(PPO_Bot): radar oscillation, Adam persistence, checkpoint order, channel race

- enemy_tracker: toggle lastOvershootDir each tick; make getRadarTurnRate take var tracker
- training: remove threadvar Adam globals; pass adamStates as var param to ppoUpdate; export ACAdamStates
- PPO_Bot: carry ACAdamStates through TrainingArgs/TrainingResult; drop trainingDone bool and Lock — use resultChan.tryRecv() directly as synchronisation
- weights: sort checkpoint dirs newest-first by mtime instead of hardcoded order
- tests/test_training: pass explicit ACAdamStates to ppoUpdate

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-08-16 15:42:06 +02:00
parent 473d67f644
commit aea0724d3a
5 changed files with 74 additions and 62 deletions
+2 -1
View File
@@ -69,7 +69,7 @@ proc normalizeRelative(angle: float64): float64 {.inline.} =
if result >= 180.0: result -= 360.0
elif result < -180.0: result += 360.0
proc getRadarTurnRate*(tracker: EnemyTracker;
proc getRadarTurnRate*(tracker: var EnemyTracker;
botX, botY, botDirection, radarDirection: float64): float64 =
## Returns radar turn rate (degrees/tick, positive = right).
## Before contact: full 45° sweep.
@@ -92,3 +92,4 @@ proc getRadarTurnRate*(tracker: EnemyTracker;
let overshoot = 10.0
let target = radarBearing + tracker.lastOvershootDir * overshoot
result = target.clamp(-45.0, 45.0)
tracker.lastOvershootDir *= -1.0