## Offline guard for the TM pattern gun rack registration (id 14) and the ## default-path parity proof. ## ## Covers: ## * RackGunNames / DefaultRackMembership carry the new gun, defaulting `off`; ## * `TR_RACK_TMPATTERN` parses both|1v1|melee|off like every other gun; ## * the DEFAULT membership table admits exactly the OLD 14-gun rack, so the ## selection sequence is identical to the pre-change all-`both` rack, RNG ## draw for RNG draw, through both `bestGun` and the live `selectGun`; ## * `initTmRadialGun()` selects the radial target mode; ## * the deferred-label fix (Task 2) resolves every fired virtual bullet: ## a radial-mode replay ends with `labelMisses == 0` and non-zero training. ## ## Run: nim c -r common_libs/tests/test_tm_pattern_registration.nim import std/[random, tables, os] import gun_harness/gun_interface import gun_harness/virtual_bullets import gun_harness/selector import gun_harness/offline_range import guns/tm_pattern const TmPatternId = 14 proc toSeq(r: HSlice[int, int]): seq[int] = for i in r.a..r.b: result.add i var failures = 0 proc check(name: string, ok: bool) = if ok: echo "PASS: ", name else: echo "FAIL: ", name; inc failures proc recordHit(fw: var FitnessWindow, hit: bool) = fw.hits[fw.head] = hit fw.head = (fw.head + 1) mod WindowSize inc fw.count proc seedWindow(t: var VirtualTracker, targetId, gunId, binIdx, hits, misses: int) = if targetId notin t.fitness: t.fitness[targetId] = newSeq[GunFitness](t.numGuns) var fw = addr t.fitness[targetId][gunId].bins[binIdx] for _ in 0.. 0)", g2.totalObs > 0 check "deferred: no label misses remain (labelMisses == 0)", g2.labelMisses == 0 check "deferred: the pending queue never overflowed", g2.pendingDropped == 0 check "deferred: the radial head is scored above chance (radTotal > 0)", g2.radTotal > 0 and g2.radCorrect > 0 when isMainModule: testTable() testDefaultAdmitsOldRack() testEnvOverride() testDefaultSelectionParity() testRadialInit() testDeferredLabel() if failures > 0: echo "\n", failures, " check(s) FAILED" quit(1) echo "\nAll TM pattern registration checks passed."