BitBrain gun (id 16): Pattern-relative ADE+SBC aim corrector, default off

Wire the verified common_libs/bitbrain ADE+SBC library into ModularBot as a
fine-grained angular corrector on top of Pattern's prediction, the shape the
offline gate test measured (argmax readout over N correction classes).

- common_libs/guns/bitbrain_gun.nim: new gun. Input = the existing TMHorizon
  53 bits (tmhBaseBits + tmhLits); output = argmax class centre over
  +-TR_BITBRAIN_RANGE, applied by rotating the Pattern point around the shooter
  exactly as tmhApplyShift does. Label = the +h-tick fact from TmHorizonGun's
  own observation ring (never across a round). Prequential (defer + resolve).
  AD layer synthesised online for our binary inputs (center=0): heuristic
  cold-start thresholds + running-histogram ~1% percentile init + the library's
  adaptThresholds. Memory modes perRound (default, measured best) / retained /
  decay (periodic partial SBC wipe). Lazy network build + local RNG, so the
  default path builds nothing and consumes no global randomness.
- tm_horizon.nim: export tmhUpdateHistory and add tmhObservedAt (label seam).
- selector.nim: register BITBRAIN at rack id 16, default rmOff, in the SAME
  commit as the id and the wiring (the aed579b admission bug is not repeated).
- ModularBot.nim: id 16 wired through predict/spawn/onResult/resets/colors,
  arrays grown 16->17, spawn gated on rack admission, per-round/per-battle/
  target reset hooks.
- env_report.nim: report every TR_BITBRAIN_* knob + add names to the known set.
- tests: update the rack length literals; new test_bitbrain_registration
  (default-parity: off, lazy, global-RNG clean).

Guard counts unchanged: rack 48, tm_pattern_registration 20, vbullet_admit 12,
env_report 25, and the rest of the suite green.
This commit is contained in:
2026-09-24 22:25:04 +02:00
parent 1fec87537d
commit 795a0e59fe
8 changed files with 721 additions and 28 deletions
+8 -4
View File
@@ -44,10 +44,10 @@ import virtual_bullets
# transition the radar uses.
const
RackGunNames*: array[16, string] = [
RackGunNames*: array[17, string] = [
"HEADON", "LINEAR", "TSETLIN", "CIRCULAR", "GUESSFACTOR", "PATTERN",
"WALLBOUNCE", "ACCEL", "STOPSHOT", "DISPLACE", "AVGLEAD", "DECAYGF",
"KNN", "TMSELECT", "TMPATTERN", "TMHORIZON"]
"KNN", "TMSELECT", "TMPATTERN", "TMHORIZON", "BITBRAIN"]
RackEnvPrefix* = "TR_RACK_"
## SHIPPED DEFAULT: `onlyPattern`. Pattern (id 5) is admitted in both racks;
## every other gun is `off`. The selection mechanism is untouched and remains
@@ -57,7 +57,7 @@ const
## it never spawns a virtual bullet unless explicitly enabled, so the shared
## VirtualTracker ring head — and every other gun's learning order — is
## unchanged.
DefaultRackMembership*: array[16, RackMembership] = [
DefaultRackMembership*: array[17, RackMembership] = [
rmOff, # 0 HEADON — off (measured: worst over-selected gun)
rmOff, # 1 LINEAR — off
rmOff, # 2 TSETLIN — off
@@ -73,7 +73,11 @@ const
rmOff, # 12 KNN — off
rmOff, # 13 TMSELECT — off
rmOff, # 14 TMPATTERN — off (already shipped off; TM pattern gun)
rmOff] # 15 TMHORIZON — off (horizon-based TM corrector; expected to lose)
rmOff, # 15 TMHORIZON — off (horizon-based TM corrector; expected to lose)
rmOff] # 16 BITBRAIN — off (fine-grained ADE+SBC corrector)
## NOTE: the table is registered in the SAME commit as the gun id (16) and the
## live wiring, so `TR_RACK_BITBRAIN=both` is the ONLY thing that admits it and
## an unset environment is byte-for-byte the shipped Pattern-only rack.
proc parseRackMembership*(value: string): RackMembership =
## Parse a `TR_RACK_<GUN>` value. Empty / unknown values fall back to the