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
+7 -3
View File
@@ -23,6 +23,7 @@ from pathlib import Path
from .common import ROOT, path
KIT = {"policy.json": "data/public/policy.json", "experiments.json": "data/public/experiments.json",
"tree.json": "data/public/tree.json",
"solver.js": "core/solver.js", "graph.js": "core/graph.js"}
README = """Threshing Atlas files for the DragonKind bot
@@ -31,12 +32,13 @@ README = """Threshing Atlas files for the DragonKind bot
Policy id: {policy}
Made: {made}
Unzip these four files into the bot's vendor/threshing-atlas/ folder, replacing the old ones, and keep them
Unzip these five files into the bot's vendor/threshing-atlas/ folder, replacing the old ones, and keep them
together: solver.js reads the game from this policy.json.
policy.json the route model (the game, the counts behind every roll, the best routes per colour)
experiments.json the experiment plan: what each attempt of each account is for (read it with assign())
solver.js the advisor: advisor(), recommendOption(), solverHistory(), assign()
tree.json the screen tree: every screen, every option, where each led (read it with screenPick())
solver.js the advisor: advisor(), recommendOption(), solverHistory(), assign(), screenPick()
graph.js trajectoryVariables(): the bot's steps -> the community form's variables
How the bot uses them: docs/BOT_INTEGRATION.md in the atlas repo. Log the policy id above as policyId on each run,
@@ -86,6 +88,7 @@ def refresh(update_main, bots=()):
_step("route model (about 2 minutes)", [py, "planner/build_policy.py"])
_step("experiment plan", [py, "planner/build_experiments.py"])
_step("what the runs show about the Black", [py, "analysis/black/evidence.py"])
_step("screen tree", [py, "analysis/tree/build_tree.py"])
_step("statistics", [py, "analysis/stats/site_stats.py"])
_step("runs, generated files and metadata", [py, "-m", "collection", "build"])
print(f"\nDone. What changed: exports/last-report.md. Send the bot its files with: {py} -m collection export-bot-kit")
@@ -97,7 +100,7 @@ def refresh(update_main, bots=()):
def _fingerprint():
"""What the route model and the plan are built from: the coded runs and the bot's anonymised files."""
h = hashlib.sha256()
for p in [path("data/public/runs_clean.csv"), *sorted(path("data/bot").glob("*.json*")),
for p in [path("data/public/runs_clean.csv"), *sorted(path("data/bot").glob("*.json*")), path("planner/knowledge.yaml"),
path("planner/policy.yaml"), path("planner/experiments.yaml"), path("core/spec/game.yaml")]:
if p.exists():
h.update(p.name.encode())
@@ -171,6 +174,7 @@ def cycle(update_main, bots, deliver_to=None, community=False, force=False):
_step("route model (a few minutes)", [py, "planner/build_policy.py"])
_step("experiment plan", [py, "planner/build_experiments.py"])
_step("what the runs show about the Black", [py, "analysis/black/evidence.py"])
_step("screen tree", [py, "analysis/tree/build_tree.py"])
try:
import scipy # noqa: F401
_step("statistics", [py, "analysis/stats/site_stats.py"])
+43 -2
View File
@@ -76,6 +76,38 @@ def reddit_results(name, spec):
return rows
def register(name, spec):
"""The Unofficial Dragon Register: one bonded dragon per row, with the rider's assignment, no route. A rider may
have logged the same run in the community form, so every row is flagged; nothing can match the two."""
p = path(spec["load"])
data = json.loads(p.read_text(encoding="utf-8")) if p.exists() else {"headers": [], "rows": []}
def col(*words):
return next((h for h in data["headers"] if all(w in h.lower() for w in words)), None)
h = {k: col(*w) for k, w in {"when": ("timestamp",), "wing": ("wing",), "section": ("section",), "squad": ("squad",),
"colour": ("colour",), "tail": ("tail",)}.items()}
values = {c: DICT["columns"][c].get("values") or [] for c in ("wing", "section", "squad", "outcome_color", "tail")}
rows = []
for n, r in enumerate(data["rows"], 1):
get = lambda k: (str(r.get(h[k])).strip() if h[k] and r.get(h[k]) is not None else None) # noqa: E731
flags = ["outcome only (register): the same run may also be in the spreadsheet"]
colour = (get("colour") or "").title() or None
if colour not in values["outcome_color"]:
flags.append("colour not recognised")
colour = None
tail = (get("tail") or "").replace(" ", "").capitalize() or None
row = blank_row(run_id=f"register-{n}", source=spec["run_source"], date=(get("when") or "")[:10] or None,
outcome="Bonded", outcome_color=colour, tail=tail if tail in values["tail"] else None)
for c in ("wing", "section", "squad"):
if get(c) and (not values[c] or get(c) in values[c]): # section is free text in the dictionary
row[c] = get(c)
encounter_columns(row)
row["data_flags"] = "; ".join(flags)
rows.append(row)
return rows
def reports(name, spec):
"""Runs reported through the "Report a run" issue form (collection/specs/report_form.yaml)."""
form = report_form.spec()
@@ -137,7 +169,7 @@ def bot_trajectories(spec):
def bot_variables(traj, crosswalk):
"""A bot attempt -> columns, through the crosswalk in collection/specs/bot.yaml. First match wins."""
v, unmapped = {}, []
for s in traj["steps"]:
for s in played(traj["steps"]):
t = _norm(s["optionText"])
hit = next((c for c in crosswalk if c[0].search(t)), None)
if hit:
@@ -156,6 +188,14 @@ BURN_REASONS = { # why the bot chose to die, in words (the bot's own reason cod
}
def played(steps):
"""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: counting them codes a run with choices it never made."""
return [s for i, s in enumerate(steps)
if not (i + 1 < len(steps) and steps[i + 1]["scene"] == s["scene"] and s.get("to") != steps[i + 1]["scene"])]
def _seen_after(steps, start, key):
"""Values the bot saw (step["seen"][key]) from step index `start` on."""
out = []
@@ -170,6 +210,7 @@ def bot(name, spec):
cw = [(re.compile(rx), col, val) for rx, col, val in read_yaml(spec["transform"]["spec"])["crosswalk"]]
rows = []
for traj in bot_trajectories(spec):
traj = {**traj, "steps": played(traj["steps"])}
steps = traj["steps"]
v, _ = bot_variables(traj, cw)
red = v.pop("red", None)
@@ -221,7 +262,7 @@ def bot(name, spec):
return rows
CODERS = {"spreadsheet": spreadsheet, "reddit_results": reddit_results, "reports": reports, "bot": bot}
CODERS = {"spreadsheet": spreadsheet, "reddit_results": reddit_results, "reports": reports, "bot": bot, "register": register}
def build_runs(pipe):
+6 -2
View File
@@ -18,7 +18,7 @@ manifest: data/manifest.json # for each source: the sha256 of the current
runs:
path: data/public/runs_clean.csv
# sources in this order; within a source, the order the coder returns
order: [reddit_spreadsheet, reddit_thread, reported, bot, reddit_pdf]
order: [reddit_spreadsheet, reddit_thread, register, reported, bot, reddit_pdf]
sources:
reddit_spreadsheet:
@@ -35,12 +35,16 @@ sources:
register:
label: Unofficial Dragon Register (which dragon each rider bonded)
run_source: register
links: { sheet: https://docs.google.com/spreadsheets/d/1KMiE9sec0l597Pzue1OhGYf07NF4howtQ_lPeqx7jXQ }
extract: { kind: http, url: "https://docs.google.com/spreadsheets/d/1KMiE9sec0l597Pzue1OhGYf07NF4howtQ_lPeqx7jXQ/export?format=xlsx", ext: xlsx }
transform: { name: sheet, sheet_contains: form responses, extra: collection/manual/reddit_results.yaml }
privacy: { redact_emails: true, drop_columns_matching: [photo, cadet name] } # no rider names, no photos
load: data/public/register.json
runs: null # bonded dragons without the route that led there
# bonded dragons without the route that led there: in the master list as outcome-only runs, flagged, because
# a rider may have logged the same run in the community form (no analysis uses them: planner/policy.yaml and
# analysis/stats/measures.yaml name their sources)
runs: register
reddit_pdf:
label: Community route PDF (u/ClumsyBadger)