Screen tree, register rows in the master list, and bot runs coded from the picks that were played
CI / test (pull_request) Canceled after 0s

- analysis/tree/build_tree.py -> data/public/tree.json, analysis/reports/TREE.md: every screen the bot has seen,
  every option, where each led (fixed or dice, with ranges), best known picks per colour chosen cautiously, where
  any picks end, and the untested options. solver.js screenPick(): least-tried and Thompson picks from the tree.
- The bot logs a pick it then overrode as a step: 37 runs were coded with choices they never made. Importer and
  graph.js now use the played steps only.
- runs_clean.csv: the Unofficial Dragon Register's 288 bonded dragons are in the master list as outcome-only
  rows, flagged (no analysis uses them).
- Cycle, refresh and the bot kit rebuild and carry the tree; tests check every generated report is current.

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-16 15:50:12 +00:00
co-authored by Claude Fable 5.2
parent d01ec46fcc
commit f8e4f575f4
25 changed files with 3613 additions and 163 deletions
+13 -3
View File
@@ -126,9 +126,19 @@
// END CROSSWALK
/** Map one bot trajectory onto the form's decision variables. Unmapped choices are listed, not guessed. */
/**
* The steps that were actually played. The bot logs a pick it then overrode (its own rules against the atlas's
* advice) as a step whose `to` is not where the run went, followed by the pick it made on the same screen. Those
* superseded picks are dropped. A step without `to` (a run in progress) is kept unless the next step is on the
* same screen.
*/
function playedSteps(steps) {
return (steps || []).filter((s, i) => !(i + 1 < steps.length && steps[i + 1].scene != null && steps[i + 1].scene === s.scene && s.to !== steps[i + 1].scene));
}
function trajectoryVariables(traj) {
const vars = {}, unmapped = [];
for (const s of traj.steps) {
for (const s of playedSteps(traj.steps)) {
const t = norm(s.optionText);
const hit = CROSSWALK.find(([re]) => re.test(t));
if (hit) { if (!(hit[1] in vars)) vars[hit[1]] = hit[2]; }
@@ -208,7 +218,7 @@
for (const o of s.options) g[id].options[o.id] = { id: o.id, text: o.text, n: 0, to: {}, bySource: {}, intentionalBurns: 0 };
}
for (const t of trajs) {
for (const s of t.steps) {
for (const s of playedSteps(t.steps)) {
const node = g[s.scene] || (g[s.scene] = { id: s.scene, stage: s.stage, tint: s.tint, label: s.stage, visits: 0, options: {} });
node.visits++;
const o = node.options[s.option] || (node.options[s.option] = { id: s.option, text: s.optionText, n: 0, to: {}, bySource: {}, intentionalBurns: 0 });
@@ -231,5 +241,5 @@
return g;
}
return { betaPosterior, betaQuantile, ibeta, CROSSWALK, trajectoryVariables, formRunVariables, VAR_STAGES, buildVariableGraph, buildSceneGraph, norm };
return { betaPosterior, betaQuantile, ibeta, CROSSWALK, trajectoryVariables, playedSteps, formRunVariables, VAR_STAGES, buildVariableGraph, buildSceneGraph, norm };
});
+35 -2
View File
@@ -13,7 +13,8 @@
* solverHistory(formVars, seen), makeParams(tables, { alphas, game }), ENCOUNTERS (set from the first sample).
* Since November 2026: advisor options `attempt` (the account's attempt number: a first attempt has its own
* shadow odds), `fix` (hold some decisions to given options: an experiment arm) and sampling "uniform" (mapping);
* assign(plan, { accountSeq, attempt }) reads the experiment plan (experiments.json) and says what an attempt is for.
* assign(plan, { accountSeq, attempt }) reads the experiment plan (experiments.json) and says what an attempt is for;
* screenPick(tree, sceneId, offered, { mode }) picks from the screen tree (tree.json): least-tried, or Thompson.
* UMD: window.ThreshSolver in the browser, module.exports in Node. No dependencies.
*/
(function (root, factory) {
@@ -413,8 +414,40 @@
propensity: (exp.share / total) / exp.arms.length, burn: exp.burn || null, planId: plan.id };
}
/* ---------- picks made from the screen tree (analysis/tree/build_tree.py, published as tree.json) ---------- */
/**
* Which option to pick on a screen, from what the tree knows about that screen:
* screenPick(tree, sceneId, offered, { mode, seed }) -> { index, text, n, mode, reason } (null: nothing offered)
* sceneId is the bot's own id for the screen; offered the option texts on it. An option the tree has never seen
* counts as never played.
* mode "least-tried": the option played least so far (mapping: fills the tree's gaps first).
* mode "thompson": for each option, draw a survival rate from what has been seen (survived + 1, died + 1) and
* take the highest: untested options get tried, deadly ones fade out. It looks one step
* ahead only, so use it where dying is the risk (a bonding encounter).
* Ties and draws use `seed` (give a new one per attempt and screen).
*/
function screenPick(tree, sceneId, offered, { mode = "least-tried", seed = 1 } = {}) {
if (!offered || !offered.length) return null;
const sc = ((tree || {}).screens || {})[sceneId], rand = rng(hash(`${seed}|${sceneId}|${mode}`));
const known = sc ? Object.values(sc.options) : [];
const rows = offered.map((text, index) => {
const o = known.find((k) => norm(k.text) === norm(text)) || { n: 0, to: {} };
const died = (o.to.DIED || { n: 0 }).n;
return { index, text, n: o.n, survived: o.n - died, died, tie: rand() };
});
let pick;
if (mode === "thompson") {
for (const r of rows) { const a = gamma(r.survived + 1, rand), b = gamma(r.died + 1, rand); r.draw = a / (a + b); }
pick = rows.reduce((x, y) => (y.draw > x.draw ? y : x));
} else {
pick = rows.reduce((x, y) => (y.n < x.n || (y.n === x.n && y.tie < x.tie) ? y : x));
}
return { index: pick.index, text: pick.text, n: pick.n, mode,
reason: mode === "thompson" ? `survived ${pick.survived} of ${pick.n} so far` : `played ${pick.n} times, the fewest on this screen` };
}
return Object.assign(api, {
advisor, recommendOption, solverHistory, norm, assign, armFor, givenFor,
advisor, recommendOption, solverHistory, norm, assign, armFor, givenFor, screenPick,
makeParams: (T, { alphas, game } = {}) => makeParams(T, { alphas, game: game || api.game }),
/** remember the game of a policy sample (sets ENCOUNTERS) without solving anything */
useGame(sample) { api.game = sample.model.game; api.ENCOUNTERS = api.game.by_colour; return api.game; },