## Parent
#165 (ModularBot wayfinder map)
## What to build
Extract TM predictor from BNNBot_garage and adapt it as a Gun module. The TM gun is a learning gun — it uses onResult() to train on miss corrections.
- Extract `tsetlin_predictor.nim` and `binary_encoding.nim` into a gun module at `common_libs/guns/tsetlin.nim`
- Adapt to Gun interface: predict() runs TM forward pass + correction on extrapolated position, onResult() matches tick via internal eligibility traces and calls learn()
- Manages own frame history window
- Configurable: clauses, T, s, states
Register in ModularBot. The learning gun competes with analytical ones — should eventually outperform against complex movement patterns.
## Acceptance criteria
- [ ] TM gun implements Gun interface
- [ ] predict() returns absolute (x, y) using TM correction on linear extrapolation
- [ ] onResult() triggers TM learning via eligibility traces
- [ ] Registered in ModularBot — four guns competing
- [ ] TM gun's fitness improves over rounds (visible in virtual bullet stats)
## Blocked by
#179 (T1)
TsetlinGun implemented and wired into ModularBot. Build passes.
What was done:
Created common_libs/guns/tsetlin.nim — self-contained: binary encoding and TM predictor inlined, no dependency on BNNBot_garage.
Implements Gun interface: predict(state, bulletSpeed) → GunPrediction and onResult(FeedbackEvent).
predict(): encodes WorldState into 870-bit binary vector (sliding window of 10 frames × 83 bits + 40 self bits), runs TM forward pass, applies (cx, cy) correction on top of linear extrapolation, returns clamped absolute (x, y). Falls back to pure linear during warm-up (first 10 frames).
onResult(): matches the resolved bullet back to its stored trace via prediction coords, computes shaped residual from miss distance, calls TM learn on both output dimensions.
Internal ring buffer of 64 trace slots for eligibility matching.
Registered in ModularBot as gun 2 (tracker: vb.initTracker(3)); headOn=0, linear=1, tsetlin=2.
Design notes:
onResult receives miss distance but not direction. Residual is split equally across x/y axes (√2 factor). Upgrade path: add enemyX/Y to FeedbackEvent for directional residuals.
circular import stays in ModularBot (other work), CircularGun field retained but not wired to tracker yet.
ponytail: comment in tsetlin.nim marks the 50/50 residual split as a deliberate simplification.
TsetlinGun implemented and wired into ModularBot. Build passes.
**What was done:**
- Created `common_libs/guns/tsetlin.nim` — self-contained: binary encoding and TM predictor inlined, no dependency on BNNBot_garage.
- Implements Gun interface: `predict(state, bulletSpeed) → GunPrediction` and `onResult(FeedbackEvent)`.
- `predict()`: encodes WorldState into 870-bit binary vector (sliding window of 10 frames × 83 bits + 40 self bits), runs TM forward pass, applies (cx, cy) correction on top of linear extrapolation, returns clamped absolute (x, y). Falls back to pure linear during warm-up (first 10 frames).
- `onResult()`: matches the resolved bullet back to its stored trace via prediction coords, computes shaped residual from miss distance, calls TM learn on both output dimensions.
- Internal ring buffer of 64 trace slots for eligibility matching.
- TM config: 50 clauses, T=25.0, s=1.5, states=32 (int16).
- Registered in ModularBot as gun 2 (`tracker: vb.initTracker(3)`); headOn=0, linear=1, tsetlin=2.
**Design notes:**
- `onResult` receives miss distance but not direction. Residual is split equally across x/y axes (√2 factor). Upgrade path: add `enemyX/Y` to `FeedbackEvent` for directional residuals.
- `circular` import stays in ModularBot (other work), `CircularGun` field retained but not wired to tracker yet.
- `ponytail:` comment in tsetlin.nim marks the 50/50 residual split as a deliberate simplification.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Parent
#165 (ModularBot wayfinder map)
What to build
Extract TM predictor from BNNBot_garage and adapt it as a Gun module. The TM gun is a learning gun — it uses onResult() to train on miss corrections.
tsetlin_predictor.nimandbinary_encoding.niminto a gun module atcommon_libs/guns/tsetlin.nimRegister in ModularBot. The learning gun competes with analytical ones — should eventually outperform against complex movement patterns.
Acceptance criteria
Blocked by
#179 (T1)
TsetlinGun implemented and wired into ModularBot. Build passes.
What was done:
common_libs/guns/tsetlin.nim— self-contained: binary encoding and TM predictor inlined, no dependency on BNNBot_garage.predict(state, bulletSpeed) → GunPredictionandonResult(FeedbackEvent).predict(): encodes WorldState into 870-bit binary vector (sliding window of 10 frames × 83 bits + 40 self bits), runs TM forward pass, applies (cx, cy) correction on top of linear extrapolation, returns clamped absolute (x, y). Falls back to pure linear during warm-up (first 10 frames).onResult(): matches the resolved bullet back to its stored trace via prediction coords, computes shaped residual from miss distance, calls TM learn on both output dimensions.tracker: vb.initTracker(3)); headOn=0, linear=1, tsetlin=2.Design notes:
onResultreceives miss distance but not direction. Residual is split equally across x/y axes (√2 factor). Upgrade path: addenemyX/YtoFeedbackEventfor directional residuals.circularimport stays in ModularBot (other work),CircularGunfield retained but not wired to tracker yet.ponytail:comment in tsetlin.nim marks the 50/50 residual split as a deliberate simplification.