ChimeraBot_garage: M5.5 — unified metrics, cross-round posterior carry, probe set v2, G5' v2

This commit is contained in:
2026-10-07 02:27:11 +02:00
parent f9f3cd7576
commit 6dd0b1c3cb
12 changed files with 815 additions and 452 deletions
@@ -58,6 +58,10 @@ type
f: File
fileOpen: bool
# Cross-round posterior carry-over (M5.5; default on, `-d:chimeraFreshRound`
# restores the per-round reset).
carryOver*: bool
## predictions: `predPos[(origin mod PredSlots)][h]` is the enemy position
## predicted `h` ticks after `origin`; `predOrigin` guards a slot's owner.
predPos: array[PredSlots, array[MaxHorizon + 1, tuple[x, y: float64]]]
@@ -79,12 +83,12 @@ proc initObserver*(kernels: seq[Kernel], telemetryDir = ""): Observer =
result.telemetryDir = telemetryDir
result.scanTick = -1
result.enemyHeat = 3.0
result.carryOver = not defined(chimeraFreshRound)
for i in 0 ..< PredSlots: result.predOrigin[i] = -1
proc resetRound(o: Observer) =
o.hedge = initHedge(kernelNames(o.kernels), o.cfg)
for i in 0 ..< o.kernels.len:
o.mems[i] = defaultMemory(o.kernels[i].defaultParams)
proc resetRoundStats(o: Observer) =
## Per-round observables and counters, with NO touch to the posterior or the
## kernel memories. Cleared on every round start (carry-over keeps the latter).
o.havePrev = false
o.haveCur = false
o.haveLastObs = false
@@ -98,6 +102,13 @@ proc resetRound(o: Observer) =
o.enemyHeat = 3.0 ## round-start heat (spec §5)
for i in 0 ..< PredSlots: o.predOrigin[i] = -1
proc resetRound(o: Observer) =
## Fresh-round ablation: uniform posterior + default kernel memories.
o.hedge = initHedge(kernelNames(o.kernels), o.cfg)
for i in 0 ..< o.kernels.len:
o.mems[i] = defaultMemory(o.kernels[i].defaultParams)
o.resetRoundStats()
proc sanitize*(s: string): string =
## Filename-safe opponent token: collapse runs of non-alphanumerics to `_`.
var prevSep = false
@@ -120,9 +131,18 @@ proc openTelemetry(o: Observer) =
o.fileOpen = true
proc startRound*(o: Observer, round: int) =
## Called on `RoundStartedEvent`. Re-initialises the posterior UNIFORM, as
## the spec requires per round (Corners re-samples its start corner each round).
o.resetRound()
## Called on `RoundStartedEvent`. With carry-over (default, M5.5) the posterior
## and kernel memories survive: the enemy is the same program across rounds, so
## identification compounds. Only RNG-derived memory is re-sampled (a per-round
## parameter such as Corners' start corner must not carry). With
## `-d:chimeraFreshRound` (`carryOver == false`) the posterior resets UNIFORM,
## which is the M3/M4 behaviour and the G6 carry-over ablation arm.
if o.carryOver:
o.resetRoundStats()
for i in 0 ..< o.kernels.len:
o.mems[i].rngState = o.kernels[i].defaultParams.seed
else:
o.resetRound()
o.round = round # `opponent` is retained: it is per-BATTLE, not per-round
# ── ledger folding (observer-local fire rule) ───────────────────────────────