T6: Extract Tsetlin Machine as gun module #184
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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.