feat(movement): multi-enemy awareness — phantom meteor + minimum risk track all enemies

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-09-20 12:28:27 +02:00
parent f06b263ae5
commit ae9a5fec6d
4 changed files with 87 additions and 36 deletions
+7 -5
View File
@@ -7,9 +7,6 @@ import std/math
import gun_harness/gun_interface
import movement_harness/movement_interface
# TODO: WorldState only carries one enemy. Extend WorldState with a seq of
# threat positions (enemies) and update scoreCandidates to iterate all of them.
# For now we treat the single enemy as the only threat point.
const
CandidateRadius = 150.0 # px radius for ring candidates
@@ -80,8 +77,13 @@ proc recalcTarget(m: var MinimumRiskModule, ws: WorldState) =
let w = ws.arenaWidth
let h = ws.arenaHeight
# Single threat for now; TODO: replace with ws.enemies when available
let threats = [vec2(ws.enemyX, ws.enemyY)]
# Use all alive enemies; fall back to single target when seq is empty
var threats: seq[Vec2]
if ws.enemies.len > 0:
for ei in ws.enemies:
threats.add vec2(ei.x, ei.y)
else:
threats.add vec2(ws.enemyX, ws.enemyY)
# Build candidates: ring + random (deterministic via tick-seeded offsets)
var best = bot # fallback: stay put