SHIPPED: the default rack is now Pattern-only (+49% hit rate, +66% damage on the boss)

`DefaultRackMembership` now admits Pattern (id 5) and marks all 14 other guns
`rmOff`. **The selector mechanism is untouched** - `chooseFromFit`, the floor/band
logic, the hysteresis and the virtual-fitness plumbing are all intact and
functional. Only the rack membership changed, so this is reverted by env alone.

Evidence (measured, replicated three times, 10 adversaries): Pattern alone gives
10.36% real hit rate / 264 damage per run vs the full rack's 6.93% / 159. Pattern
significantly wins on DrussGT, Corners, Crazy and PatternMover, ties on three, and
the full rack never significantly beats it on ANY adversary. Mechanism: the
virtual signal keeps ranking the wrong guns first (HeadOn 46% of ticks at 2.0%
real; Linear 57.7% at 6.0% real while Pattern sits at 11.1%).

**THIS CONTRADICTS THE USER'S STANDING DIRECTIVE** to keep virtual-fitness
selection. Recorded plainly in docs/selector_negative_value.md with a SHIPPED
DECISION banner rather than done quietly: the mechanism is retained and one env
var away, because the measurement says it is negative value on every rack size
tested and on 10/10 adversaries.

Revert one-liner (no rebuild):
  TR_RACK_PATTERN=both TR_RACK_HEADON=both TR_RACK_LINEAR=both TR_RACK_TSETLIN=both \
  TR_RACK_CIRCULAR=both TR_RACK_GUESSFACTOR=both TR_RACK_WALLBOUNCE=both \
  TR_RACK_ACCEL=both TR_RACK_STOPSHOT=both TR_RACK_DISPLACE=both TR_RACK_AVGLEAD=both \
  TR_RACK_DECAYGF=both TR_RACK_KNN=both TR_RACK_TMSELECT=both ./out/ModularBot
The unit test `testRevertOverrideRestoresFullRack` exercises exactly this table.

FLOOR PATH, verified not assumed: `chooseFromFit` already returns `admitted[0]` on
the floor path, so it respects admission by construction. Cold field + shipped
default -> floor returns Pattern (id 5), NOT HeadOn. With an explicit all-`both`
membership the same cold field returns gun 0 (HeadOn) - the old behaviour. Four
assertions in `testFloorRespectsAdmission`.

LIVENESS: one 1-round battle with NO overrides -> Pattern selected 105/105 = 100%,
every other gun 0 including TMPattern.

Honesty caveat retained in the doc: 4 of the 10 opponents were Tank Royale
sample-bot PORTS rather than the original classic jars (only DrussGT is a real
classic jar through the shim).

Guards: test_rack_membership 48 (was 38; new floor/revert/default checks),
test_tm_pattern_registration 20 (5 checks hard-coded the old default and were
updated to assert the new one, with the TMPATTERN parity proof moved onto an
explicit old-rack table), test_gun_harness 39, test_vbullet_metric 11,
test_power_selection 3, test_adaptive_radar 41, test_tfil_ring_weights 24,
test_power_policy 26, test_ram_decision 28, test_selector_tiebreak 19,
test_tm_pattern_rack_live 4, test_tm_pattern_learning 3,
acceptance_offline_vs_online 12/12 VERDICT PASS. ModularBot compiles.

FOLLOW-ON THIS EXPOSED: membership filters SELECTION but not virtual-bullet
SPAWNING, so under `onlyPattern` the 13 unselected guns still predict and spawn
every tick. Tsetlin alone is ~5.3 ms/tick (~41% of the 13.16 ms per-tick budget),
so we are still paying for it while never using it. Gating spawn on admission
would reclaim that; it was deliberately NOT done here because it would alter the
measurement protocol mid-A/B.
This commit is contained in:
2026-09-22 02:10:07 +02:00
parent 9cd6e9b8ce
commit 31c7c01d28
4 changed files with 202 additions and 53 deletions
+44 -14
View File
@@ -15,17 +15,33 @@ import virtual_bullets
# GUN_RACK_DISABLE. A gun's membership admits it into the 1v1 rack, the melee
# rack, both, or neither:
#
# TR_RACK_HEADON=both (shipped default for every gun)
# TR_RACK_PATTERN=both (shipped default: the ONLY admitted gun)
# TR_RACK_HEADON=both -> re-admit HeadOn (used to restore the old rack)
# TR_RACK_TSETLIN=1v1 -> 1v1 rack only
# TR_RACK_DISPLACE=melee -> melee rack only
# TR_RACK_KNN=off -> removed from both racks
# TR_RACK_TMPATTERN=off (shipped default for the new TM pattern gun)
#
# SHIPPED DEFAULT IS `onlyPattern`: Pattern (id 5) is admitted in both racks and
# every other gun is `off`. This is a deliberate, measured decision, not a
# pruning heuristic — the virtual-fitness selector was measured to be NEGATIVE
# value at every rack size tested (full, lean8, lean6, pairPC/PK/PL) and against
# 10/10 adversaries, while Pattern alone is the best single gun in general. See
# docs/selector_negative_value.md. The selector MECHANISM is retained in full
# (chooseFromFit, the floor/band logic, hysteresis, virtual fitness) — the rack
# merely has one member by default, so re-enabling any gun is a one-line env
# override with no rebuild:
#
# Revert to the old full rack (all guns `both`, TMPATTERN `off`):
# TR_RACK_PATTERN=both TR_RACK_HEADON=both TR_RACK_LINEAR=both \
# TR_RACK_TSETLIN=both TR_RACK_CIRCULAR=both TR_RACK_GUESSFACTOR=both \
# TR_RACK_WALLBOUNCE=both TR_RACK_ACCEL=both TR_RACK_STOPSHOT=both \
# TR_RACK_DISPLACE=both TR_RACK_AVGLEAD=both TR_RACK_DECAYGF=both \
# TR_RACK_KNN=both TR_RACK_TMSELECT=both ./ModularBot
#
# The mode itself is derived from SERVER truth (`getEnemyCount()`), never from
# the tracker's known-enemy count, by `rackMode` in virtual_bullets — the same
# transition the radar uses. Every gun except TMPATTERN defaults to `both`, so an
# unset environment preserves the pre-change single-rack selection byte-for-byte;
# TMPATTERN defaults to `off` so it cannot alter that selection.
# transition the radar uses.
const
RackGunNames*: array[15, string] = [
@@ -33,16 +49,30 @@ const
"WALLBOUNCE", "ACCEL", "STOPSHOT", "DISPLACE", "AVGLEAD", "DECAYGF",
"KNN", "TMSELECT", "TMPATTERN"]
RackEnvPrefix* = "TR_RACK_"
## Defaults are all-`both` EXCEPT the new TM pattern gun (id 14), which ships
## `off`: it is registered and forceable (`TR_RACK_TMPATTERN=both|1v1|melee`)
## but never spawns a virtual bullet unless explicitly enabled, so the shared
## VirtualTracker ring head — and therefore every other gun's learning order
## and the default selection sequence — is byte-for-byte unchanged. Defaulting
## it to `both` would let it compete for selection and change the default rack.
## SHIPPED DEFAULT: `onlyPattern`. Pattern (id 5) is admitted in both racks;
## every other gun is `off`. The selection mechanism is untouched and remains
## fully functional — only the rack's membership changed. Re-enable any gun
## with `TR_RACK_<GUN>`, or restore the old full rack with the one-liner in the
## header comment. TMPATTERN (id 14) stays `off`: registered and forceable but
## 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[15, RackMembership] = [
rmBoth, rmBoth, rmBoth, rmBoth, rmBoth, rmBoth, rmBoth,
rmBoth, rmBoth, rmBoth, rmBoth, rmBoth, rmBoth, rmBoth,
rmOff]
rmOff, # 0 HEADON — off (measured: worst over-selected gun)
rmOff, # 1 LINEAR — off
rmOff, # 2 TSETLIN — off
rmOff, # 3 CIRCULAR — off
rmOff, # 4 GUESSFACTOR — off
rmBoth, # 5 PATTERN — the only admitted gun (best single gun in general)
rmOff, # 6 WALLBOUNCE — off
rmOff, # 7 ACCEL — off
rmOff, # 8 STOPSHOT — off
rmOff, # 9 DISPLACE — off
rmOff, # 10 AVGLEAD — off
rmOff, # 11 DECAYGF — off
rmOff, # 12 KNN — off
rmOff, # 13 TMSELECT — off
rmOff] # 14 TMPATTERN — off (already shipped off; TM pattern gun)
proc parseRackMembership*(value: string): RackMembership =
## Parse a `TR_RACK_<GUN>` value. Empty / unknown values fall back to the
@@ -85,7 +115,7 @@ proc rackModeName*(m: RackMode): string =
proc rackOverrides*(membership: openArray[RackMembership]): string =
## Compact `GUN:mode,GUN:mode` list of entries that differ from the shipped
## all-`both` default. Empty when the rack is at its default.
## default table. Empty when the rack is at its default.
for i in 0..<min(len(RackGunNames), membership.len):
if membership[i] != rmBoth:
if result.len > 0: result.add ","