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
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:
co-authored by
Claude Fable 5.2
parent
d01ec46fcc
commit
f8e4f575f4
+43
-2
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user