fix(PPO_Bot): radar lock oscillation bug — arctan2 arg order wrong for Tank Royale coords

arctan2(dy, dx) gives east-based math bearing; Tank Royale uses north=0°, CW+.
Swapping to arctan2(dx, dy) gives the correct game-space bearing.
Symptom: radar commanded 45°/tick away from a target directly ahead.
Adds test_radar_lock.nim as regression test (20-tick lock, ±15° tolerance).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-08-16 16:38:15 +02:00
parent f27b0238f0
commit fd22535f5b
2 changed files with 44 additions and 1 deletions
+2 -1
View File
@@ -82,9 +82,10 @@ proc getRadarTurnRate*(tracker: var EnemyTracker;
return 45.0
# Bearing from radar to enemy
# Tank Royale: 0°=north, CW+. arctan2(dx, dy) gives north-based CW bearing.
let dx = tracker.current.x - botX
let dy = tracker.current.y - botY
let absoluteDir = (180.0 * arctan2(dy, dx) / PI + 360.0) mod 360.0
let absoluteDir = (180.0 * arctan2(dx, dy) / PI + 360.0) mod 360.0
let radarBearing = normalizeRelative(absoluteDir - radarDirection)
# Overshoot by 10°, alternate direction each tick