Core: fix three coding bugs from the core review, with rule tests (#11)
1. Letting the Red pass. Only climbing down quickly puts you above the Red, so a tree run that passed on the Red and then met the Greens let it pass. Those 16 runs were coded as slow descents; they are now "Descend quickly: let the Red pass" and count for the Greens' encounter, so the route model's "let it pass" option rests on its own runs. A tree run with both the Red and the Greens attempted (impossible in one run) is now flagged. 2. Leaving your squadmates. The form only offered "> Left them" from 2026-10-27 (0 of 504 squad runs before chose it, 40 of 144 after). Earlier and undated squad runs are now unknown rather than "stayed together" (form.yaml: left_squadmates_asked_from). 3. Bot text. The wounded cadet's other two choices map onto the form; a test checks every choice the bot has logged maps onto a form variable (encounter answers excepted, not modelled yet). Each rule has a test in tests/core/test_coding.py. Data rebuilt (runs, graph, policy, report); the headline odds move by at most 0.02 points. The Methods tab describes both rules. Claude-Session: https://claude.ai/code/session_01UCzTd31GphpMXDhQqWrCMQ Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
cc86343668
commit
963b08c522
@@ -147,6 +147,8 @@ def code_row(r, C):
|
||||
suffix = F["company_left_suffix"]
|
||||
left_squad = company_raw.endswith(suffix)
|
||||
company = company_raw[: -len(suffix)] if left_squad else company_raw
|
||||
if not left_squad and company in ("1 Squadmate", "2 Squadmates") and not (date and date >= F["left_squadmates_asked_from"]):
|
||||
left_squad = None # the form did not offer "left them" yet: unknown, not "stayed together"
|
||||
pools = F["sighting_pool"]
|
||||
pool = list(pools.get(company, {}).get(direction, [])) + (list(pools["Alone"].get(direction, [])) if left_squad else [])
|
||||
if first and first != "Unsure" and pool and first not in pool:
|
||||
@@ -198,8 +200,14 @@ def code_row(r, C):
|
||||
if hour == "Tree":
|
||||
if enc["Blue"] or enc["Black"] or rare == "Shadow":
|
||||
branch = "Shadow (rare)"
|
||||
elif enc["Red"] == ENC["passed"] and enc["Green"]:
|
||||
# only climbing down quickly puts you above the Red: passing on it and meeting the Greens means the
|
||||
# rider let it pass
|
||||
branch = "Descend quickly: let the Red pass"
|
||||
elif enc["Green"]:
|
||||
branch = "Descend slowly: two Greens"
|
||||
if enc["Red"]:
|
||||
flags.append("tree run with both the Red and the two Greens attempted")
|
||||
elif enc["Red"]:
|
||||
branch = "Descend quickly: Red"
|
||||
elif enc["Orange"] or enc["Brown"]:
|
||||
|
||||
+5
-7
@@ -63,7 +63,8 @@ def prepare_run(r):
|
||||
"direction": r["direction"] if r["direction"] in DECISIONS["direction"] else None,
|
||||
"fs": r["first_sighting"] if r["first_sighting"] in ("Red", "Brown", "Green", "Orange") else None}
|
||||
lf = r.get("left_squadmates")
|
||||
v["left"] = ALONE if v["company"] == "Alone" else (("Leave them" if lf is True or str(lf).lower() == "true" else "Stay together") if v["company"] else None)
|
||||
known = lf is not None and not (isinstance(lf, float) and lf != lf) and lf != ""
|
||||
v["left"] = ALONE if v["company"] == "Alone" else (("Leave them" if lf is True or str(lf).lower() == "true" else "Stay together") if v["company"] and known else None)
|
||||
v["react"] = r["sighting_action"] if r.get("sighting_action") in DECISIONS["react"] else None
|
||||
v["diedSight"] = r["scream"] == "DIED at first sighting"
|
||||
if v["diedSight"]:
|
||||
@@ -98,12 +99,9 @@ def prepare_run(r):
|
||||
v["shadowColour"] = "Black" if r.get("enc_Black") else "Blue"
|
||||
v["encCtx"] = "shadow-" + v["shadowColour"]
|
||||
elif b == "Descend quickly: Red":
|
||||
v["descend"] = "Quickly (Red)"
|
||||
# a rider who let the Red pass and met the Greens instead
|
||||
if r.get("enc_Red") == "Changed my mind" and r.get("enc_Green"):
|
||||
v["red"], v["encCtx"] = "Let it pass (two Greens)", "tree-Greens"
|
||||
else:
|
||||
v["red"], v["encCtx"] = "Jump onto the Red", "tree-Red"
|
||||
v["descend"], v["red"], v["encCtx"] = "Quickly (Red)", "Jump onto the Red", "tree-Red"
|
||||
elif b == "Descend quickly: let the Red pass":
|
||||
v["descend"], v["red"], v["encCtx"] = "Quickly (Red)", "Let it pass (two Greens)", "tree-Greens"
|
||||
elif b == "Descend slowly: two Greens":
|
||||
v["descend"], v["encCtx"] = "Slowly (two Greens)", "tree-Greens"
|
||||
elif v["hour"] == "Valley" and b:
|
||||
|
||||
+12
-4
@@ -239,6 +239,8 @@
|
||||
const companyRaw = g("company") || "Unknown";
|
||||
const leftSquad = / > Left them$/.test(companyRaw);
|
||||
const company = leftSquad ? companyRaw.replace(/ > Left them$/, "") : companyRaw;
|
||||
// "left them" was only offered from 2026-10-27 (core/spec/form.yaml): earlier and undated squad runs are unknown
|
||||
const leftKnown = leftSquad || !["1 Squadmate", "2 Squadmates"].includes(company) || (date && date >= "2026-10-27");
|
||||
// Leaving your squadmates sends you into the solo pools, so either pool is plausible.
|
||||
const pool = (SIGHTING_POOL[company + "|" + direction] || []).concat(leftSquad ? SIGHTING_POOL["Alone|" + direction] || [] : []);
|
||||
if (first && first !== "Unsure" && pool.length && !pool.includes(first))
|
||||
@@ -282,7 +284,11 @@
|
||||
let branch = null;
|
||||
if (hour === "Tree") {
|
||||
if (enc.Blue || enc.Black || rare === "Shadow") branch = "Shadow (rare)";
|
||||
else if (enc.Green) branch = "Descend slowly: two Greens";
|
||||
else if (enc.Red === "Changed my mind" && enc.Green) branch = "Descend quickly: let the Red pass";
|
||||
else if (enc.Green) {
|
||||
branch = "Descend slowly: two Greens";
|
||||
if (enc.Red) flags.push("tree run with both the Red and the two Greens attempted");
|
||||
}
|
||||
else if (enc.Red) branch = "Descend quickly: Red";
|
||||
else if (enc.Orange || enc.Brown) {
|
||||
branch = "Descend slowly: two Greens";
|
||||
@@ -321,7 +327,7 @@
|
||||
source, date, wing, section, squad: g("squad") || "Unknown", attempt,
|
||||
// "I've lost count" means many attempts, so it is a later attempt, not missing
|
||||
attempt_group: attempt === 1 ? "First attempt" : attempt > 1 || /lost count/i.test(g("attempt") || "") ? "Later attempt" : "Unknown",
|
||||
goal, company, left_squadmates: leftSquad, direction, first_sighting: first || "Unknown",
|
||||
goal, company, left_squadmates: leftKnown ? leftSquad : null, direction, first_sighting: first || "Unknown",
|
||||
sighting_action: "sighting_action" in C ? SIGHTING_ACTION[g("sighting_action")] || g("sighting_action") || "Unknown" : "(not asked)",
|
||||
scream, resolution, combat_first: combat || "(not recorded)", combat_second: combat2 || "(not recorded)",
|
||||
post_path: post, hour, branch,
|
||||
@@ -536,10 +542,12 @@
|
||||
const FACTORS = ["company", "direction", "first_sighting", "scream", "resolution", "combat_first",
|
||||
"post_path", "hour", "wing", "squad", "attempt_group", "source", "goal", "sighting_action", "combat_second", "malek_intent"];
|
||||
|
||||
// the two Greens are met by climbing down slowly, or by climbing down quickly and letting the Red pass
|
||||
const GREENS = (r) => r.branch === "Descend slowly: two Greens" || r.branch === "Descend quickly: let the Red pass";
|
||||
// Encounter contexts: which recorded dragon attempt belongs to which in-game encounter.
|
||||
const CONTEXTS = [
|
||||
["Red (tree, descend quickly)", (r) => r.hour === "Tree" && r.branch === "Descend quickly: Red", "enc_Red", "Red"],
|
||||
["Green (two Greens)", (r) => r.hour === "Tree" && r.branch === "Descend slowly: two Greens", "enc_Green", "Green"],
|
||||
["Green (two Greens)", (r) => r.hour === "Tree" && GREENS(r), "enc_Green", "Green"],
|
||||
["Blue (shadow)", (r) => r.hour === "Tree" && r.branch === "Shadow (rare)", "enc_Blue", "Blue"],
|
||||
["Black (shadow)", (r) => r.hour === "Tree" && r.branch === "Shadow (rare)", "enc_Black", "Black"],
|
||||
["Red (valley)", (r) => r.hour === "Valley" && r.branch === "Valley Red", "enc_Red", "Red"],
|
||||
@@ -659,7 +667,7 @@
|
||||
by_stratum: Object.fromEntries(sortedKeys(byS).map((s) => [s, rate(byS[s], win)])),
|
||||
};
|
||||
});
|
||||
const greens = runs.filter((r) => r.hour === "Tree" && r.branch === "Descend slowly: two Greens" && r.enc_Green);
|
||||
const greens = runs.filter((r) => r.hour === "Tree" && GREENS(r) && r.enc_Green);
|
||||
res.green_rescue = {
|
||||
green_encounters: greens.length,
|
||||
bonded_green: greens.filter((r) => r.enc_Green === "Bonded!").length,
|
||||
|
||||
@@ -104,6 +104,9 @@
|
||||
[/^allow your squadmate to exact/, "resolution", "Squadmate's revenge"],
|
||||
[/^leave the bullies alive/, "resolution", "Left bullies to the dragons"],
|
||||
[/tourniquet/, "resolution", "Tourniquet"],
|
||||
// the wounded cadet's other two choices (the bot has not logged this screen yet, so these are kept loose)
|
||||
[/leave (them|him|her) to die/, "resolution", "Left injured cadet"],
|
||||
[/take (their|his|her) weapons?/, "resolution", "Took their weapons"],
|
||||
[/^walk toward the east/, "post_path", "East"],
|
||||
[/^walk toward the west/, "post_path", "West"],
|
||||
[/^walk farther into the forest/, "post_path", "Forest"],
|
||||
|
||||
+8
-9
@@ -102,7 +102,8 @@
|
||||
const v = { company: DECISIONS.company.includes(r.company) ? r.company : null,
|
||||
direction: DECISIONS.direction.includes(r.direction) ? r.direction : null,
|
||||
fs: ["Red", "Brown", "Green", "Orange"].includes(r.first_sighting) ? r.first_sighting : null };
|
||||
v.left = v.company === "Alone" ? ALONE : v.company ? (String(r.left_squadmates) === "true" || r.left_squadmates === true ? "Leave them" : "Stay together") : null;
|
||||
const leftKnown = r.left_squadmates != null && r.left_squadmates !== "";
|
||||
v.left = v.company === "Alone" ? ALONE : v.company && leftKnown ? (String(r.left_squadmates) === "true" || r.left_squadmates === true ? "Leave them" : "Stay together") : null;
|
||||
v.react = DECISIONS.react.includes(r.sighting_action) ? r.sighting_action : null;
|
||||
v.diedSight = r.scream === "DIED at first sighting";
|
||||
if (v.diedSight) return v;
|
||||
@@ -128,12 +129,8 @@
|
||||
if (v.hour === "Tree" && b) {
|
||||
v.shadow = b === "Shadow (rare)";
|
||||
if (v.shadow) { v.shadowColour = r.enc_Black ? "Black" : "Blue"; v.encCtx = "shadow-" + v.shadowColour; }
|
||||
else if (b === "Descend quickly: Red") {
|
||||
v.descend = "Quickly (Red)";
|
||||
// a rider who let the Red pass and met the Greens instead
|
||||
if (r.enc_Red === "Changed my mind" && r.enc_Green) { v.red = "Let it pass (two Greens)"; v.encCtx = "tree-Greens"; }
|
||||
else { v.red = "Jump onto the Red"; v.encCtx = "tree-Red"; }
|
||||
}
|
||||
else if (b === "Descend quickly: Red") { v.descend = "Quickly (Red)"; v.red = "Jump onto the Red"; v.encCtx = "tree-Red"; }
|
||||
else if (b === "Descend quickly: let the Red pass") { v.descend = "Quickly (Red)"; v.red = "Let it pass (two Greens)"; v.encCtx = "tree-Greens"; }
|
||||
else if (b === "Descend slowly: two Greens") { v.descend = "Slowly (two Greens)"; v.encCtx = "tree-Greens"; }
|
||||
} else if (v.hour === "Valley" && b) {
|
||||
if (b === "Valley Red") { v.valley = "Face the Red"; v.encCtx = "valley-Red"; }
|
||||
@@ -620,7 +617,8 @@
|
||||
descend: { "Quickly (Red)": /^descend quickly/, "Slowly (two Greens)": /^climb down slowly/ },
|
||||
resolution: {
|
||||
"Killed the bullies yourself": /^end the lives of the bullies/, "Squadmate's revenge": /^allow your squadmate to exact/,
|
||||
"Left bullies to the dragons": /^leave the bullies alive/, "Tourniquet": /tourniquet/, "Took their weapons": /weapon/,
|
||||
"Left bullies to the dragons": /^leave the bullies alive/, "Tourniquet": /tourniquet/,
|
||||
"Left injured cadet": /leave (them|him|her) to die/, "Took their weapons": /take (their|his|her) weapons?/,
|
||||
},
|
||||
scream: { "Investigate the scream": /^investigate the scream/, "Keep walking": /^keep walking/ },
|
||||
clearing: { "Help your squadmate": /^help your squadmate/, "Walk away": /^play it safe and leave them/ },
|
||||
@@ -659,7 +657,8 @@
|
||||
if (DECISIONS.post.includes(vars.post_path)) h.post = vars.post_path;
|
||||
else if (h.cadet && !HELP[h.cadet]) h.post = "(no fork)";
|
||||
if (DECISIONS.hour.includes(vars.hour)) h.hour = vars.hour;
|
||||
if (vars.branch === "Descend quickly: Red") h.descend = "Quickly (Red)";
|
||||
if (vars.branch === "Descend quickly: Red" || vars.branch === "Descend quickly: let the Red pass") h.descend = "Quickly (Red)";
|
||||
if (vars.branch === "Descend quickly: let the Red pass" && !h.red) h.red = "Let it pass (two Greens)";
|
||||
if (DECISIONS.red.includes(vars.red)) h.red = vars.red;
|
||||
if (vars.branch === "Descend slowly: two Greens") h.descend = "Slowly (two Greens)";
|
||||
if (vars.branch === "Valley Red") h.valley = "Face the Red";
|
||||
|
||||
+4
-1
@@ -125,8 +125,11 @@ answers:
|
||||
"Climbed the tallest tree": Tree
|
||||
"N/A - You're dead": "DIED before the hour"
|
||||
|
||||
# Suffix on the company answer that means the rider later left their squadmates (redesigned form only).
|
||||
# Suffix on the company answer that means the rider later left their squadmates. The answer was only offered from
|
||||
# this date (none of the 504 squad runs before it chose it; 40 of 144 after it did): earlier and undated squad runs
|
||||
# are coded as unknown (empty), not as "stayed together".
|
||||
company_left_suffix: " > Left them"
|
||||
left_squadmates_asked_from: "2026-10-27"
|
||||
|
||||
# The encounter answers in the "attempt to bond" grid
|
||||
encounter_answers: { bonded: "Bonded!", burned: "Incinerated", passed: "Changed my mind", rescued: "Saved by another" }
|
||||
|
||||
Reference in New Issue
Block a user