Bots: env reporting, TFIL movement, gun selector and docs refresh
DevControlBot DevControlBot.sh env-file handling and defines, tfil.nim
survival-movement rework, README
ModularBot .env.example, ModularBot.nim, env_report.nim, vbullet_draw.nim
PPO_Bot enemy_tracker.nim
common_libs gun_harness/selector.nim
tests env_report, lead_gain_legacy, rack_membership,
rack_stat_width, tm_pattern_registration adjustments
docs env_reference.md, goto-controller-algorithm.md
This commit is contained in:
@@ -22,6 +22,10 @@ import virtual_bullets
|
||||
# TR_RACK_KNN=off -> removed from both racks
|
||||
# TR_RACK_TMPATTERN=off (shipped default for the new TM pattern gun)
|
||||
# TR_RACK_LEADGAIN=both -> the per-range-band lead-gain corrector (id 16)
|
||||
# TR_RACK_KNOWLEDGE=both -> the learned residual gun (id 17); it is a
|
||||
# persistence-carrying gun, so the shipped default
|
||||
# is `off` and it only ever touches disk when a
|
||||
# caller admits it
|
||||
#
|
||||
# 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
|
||||
@@ -45,10 +49,11 @@ import virtual_bullets
|
||||
# transition the radar uses.
|
||||
|
||||
const
|
||||
RackGunNames*: array[17, string] = [
|
||||
RackGunNames*: array[19, string] = [
|
||||
"HEADON", "LINEAR", "TSETLIN", "CIRCULAR", "GUESSFACTOR", "PATTERN",
|
||||
"WALLBOUNCE", "ACCEL", "STOPSHOT", "DISPLACE", "AVGLEAD", "DECAYGF",
|
||||
"KNN", "TMSELECT", "TMPATTERN", "TMHORIZON", "LEADGAIN"]
|
||||
"KNN", "TMSELECT", "TMPATTERN", "TMHORIZON", "LEADGAIN", "KNOWLEDGE",
|
||||
"WAVEELM"]
|
||||
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
|
||||
@@ -74,7 +79,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[17, RackMembership] = [
|
||||
DefaultRackMembership*: array[19, RackMembership] = [
|
||||
rmOff, # 0 HEADON — off (measured: worst over-selected gun)
|
||||
rmOff, # 1 LINEAR — off
|
||||
rmOff, # 2 TSETLIN — off
|
||||
@@ -91,7 +96,12 @@ const
|
||||
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] # 16 LEADGAIN — off (per-range-band lead-gain corrector)
|
||||
rmOff, # 16 LEADGAIN — off (per-range-band lead-gain corrector)
|
||||
rmOff, # 17 KNOWLEDGE — off (learned additive angular residual on top of
|
||||
# the self-consistent lead forecast; see
|
||||
# `guns/gun_knowledge.nim`)
|
||||
rmOff] # 18 WAVEELM — off (online-ELM learned offset on the analytic
|
||||
# intercept; see `guns/waveelm.nim`)
|
||||
## NOTE: the table is registered in the SAME commit as the gun id and the live
|
||||
## wiring, so `TR_RACK_LEADGAIN=both` (or the legacy `TR_RACK_BITBRAIN=both`)
|
||||
## are the ONLY things that admit that gun, and an unset environment is
|
||||
|
||||
@@ -73,7 +73,7 @@ proc testKnownNames() =
|
||||
check "known set has no duplicates", known.len == s.len
|
||||
check "known set only holds TR_*/GUN_* names",
|
||||
known.allIt(it.startsWith("TR_") or it.startsWith("GUN_"))
|
||||
check "known set covers all 17 rack names",
|
||||
check "known set covers every rack name (width derived, not a literal)",
|
||||
RackGunNames.allIt((RackEnvPrefix & it) in s)
|
||||
for name in ["TR_MOVEMENT", "TR_POWER_ENERGY_MIN", "TR_TMHORIZON_NSTATES",
|
||||
"GUN_VBULLET_METRIC", "TR_ENV_REPORT", "GUN_SELECTOR_SEED",
|
||||
|
||||
@@ -164,8 +164,8 @@ proc testDefaultParity() =
|
||||
let want = if i == 5: rmBoth else: rmOff
|
||||
if m[i] != want: onlyPattern = false
|
||||
check "parity: a clean env still loads the shipped onlyPattern rack", onlyPattern
|
||||
check "parity: the rack is still 17 guns at id 16 = LEADGAIN",
|
||||
RackGunNames.len == 17 and RackGunNames[LeadGainId] == "LEADGAIN"
|
||||
check "parity: the rack is still one entry per gun and id 16 = LEADGAIN",
|
||||
RackGunNames.len == NumRackGuns and RackGunNames[LeadGainId] == "LEADGAIN"
|
||||
var g = initLeadGainGun()
|
||||
check "parity: a clean env resolves the shipped candidate set",
|
||||
g.cands == @[0.0, 0.25, 0.5, 0.75, 1.0] and g.memMode == lgPerRound
|
||||
|
||||
@@ -158,14 +158,14 @@ proc testDefaultsOnlyPattern() =
|
||||
DefaultRackMembership[12] == rmOff and DefaultRackMembership[13] == rmOff and
|
||||
DefaultRackMembership[14] == rmOff
|
||||
check "defaults: the default rack admits ONLY Pattern in 1v1",
|
||||
admittedGuns(17, rm1v1, DefaultRackMembership) == @[PatternId]
|
||||
admittedGuns(NumRackGuns, rm1v1, DefaultRackMembership) == @[PatternId]
|
||||
check "defaults: the default rack admits ONLY Pattern in melee",
|
||||
admittedGuns(17, rmMelee, DefaultRackMembership) == @[PatternId]
|
||||
admittedGuns(NumRackGuns, rmMelee, DefaultRackMembership) == @[PatternId]
|
||||
let loaded = loadRackMembership()
|
||||
check "defaults: with a clean environment loadRackMembership() == shipped table",
|
||||
loaded == DefaultRackMembership
|
||||
check "defaults: RackGunNames covers the shipped 17-gun rack",
|
||||
RackGunNames.len == 17 and DefaultRackMembership.len == 17
|
||||
check "defaults: RackGunNames covers the shipped rack (width derived, not a literal)",
|
||||
RackGunNames.len == NumRackGuns and DefaultRackMembership.len == NumRackGuns
|
||||
|
||||
proc testFloorRespectsAdmission() =
|
||||
## The FLOOR path (`bestRate <= 0` or below the floor rate) historically fell
|
||||
@@ -213,14 +213,15 @@ proc testRevertOverrideRestoresFullRack() =
|
||||
if m[i] != want: full = false
|
||||
check "revert: the documented one-liner restores the all-`both` full rack", full
|
||||
check "revert: 1v1 rack admits every gun again (TMPATTERN excluded)",
|
||||
admittedGuns(17, rm1v1, m) == @[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 15, 16]
|
||||
admittedGuns(NumRackGuns, rm1v1, m) ==
|
||||
@[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 15, 16, 17, 18]
|
||||
clearRackEnv()
|
||||
# The ADE+SBC gun (old rack id 17) is RETIRED, so `TR_RACK_BITBRAIN` is now
|
||||
# unambiguously LEADGAIN's old name: alone, it admits LEADGAIN and nothing else.
|
||||
putEnv("TR_RACK_BITBRAIN", "both")
|
||||
let mLegacy = loadRackMembership()
|
||||
check "revert: the legacy TR_RACK_BITBRAIN alone selects LEADGAIN (16) only",
|
||||
mLegacy[16] == rmBoth and admittedGuns(17, rm1v1, mLegacy) == @[5, 16]
|
||||
mLegacy[16] == rmBoth and admittedGuns(NumRackGuns, rm1v1, mLegacy) == @[5, 16]
|
||||
clearRackEnv()
|
||||
|
||||
proc testEnvOverrides() =
|
||||
|
||||
@@ -14,8 +14,9 @@
|
||||
## The fix derives every gun-indexed width from `NumRackGuns` (== `len(RackGunNames)`).
|
||||
## This test is the guard that would have caught it:
|
||||
##
|
||||
## A. rack table — `NumRackGuns` is 17, 17 DISTINCT names, and the
|
||||
## membership table and the legacy alias target are in range;
|
||||
## A. rack table — `NumRackGuns` is one entry per gun, DISTINCT names, and
|
||||
## the membership table and the legacy alias target are in
|
||||
## range;
|
||||
## B. source shape — `ModularBot.nim` contains NO literal width/loop bound
|
||||
## narrower than `NumRackGuns` for the gun-indexed
|
||||
## accounting, and sizes them with `NumRackGuns`;
|
||||
@@ -26,10 +27,12 @@
|
||||
## D. live (opt-in) — with a rack that admits ONLY the newest id, the bot
|
||||
## selects it, fires and lands hits (skipped without JARs).
|
||||
##
|
||||
## The ADE+SBC gun (rack id 17) was later RETIRED, so the rack is back to 17 and
|
||||
## the newest id is LEADGAIN (16). The guard is unchanged in shape and in
|
||||
## strength: C3 now proves the fix survives a rack that grows again, which is
|
||||
## the general form of the bug that shipped.
|
||||
## The ADE+SBC gun (rack id 17) was later RETIRED, so the rack went back to 17
|
||||
## with LEADGAIN (16) as the newest id. KNOWLEDGE now occupies id 17 again, so
|
||||
## the newest id is asserted as a DERIVED value (`NumRackGuns - 1`), never a
|
||||
## literal: the guard is unchanged in shape and in strength, and C3 still proves
|
||||
## the fix survives a rack that grows again, which is the general form of the bug
|
||||
## that shipped.
|
||||
##
|
||||
## Run: nim c -r common_libs/tests/test_rack_stat_width.nim
|
||||
## Live: TR_SERVER_JAR=... TR_BATTLE_RUNNER=... nim c -r common_libs/tests/test_rack_stat_width.nim
|
||||
@@ -47,7 +50,7 @@ const
|
||||
adversaryDir = repoRoot / "common_libs" / "test_framework" / "adversaries" / "SittingDuck"
|
||||
statsPath = "/tmp/rack_stat_width_stats.jsonl"
|
||||
PatternId = 5
|
||||
NewestId = NumRackGuns - 1 ## 16 (LEADGAIN), the newest rack id
|
||||
NewestId = NumRackGuns - 1 ## the newest rack id (KNOWLEDGE)
|
||||
LegacyLeadGainId = 16
|
||||
|
||||
var failures = 0
|
||||
@@ -59,7 +62,7 @@ proc check(name: string, ok: bool) =
|
||||
|
||||
proc testRackTable() =
|
||||
check "A1: NumRackGuns is derived from RackGunNames",
|
||||
NumRackGuns == RackGunNames.len and NumRackGuns == 17
|
||||
NumRackGuns == RackGunNames.len and NumRackGuns > 0
|
||||
check "A2: rack membership table has one entry per gun",
|
||||
DefaultRackMembership.len == NumRackGuns
|
||||
var seen = initTable[string, bool]()
|
||||
@@ -176,9 +179,9 @@ proc testAccounting() =
|
||||
check "C3: a rack one gun WIDER is still fully covered by the NumRackGuns width",
|
||||
grownOk and grown[NumRackGuns] == 1
|
||||
|
||||
# The legacy namespace: TR_RACK_BITBRAIN is now unambiguously LEADGAIN's old
|
||||
# The legacy namespace: TR_RACK_BITBRAIN is unambiguously LEADGAIN's old
|
||||
# name (the ADE+SBC gun that briefly owned it was retired), so it always
|
||||
# admits LEADGAIN (16) — the newest id — and nothing else.
|
||||
# admits LEADGAIN (16) — and nothing else, not the gun that reused id 17.
|
||||
for n in RackGunNames: delEnv("TR_RACK_" & n)
|
||||
delEnv("TR_BITBRAIN_NET")
|
||||
putEnv("TR_RACK_BITBRAIN", "both")
|
||||
|
||||
@@ -62,7 +62,8 @@ proc seedOldRack(t: var VirtualTracker, targetId: int) =
|
||||
# ── registration table ────────────────────────────────────────────────────────
|
||||
|
||||
proc testTable() =
|
||||
check "rack: RackGunNames has 17 entries", RackGunNames.len == 17
|
||||
check "rack: RackGunNames has one entry per rack gun (width derived)",
|
||||
RackGunNames.len == NumRackGuns
|
||||
check "rack: the new gun is named TMPATTERN at id 14",
|
||||
RackGunNames[TmPatternId] == "TMPATTERN"
|
||||
check "rack: the new gun defaults to `off`",
|
||||
|
||||
Reference in New Issue
Block a user