T2: Add linear gun module #180

Open
opened 2026-09-19 14:49:01 +02:00 by SirStone · 1 comment
Owner

Parent

#165 (ModularBot wayfinder map)

What to build

Linear extrapolation gun that plugs into the existing gun harness. Predicts enemy continues at current velocity and heading. Extrapolates position by ticksToArrive = distance / bulletSpeed. Returns absolute (x, y). onResult() is no-op (analytical gun).

Register it in ModularBot alongside head-on gun. The bot now has two guns competing via virtual bullet fitness — should switch to linear against moving targets.

Acceptance criteria

  • Linear gun implements Gun interface
  • Registered in ModularBot alongside head-on gun
  • Virtual bullet tracker shows linear gun winning against moving enemies
  • No regressions — bot still works against SittingDuck

Blocked by

#179 (T1)

## Parent #165 (ModularBot wayfinder map) ## What to build Linear extrapolation gun that plugs into the existing gun harness. Predicts enemy continues at current velocity and heading. Extrapolates position by ticksToArrive = distance / bulletSpeed. Returns absolute (x, y). onResult() is no-op (analytical gun). Register it in ModularBot alongside head-on gun. The bot now has two guns competing via virtual bullet fitness — should switch to linear against moving targets. ## Acceptance criteria - [ ] Linear gun implements Gun interface - [ ] Registered in ModularBot alongside head-on gun - [ ] Virtual bullet tracker shows linear gun winning against moving enemies - [ ] No regressions — bot still works against SittingDuck ## Blocked by #179 (T1)
SirStone added the ready-for-agent label 2026-09-19 14:49:01 +02:00
Author
Owner

Implemented. Build is clean.

common_libs/guns/linear.nim — new file:

  • predict: ticksToArrive = dist / bulletSpeed; extrapolates using cos(headingRad) * speed * ticks for X, sin(headingRad) * speed * ticks for Y; clamps to arena bounds
  • onResult: no-op (analytical gun)

ModularBot_garage/src/ModularBot.nim changes:

  • Imports guns/linear
  • Adds linear: LinearGun field
  • Tracker init changed from initTracker(1) → initTracker(2) (gun 0 = head-on, gun 1 = linear)
  • onScannedBot: spawns virtual bullets for both guns each scan
  • Feedback dispatch: routes by gunId (case on 0/1)
  • Gun selection: selectShot picks winner; pred computed from winning gun's predict
Implemented. Build is clean. **`common_libs/guns/linear.nim`** — new file: - `predict`: ticksToArrive = dist / bulletSpeed; extrapolates using `cos(headingRad) * speed * ticks` for X, `sin(headingRad) * speed * ticks` for Y; clamps to arena bounds - `onResult`: no-op (analytical gun) **`ModularBot_garage/src/ModularBot.nim`** changes: - Imports `guns/linear` - Adds `linear: LinearGun` field - Tracker init changed from `initTracker(1)` → `initTracker(2)` (gun 0 = head-on, gun 1 = linear) - `onScannedBot`: spawns virtual bullets for both guns each scan - Feedback dispatch: routes by `gunId` (`case` on 0/1) - Gun selection: `selectShot` picks winner; `pred` computed from winning gun's `predict`
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: SirStone/SirRoboGarage#180