j141 fix: the per-gun real-shot accounting was still array[17] after rack id 17 landed
REGRESSION: the live bot stopped firing entirely and moved degenerately whenever a rack admitted rack id 17 (the ADE+SBC BITBRAIN gun added ine9302bc). ROOT CAUSE: ModularBot.nim declared the per-gun accounting arrays (gunRealShots / gunRealHits / gunRealShotsByMode / gunRealHitsByMode / gunSelectionCount) as array[17, int] — the rack size BEFORE id 17 existed. The instant the selector picked gun 17, the accounting indexed one past the end: * debug build -> IndexDefect out of run(): the bot stops, 0 shots; * -d:release (shipped) -> silent out-of-bounds write onto the adjacent lastPowerLogKey: string header, so the bot kept moving but never fired and never reported a shot. Measured with the owner's exact out/.env, 1v1 SittingDuck:0dc5552(pre-rename): BitBrain(id16) selected 356+157 ticks, realShots 24+9, realHits 23+9, ModularBot wins 180/360 HEAD (e9302bc..) : selected 0, vShots 0, realShots 0, realHits 0 debug : IndexDefect on the first tick that selects id 17 -d:release : same 0/0/0, bot scores 22 and dies FIX: derive every gun-indexed width from the rack instead of a literal. gun_harness/selector exports NumRackGuns* = len(RackGunNames) (18); ModularBot uses it for the five accounting arrays, the per-round reset loops, the gun_stats.jsonl dump loop, the table and initTracker(). Shipped defaults unchanged: clean env is still the onlyPattern rack and movement is still strafe. GUARD: common_libs/tests/test_rack_stat_width.nim (24 checks) — rack table shape, a source scan proving no gun-indexed width/loop bound is narrower than NumRackGuns, an in-process accounting replay that would have overflowed array[17], and the legacy-namespace checks (id 16 via TR_RACK_BITBRAIN, id 17 never admitted while legacy). It reports 7 failures on the pre-fix ModularBot.nim and passes after. Optional --live section proves a rack admitting only the newest id fires and lands hits. Parity: test_env_report 25, test_rack_membership 49, test_lead_gain_ registration 13, test_lead_gain_legacy 24, test_bitbrain_net 44, test_gun_harness 39, test_tfil_commit_env 30, test_bitbrain 56, test_tm_pattern_registration 20 — all unchanged, 0 failures. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -52,6 +52,14 @@ const
|
||||
"WALLBOUNCE", "ACCEL", "STOPSHOT", "DISPLACE", "AVGLEAD", "DECAYGF",
|
||||
"KNN", "TMSELECT", "TMPATTERN", "TMHORIZON", "LEADGAIN", "BITBRAIN"]
|
||||
RackEnvPrefix* = "TR_RACK_"
|
||||
## THE rack size, derived from `RackGunNames`. Every per-gun-indexed array and
|
||||
## loop in the bot and in the harness MUST be sized with this, never with a
|
||||
## literal: adding a gun used to leave the live per-gun real-shot accounting
|
||||
## at `array[17, int]`, so the newest gun indexed one past the end on the
|
||||
## first tick it was selected (a hard IndexDefect in a debug build, silent
|
||||
## memory corruption in `-d:release`). See
|
||||
## `common_libs/tests/test_rack_stat_width.nim`.
|
||||
NumRackGuns* = len(RackGunNames)
|
||||
## LEADGAIN (id 16) is the per-range-band lead-gain corrector
|
||||
## (`guns/lead_gain.nim`). It USED to be called BITBRAIN; the name now
|
||||
## describes its internals (it learns a multiplier for Pattern's lead per
|
||||
|
||||
Reference in New Issue
Block a user