j130 learned movement: outcome label (P(hit|state,g)) mode + Gate A; pre-registered outcome arms

This commit is contained in:
2026-09-26 11:27:03 +02:00
parent 4c934a67c1
commit 61def1c3e9
6 changed files with 695 additions and 24 deletions
+1 -1
View File
@@ -511,7 +511,7 @@ proc knownEnvNames*(): seq[string] =
LearnedDecayEveryEnv, LearnedDecayShiftEnv, LearnedAlphaEnv,
LearnedTravelEnv, LearnedReversalEnv, LearnedPrefDistEnv,
LearnedDistBandEnv, LearnedRadialFracEnv, LearnedWallMarginEnv,
LearnedGlobalEnv, LearnedLogEnv,
LearnedGlobalEnv, LearnedLabelEnv, LearnedLogEnv,
# harness vars (read by the test framework, inherited by the bot, so they
# must NOT be reported as typos)
"TR_SERVER_JAR", "TR_BATTLE_RUNNER", "TR_BATTLE_RUNNER_DIR",
@@ -76,6 +76,12 @@ proc run(ticks: int, decayShift: int): LearnedSurferModule =
for _ in 0..<ticks:
discard result.step(s)
proc runOutcome(ticks: int, decayShift: int): LearnedSurferModule =
putEnv(LearnedLabelEnv, "outcome")
result = run(ticks, decayShift)
putEnv(LearnedLabelEnv, "")
loadLearnedEnv()
proc counters(m: LearnedSurferModule): int =
var n = 0
for c in m.sbc.counters:
@@ -135,6 +141,31 @@ proc main() =
let g = run(ticks = 200, decayShift = 1)
check "TR_LEARNED_GLOBAL still moves (prior-only map)", g.decisions > 20
delEnv(LearnedGlobalEnv)
# 8. outcome label: the 2-class counted SBC learns and reads a probability
putEnv(LearnedGlobalEnv, "")
let o = runOutcome(ticks = 600, decayShift = 1)
check "TR_LEARNED_LABEL=outcome still moves", o.decisions > 100
check "outcome memory accumulated",
(block:
var n = 0
for c in o.outcome.counters:
if c != 0'u8: inc n
n > 0)
check "outcome hit prior is a probability in [0,1]",
(block:
let p = o.predictHit(0, 0, 10)
p >= 0.0 and p <= 1.0)
let o2 = runOutcome(ticks = 300, decayShift = 1)
let o3 = runOutcome(ticks = 300, decayShift = 1)
check "outcome mode deterministic",
(block:
var n2, n3 = 0
for c in o2.outcome.counters:
if c != 0'u8: inc n2
for c in o3.outcome.counters:
if c != 0'u8: inc n3
n2 == n3)
putEnv(LearnedDecayShiftEnv, "")
putEnv(LearnedDecayEveryEnv, "")
loadLearnedEnv()