5e32ec16df
Remove guns/bitbrain_net.nim (+README), test_bitbrain_net.nim,
measure_bitbrain_scaling.nim, rack id 17 and all of its plumbing in
selector.nim / ModularBot.nim / env_report.nim, the TR_BITBRAIN_NET switch
and the NEW-NETWORK TR_BITBRAIN_* knobs, and the BitBrainNet arm of
run_prediction_quality.nim.
With id 17 gone there is nothing to disambiguate, so the legacy namespace
becomes the ONLY one: TR_RACK_BITBRAIN always selects id 16 LEADGAIN and
every TR_BITBRAIN_<X> in the frozen 14-suffix alias set always means
TR_LEADGAIN_<X>. The alias layer and its [depr] line stay.
KEPT: the common_libs/bitbrain/ SBC library (learned_surfer imports
bitbrain/sbc), lead_gain at id 16 with env TR_LEADGAIN_* and log tag [lg],
and the c9b6753 crash fix (NumRackGuns widths + test_rack_stat_width).
Tombstone: docs/bitbrain_campaign.md ## RETIRED and one cross-reference line
in docs/gun_campaign.md. Shipped defaults unchanged: clean env -> rack
active 1v1 = PATTERN, movement default strafe.
90 lines
3.4 KiB
Nim
90 lines
3.4 KiB
Nim
## Default-parity + registration guard for the LEADGAIN gun (id 16).
|
|
##
|
|
## No Java, no battle, no network build. Covers:
|
|
## * the rack table carries LEADGAIN at id 16 and it defaults to `off`;
|
|
## * the shipped rack still admits exactly Pattern;
|
|
## * TR_RACK_LEADGAIN=both is what admits it, and the spawn gate honours it;
|
|
## (the LEGACY TR_RACK_BITBRAIN alias is pinned by
|
|
## `test_lead_gain_legacy.nim`);
|
|
## * `initLeadGainGun()` is LAZY (no learner) and does NOT touch the global
|
|
## RNG, so the default path cannot perturb the selector's random draws;
|
|
## * the mode parser defaults to `perRound`.
|
|
##
|
|
## Run: nim c -r common_libs/tests/test_lead_gain_registration.nim
|
|
|
|
import std/[random, os, math]
|
|
import gun_harness/virtual_bullets
|
|
import gun_harness/selector
|
|
import guns/lead_gain
|
|
|
|
const LeadGainId = 16
|
|
const PatternId = 5
|
|
|
|
var failures = 0
|
|
proc check(name: string, ok: bool) =
|
|
if ok: echo "PASS: ", name
|
|
else: echo "FAIL: ", name; inc failures
|
|
|
|
proc clearRackEnv() =
|
|
for name in RackGunNames: delEnv("TR_RACK_" & name)
|
|
|
|
proc testTable() =
|
|
check "rack: LEADGAIN is registered at id 16", RackGunNames[LeadGainId] == "LEADGAIN"
|
|
check "rack: LEADGAIN defaults to `off`", DefaultRackMembership[LeadGainId] == rmOff
|
|
var onlyPattern = true
|
|
for i in 0..<RackGunNames.len:
|
|
let want = if i == PatternId: rmBoth else: rmOff
|
|
if DefaultRackMembership[i] != want: onlyPattern = false
|
|
check "rack: the shipped default is still the onlyPattern rack", onlyPattern
|
|
check "rack: the default rack admits only Pattern (1v1)",
|
|
admittedGuns(NumRackGuns, rm1v1, DefaultRackMembership) == @[PatternId]
|
|
check "gate: LEADGAIN is NOT spawned under the default rack",
|
|
not vBulletAdmitted(LeadGainId, rm1v1, DefaultRackMembership, true)
|
|
|
|
proc testEnvOverride() =
|
|
clearRackEnv()
|
|
putEnv("TR_RACK_LEADGAIN", "both")
|
|
let m = loadRackMembership()
|
|
check "env: TR_RACK_LEADGAIN=both admits LEADGAIN",
|
|
m[LeadGainId] == rmBoth and
|
|
vBulletAdmitted(LeadGainId, rm1v1, m, true)
|
|
check "env: admitting LEADGAIN leaves Pattern as the only other member",
|
|
admittedGuns(NumRackGuns, rm1v1, m) == @[PatternId, LeadGainId]
|
|
clearRackEnv()
|
|
|
|
proc testLazyAndRngClean() =
|
|
delEnv("TR_LEADGAIN_MEM"); delEnv("TR_BITBRAIN_MEM")
|
|
var g = initLeadGainGun()
|
|
check "lazy: constructing the gun does NOT build the learner (0 bytes)",
|
|
g.networkBytes == 0
|
|
check "default: unset TR_LEADGAIN_MEM is perRound",
|
|
g.memMode == lgPerRound
|
|
check "parse: retained/decay/unknown",
|
|
parseLgMemMode("retained") == lgRetained and
|
|
parseLgMemMode("decay") == lgDecay and
|
|
parseLgMemMode("banana") == lgPerRound
|
|
# Global RNG parity: constructing the gun must not consume global randomness.
|
|
randomize(1234)
|
|
let a = rand(1_000_000)
|
|
randomize(1234)
|
|
var g2 = initLeadGainGun()
|
|
discard g2
|
|
let b = rand(1_000_000)
|
|
check "parity: initLeadGainGun() does not perturb the global RNG", a == b
|
|
|
|
proc testGeometry() =
|
|
check "geometry: class 0 centre is the low edge + half a bin",
|
|
abs(lgCenterDeg(0, 32, 40.0) - (-40.0 + 0.5 * 80.0 / 32.0)) < 1e-9
|
|
check "geometry: lgClassOf round-trips the centre",
|
|
lgClassOf(degToRad(lgCenterDeg(17, 32, 40.0)), 32, 40.0) == 17
|
|
|
|
testTable()
|
|
testEnvOverride()
|
|
testLazyAndRngClean()
|
|
testGeometry()
|
|
|
|
if failures > 0:
|
|
echo "\n", failures, " check(s) FAILED"
|
|
quit(1)
|
|
echo "\nAll LEADGAIN registration checks passed."
|