Commit Graph

56 Commits

Author SHA1 Message Date
SirStone 0ee5c21ef5 fix(SNNBot): store SNN state in aim snapshots for correct retroactive learning
The retroactive error signal matures many ticks after the snapshot was taken,
but superSpikeUpdate was using bot.lastSpikes/lastVSnap which had been
overwritten by subsequent DECIDE cycles. Learning was applied against wrong
neural activity — effectively random weight perturbations.

Fix: AimSnapshot now captures spikes, vSnap, and preTrace at DECIDE time.
superSpikeUpdate receives these saved values at maturation instead of the
stale current state.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-09-14 22:08:22 +02:00
SirStone 5740c56a9f feat(SNNBot): add velocity input encoding and retroactive error signal (#159)
- Expand input layer from 36 to 80 neurons: bearing (0-35) + velocity direction (36-71) + speed (72-79)
- Population-code velocity direction (same 10° band scheme as bearing) and speed (8 bands, 1 unit/tick)
- Compute 1-tick velocity from position deltas in onScannedBot
- Add 100-slot ring buffer with per-slot tick tracking for enemy positions
- Replace instantaneous bearing error with retroactive would-have-hit signal
- Skip learning until first aim snapshot matures (buffer fill period)
- Delayed-target SuperSpike: weight updates use most recently matured retroactive bearing

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-09-14 21:34:59 +02:00
SirStone 23bdf8acd6 research(SNNBot): survey existing lead-targeting and enemy tracking code
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-09-13 20:30:10 +02:00
SirStone dbae449273 feat(SNNBot): replace R-STDP with SuperSpike learning rule (#158)
Three-factor local learning: Δw = η × pre_trace × σ'(U) × error
- Surrogate derivative σ'(U) = 1/(1+|β(U-ϑ)|)² gives directional gradient
- Random feedback weights project output error to hidden layer
- 10-tick inference window for rate-coded sin/cos output
- Fixed stale learning target bug (EVALUATE used wrong gun direction)

Hyperparams: ETA=0.05, THRESH=0.2, W_CLAMP=1.0, N_INFER=10, BETA=1.0
Removed: R-STDP eligibility traces, STDP timing window, exploration noise

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-09-13 20:07:31 +02:00
SirStone 2bfa8eb6a5 feat(SNNBot): add STDP learner and integration test (#153, #155)
- Implement reward-modulated STDP: spike timing, eligibility traces,
  reward-gated weight updates (w += η * reward * trace), clamp [-2,2]
- Add integration smoke test vs SittingDuck (compile + battle completion)
- Add tests/config.nims and nimble test task
2026-09-13 10:31:07 +02:00
SirStone c038128c2f feat(SNNBot): upgrade bot API, fix debug overlay and aiming lines
- Upgrade to robocode_tankroyale_botapi v1.0.7 (SVG viewBox fix)
- Fix Y-axis mirror in aiming line toXY helper
- Resize debug panel to half arena width/height
- Replace neuron boxes with barcode-style spike lines
- Thickness-encoded weight connections (all 216 lines)
- Add aiming line legend (top-left, white text)
- Dynamic aiming line length (distance + 50px overshoot)
2026-09-13 10:24:20 +02:00