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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user