Route model: first attempts are their own shadow roll; experiment plan and automated bot cycle

- game.yaml: `givens` (first or later attempt) and `distinct` levels that are not pooled; the shadow roll
  depends on the attempt first. Form submissions show the shadow on 9% of first attempts and 0.3% of later ones.
- Reporting bias: a roll whose bias cannot be measured can borrow another roll's (`borrow: {shadow: meadow}`),
  so form submissions inform the shadow again. An assumption, stated in planner/policy.yaml.
- policy.json: targets.<colour>.firstAttempt (this attempt, eventually). Black: about 1.4% on a first attempt,
  0.07% on a later one.
- solver.js: advisor options `attempt`, `fix`, sampling "uniform"; assign() and armFor() for the plan.
- planner/experiments.yaml + build_experiments.py -> data/public/experiments.json (progress and status per
  experiment, rebuilt from the bot's runs).
- python -m collection cycle: import bot runs, refit, re-plan, deliver the kit; .gitea/workflows/bot-cycle.yml.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014jqCC2LZ4x1WHQ1V57nTsv
This commit is contained in:
ekcSchiano
2026-11-12 03:31:33 +00:00
co-authored by Claude Fable 5.2
parent ee07ee143e
commit ab3664f369
25 changed files with 1938 additions and 573 deletions
+41 -1
View File
@@ -250,13 +250,30 @@ def draw_worlds(T, seeds, alphas, support):
"""Posterior draws, one world per seed, each drawn in its own walk of the game (see Params)."""
p = model.Params(T, "draw", seeds=seeds, alphas=alphas)
p.reached = {}
default = dict(p.given)
for d in range(p.D):
p.world = d
_Drawer(p, support, d, p.reached).root()
# the same world for runs with other givens (a first attempt): only the rolls that depend on them are new
for given in other_givens():
p.given = {**default, **given}
_Drawer(p, support, d, {}).root()
p.given = default
p.world = None
return p
def other_givens():
"""Every non-default value of every given in game.yaml, one at a time: [{"attempt": "First attempt"}]."""
return [{k: v} for k, g in model.GIVENS.items() for v in g["values"] if v != g["default"]]
def given_key(given):
"""The name a non-default given's results are published under: {"attempt": "First attempt"} -> "firstAttempt"."""
words = " ".join(given.values()).split()
return words[0].lower() + "".join(w.capitalize() for w in words[1:])
# ---------------------------------------------------------------- objectives
def solve(params, X, support, lam=0.0, record=False, only=None):
@@ -364,6 +381,28 @@ def build_policy(runs, draws=200, seed=20261101, min_support=None, alpha=None, c
"crossFit": {"inSample": (cross[0]["inSample"] + cross[1]["inSample"]) / 2,
"heldOut": (cross[0]["heldOut"] + cross[1]["heldOut"]) / 2},
}
# Runs with another given (a first attempt). "This attempt" is solved as above. "Eventually": every attempt
# after it is an ordinary one, worth the default's ratio (lam), so the best play maximises
# P(X now) + P(no bond now) * lam, which is the same score with lam fixed.
later = [xi / (xi + oi) if xi + oi else 0.0 for xi, oi in zip(ev_ratio[0], ev_ratio[1])]
for given in other_givens():
m1, d1 = mean.having(**given), drawp.having(**given)
g_one = solve(m1, X, support, record=True)
g_ev = solve(m1, X, support, lam=ratio.lam, record=True)
e_one = evaluate(d1, X, support, g_one.decide)
e_ev = evaluate(d1, X, support, g_ev.decide)
def gblock(sol, ev, dr, m1=m1):
x, o = ev[0], ev[1]
return {"pX": {**summarise(x), "point": float(sol.value[0][0])},
"pOther": {**summarise(o), "point": float(sol.value[1][0])},
"tree": Exporter(m1, X, support, sol, dr).root()}
ev_block = gblock(g_ev, e_ev, solve(d1, X, support, lam=d_ratio.lam))
x0, o0 = float(g_ev.value[0][0]), float(g_ev.value[1][0])
ev_block["pEventually"] = {**summarise([x + (1 - x - o) * r for x, o, r in zip(e_ev[0], e_ev[1], later)]),
"point": x0 + (1 - x0 - o0) * float(np.ravel(ratio.lam)[0])}
targets[X][given_key(given)] = {"given": given, "thisAttempt": gblock(g_one, e_one, solve(d1, X, support)),
"eventually": ev_block}
return {
"schema": 1,
"model": {
@@ -371,12 +410,13 @@ def build_policy(runs, draws=200, seed=20261101, min_support=None, alpha=None, c
"alphas": alphas, "alphaFit": {k: f["logLik"] for k, f in fitted.items()}, "draws": draws, "seed": seed,
"minSupport": min_support,
"chanceContext": {k: s["context"] for k, s in model.CHANCE.items()},
"given": model.DEFAULT_GIVEN,
"decisions": model.DECISIONS, "support": support, "supportCounts": counts,
"tables": T,
# how much each kind of source over-reports each rare roll, and the correction applied (bias.py)
"reportingBias": bias_est,
# the game itself (core/spec/game.yaml), so the advisor in core/solver.js can re-solve from any point
"game": {k: G[k] for k in ("version", "colours", "decisions", "chance", "encounters", "encounter_outcomes",
"game": {k: G[k] for k in ("version", "colours", "givens", "decisions", "chance", "encounters", "encounter_outcomes",
"by_colour", "start", "steps", "from_form", "bot_text")},
},
"data": {"runs": len(runs)},