SNNBot: SNN-aimed gun against stationary target #147

Closed
opened 2026-09-12 11:37:03 +02:00 by SirStone · 1 comment
Owner

Destination

A new bot (SNNBot_garage/) that uses a Spiking Neural Network to learn where to aim its gun at a stationary target (SittingDuck). The SNN outputs a target angle; a deterministic aimTo() function turns the gun there. Radar uses the existing lock radar module. No firing, no movement. Two switchable learning algorithms (hill-climbing and reward-modulated STDP). Graphical debug overlay shows input activations, hidden neuron states, output angle, and aiming error. Integration test via shared test framework. Done when the gun visibly tracks the enemy and error drops over time.

Notes

  • Language: Nim. Follow existing garage convention (src/, tests/, out/).
  • Skills: nim, tdd, ponytail.
  • Bot API: Tank Royale Nim API (rtr_nim_botapi_3). Gun direction and enemy direction are both 0–360° absolute. Relative bearing via normalizeRelativeAngle(enemyDir - gunDirection) → -180° to +180°.
  • SNN architecture: 36 population-coded input neurons (10° bands, -180° to +180°), 6 LIF hidden neurons, 1 output neuron (membrane potential readout → target angle). aimTo() converts target angle to shortest gun turn.
  • Implementer chooses all gritty details — the map decides scope and approach, not implementation specifics.

Decisions so far

Not yet specified

  • Fast training runner — SNNBot currently runs against an external server at real-time TPS. For meaningful SuperSpike training, need a dedicated training runner (like PPO_Bot's RunTraining.java) with embedded server + TPS=-1 for ~100× speedup. Blocked on SuperSpike implementation.
  • How to extend the SNN to control firing once aiming is proven
  • How to extend the SNN to control movement
  • How to scale population coding resolution when training replaces hand-tuning
  • Whether to share the SNN engine as a common_lib or keep it garage-local
  • Recurrent SNN neurons (LSNN) for temporal pattern learning (wavesurfing etc.)
  • Performance benchmarking: SuperSpike vs (future) backprop convergence comparison methodology

Out of scope

  • Multiple enemies
  • Enemy movement prediction / lead targeting
  • Body movement or evasion
  • Competitive tuning against other bots
  • Prototype hill-climbing learner — dropped, STDP covers its purpose (proving topology + teaching spiking mechanics)
## Destination A new bot (`SNNBot_garage/`) that uses a Spiking Neural Network to learn where to aim its gun at a stationary target (SittingDuck). The SNN outputs a target angle; a deterministic `aimTo()` function turns the gun there. Radar uses the existing lock radar module. No firing, no movement. Two switchable learning algorithms (hill-climbing and reward-modulated STDP). Graphical debug overlay shows input activations, hidden neuron states, output angle, and aiming error. Integration test via shared test framework. Done when the gun visibly tracks the enemy and error drops over time. ## Notes - Language: Nim. Follow existing garage convention (`src/`, `tests/`, `out/`). - Skills: `nim`, `tdd`, `ponytail`. - Bot API: Tank Royale Nim API (`rtr_nim_botapi_3`). Gun direction and enemy direction are both 0–360° absolute. Relative bearing via `normalizeRelativeAngle(enemyDir - gunDirection)` → -180° to +180°. - SNN architecture: 36 population-coded input neurons (10° bands, -180° to +180°), 6 LIF hidden neurons, 1 output neuron (membrane potential readout → target angle). `aimTo()` converts target angle to shortest gun turn. - Implementer chooses all gritty details — the map decides scope and approach, not implementation specifics. ## Decisions so far - [Research Tank Royale debug drawing API](https://git.fossellini.top/SirStone/SirRoboGarage/issues/148) — SVG-based: drawLine, drawCircle, fillCircle, drawText, drawRectangle. Arena coords, auto-clears per tick, full color+alpha. - [Research aimTo() mechanics — gun turn limits and API](https://git.fossellini.top/SirStone/SirRoboGarage/issues/149) — Max 20°/tick, setGunTurnRate() auto-clamps, independent of body turn. aimToTick() already exists in PPO_Bot controllers.nim — reuse it. - [Decide learning loop structure](https://git.fossellini.top/SirStone/SirRoboGarage/issues/150) — Continuous loop (no episodes): output → wait for gun to arrive → measure error → reward = 1/(1+error) → update weights → repeat. Weights accumulate across rounds. STDP only (hill-climbing dropped). Surrogate gradient deferred. - [Decide debug overlay layout and content](https://git.fossellini.top/SirStone/SirRoboGarage/issues/151) — Mixed layout: aim lines from bot position, neuron states + alpha-coded weight connections in fixed corner panel. Error logged to stdout per evaluation. No on-screen error text. - [Prototype SNN core and aiming loop](#152) — Pipeline works: SNN forward pass → population encoding → membrane readout → aimTo() tracks the angle. Debug overlay confirmed working. - [Set up integration test for SNNBot](#153) — Smoke test vs SittingDuck, asserts battle completion - [Prototype reward-modulated STDP learner](#155) — R-STDP with eligibility traces, reward-gated weight updates - [Research SuperSpike learning rule for SNNBot gun aiming](https://git.fossellini.top/SirStone/SirRoboGarage/issues/156) — SuperSpike confirmed: purely local three-factor rule with surrogate derivative, compatible with current topology, no autograd needed - [Research PC-SNN as backup learning algorithm](https://git.fossellini.top/SirStone/SirRoboGarage/issues/157) — PC-SNN rejected: requires incompatible TTFS coding scheme, too complex for a backup - [Implement SuperSpike learning rule in SNNBot](https://git.fossellini.top/SirStone/SirRoboGarage/issues/158) — SuperSpike working: three-factor local rule with surrogate derivative, 10-tick inference window, ETA=0.05, gun tracks enemy ## Not yet specified - **Fast training runner** — SNNBot currently runs against an external server at real-time TPS. For meaningful SuperSpike training, need a dedicated training runner (like PPO_Bot's RunTraining.java) with embedded server + TPS=-1 for ~100× speedup. Blocked on SuperSpike implementation. - How to extend the SNN to control firing once aiming is proven - How to extend the SNN to control movement - How to scale population coding resolution when training replaces hand-tuning - Whether to share the SNN engine as a common_lib or keep it garage-local - Recurrent SNN neurons (LSNN) for temporal pattern learning (wavesurfing etc.) - Performance benchmarking: SuperSpike vs (future) backprop convergence comparison methodology ## Out of scope - Multiple enemies - Enemy movement prediction / lead targeting - Body movement or evasion - Competitive tuning against other bots - [Prototype hill-climbing learner](https://git.fossellini.top/SirStone/SirRoboGarage/issues/154) — dropped, STDP covers its purpose (proving topology + teaching spiking mechanics)
SirStone added the wayfinder:map label 2026-09-12 12:21:57 +02:00
Author
Owner

Resolution

Destination reached. The SNN-aimed gun visibly tracks the enemy and error drops over time.

Route walked (10 decisions):

  • Debug drawing API researched, aimTo() mechanics confirmed
  • Learning loop: continuous (no episodes), STDP-only
  • Debug overlay: aim lines + barcode neuron panel
  • SNN core prototyped: population coding → LIF hidden → sin/cos decode
  • Integration test via shared framework
  • R-STDP prototyped, hit local minima wall
  • SuperSpike researched (PC-SNN rejected as backup)
  • SuperSpike implemented — three-factor local rule with surrogate derivative, converges reliably

Deferred to future maps: fast training runner, gun firing, movement, LSNN, SNN as common_lib, performance benchmarking.

## Resolution Destination reached. The SNN-aimed gun visibly tracks the enemy and error drops over time. **Route walked (10 decisions):** - Debug drawing API researched, aimTo() mechanics confirmed - Learning loop: continuous (no episodes), STDP-only - Debug overlay: aim lines + barcode neuron panel - SNN core prototyped: population coding → LIF hidden → sin/cos decode - Integration test via shared framework - R-STDP prototyped, hit local minima wall - SuperSpike researched (PC-SNN rejected as backup) - SuperSpike implemented — three-factor local rule with surrogate derivative, converges reliably **Deferred to future maps:** fast training runner, gun firing, movement, LSNN, SNN as common_lib, performance benchmarking.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: SirStone/SirRoboGarage#147