T4: Add movement harness + oscillator module #182

Open
opened 2026-09-19 14:49:06 +02:00 by SirStone · 2 comments
Owner

Parent

#165 (ModularBot wayfinder map)

What to build

Movement trait and harness, plus first movement module:

  • Movement trait (common_libs/movement_harness/): MovementModule concept with computeMove(state) → (speed, turnRate). Harness calls module every tick, applies to bot. No fitness selector yet — single module only. Interface designed for future selector.
  • Oscillator module (common_libs/movements/oscillator.nim): Perpendicular strafing relative to enemy bearing, periodic direction reversal.

Wire into ModularBot. The bot now dodges instead of sitting still.

Acceptance criteria

  • MovementModule concept defined and importable
  • Movement harness applies module output every tick
  • Oscillator module implements MovementModule
  • ModularBot moves during battle (no longer stationary)
  • Gun accuracy not degraded (movement shouldn't break aiming)

Blocked by

#179 (T1)

## Parent #165 (ModularBot wayfinder map) ## What to build Movement trait and harness, plus first movement module: - **Movement trait** (`common_libs/movement_harness/`): `MovementModule` concept with `computeMove(state) → (speed, turnRate)`. Harness calls module every tick, applies to bot. No fitness selector yet — single module only. Interface designed for future selector. - **Oscillator module** (`common_libs/movements/oscillator.nim`): Perpendicular strafing relative to enemy bearing, periodic direction reversal. Wire into ModularBot. The bot now dodges instead of sitting still. ## Acceptance criteria - [ ] MovementModule concept defined and importable - [ ] Movement harness applies module output every tick - [ ] Oscillator module implements MovementModule - [ ] ModularBot moves during battle (no longer stationary) - [ ] Gun accuracy not degraded (movement shouldn't break aiming) ## Blocked by #179 (T1)
SirStone added the ready-for-agent label 2026-09-19 14:49:06 +02:00
Author
Owner

Movement harness implemented and wired. Build passes.

Files created:

  • common_libs/movement_harness/movement_interface.nim — MoveCommand tuple type + isMovementModule concept, re-exports WorldState from gun_interface
  • common_libs/movements/oscillator.nim — OscillatorModule: perpendicular strafing (enemy bearing + 90°), reverses every 40 ticks or on wall proximity (<60px), speed ±8, turnRate clamped ±10°/tick

ModularBot.nim changes:

  • Added import movements/oscillator
  • Added mover: OscillatorModule field
  • onRoundStarted: resets bot.mover = initOscillator()
  • run(): replaces setTargetSpeed(0)/setTurnRate(0) with computeMove(lastState) output when contact is established; stationary while searching

Note: file was concurrently modified by another agent (radar harness already landed), changes merged on top of that state.

Movement harness implemented and wired. Build passes. **Files created:** - `common_libs/movement_harness/movement_interface.nim` — `MoveCommand` tuple type + `isMovementModule` concept, re-exports `WorldState` from gun_interface - `common_libs/movements/oscillator.nim` — `OscillatorModule`: perpendicular strafing (enemy bearing + 90°), reverses every 40 ticks or on wall proximity (<60px), speed ±8, turnRate clamped ±10°/tick **ModularBot.nim changes:** - Added `import movements/oscillator` - Added `mover: OscillatorModule` field - `onRoundStarted`: resets `bot.mover = initOscillator()` - `run()`: replaces `setTargetSpeed(0)/setTurnRate(0)` with `computeMove(lastState)` output when contact is established; stationary while searching Note: file was concurrently modified by another agent (radar harness already landed), changes merged on top of that state.
Author
Owner

Done. Created /common_libs/movements/phantom_meteor.nim — full gravity engine (danger histogram, phantom bullets, waves, wall forces) adapted as a MovementModule.

Changes:

  • gun_interface.nim: added enemyEnergy field to WorldState
  • common_libs/movements/phantom_meteor.nim: new file — PhantomMeteorModule with initPhantomMeteor(), resetRound(), computeMove(state) → (speed, turnRate)
  • ModularBot.nim: swapped oscillator → phantom_meteor; buildState passes e.energy; onRoundStarted calls bot.mover.resetRound() (histogram survives rounds, transients reset); isMainModule init updated

Build: clean (nimble build exits 0).

Done. Created `/common_libs/movements/phantom_meteor.nim` — full gravity engine (danger histogram, phantom bullets, waves, wall forces) adapted as a `MovementModule`. Changes: - `gun_interface.nim`: added `enemyEnergy` field to `WorldState` - `common_libs/movements/phantom_meteor.nim`: new file — `PhantomMeteorModule` with `initPhantomMeteor()`, `resetRound()`, `computeMove(state) → (speed, turnRate)` - `ModularBot.nim`: swapped oscillator → phantom_meteor; `buildState` passes `e.energy`; `onRoundStarted` calls `bot.mover.resetRound()` (histogram survives rounds, transients reset); `isMainModule` init updated Build: clean (`nimble build` exits 0).
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: SirStone/SirRoboGarage#182