Bully fight: add the first move and the dagger choice to the solver and the map

After helping your squadmate the game asks your first move (pause to assess, charge the
smaller cadet, or get between your squadmate and the bigger one) and, after pausing, what to
do about the smaller cadet's dagger. Both are now decisions in the solver, and the chance of
dying in the fight depends on them (about 3 in 10 riders who charged in died; almost none who
paused). With that split, helping now beats walking away.

On the map, several choices made at one place share one diamond, which opens a card listing
each choice in the game's order. Policy rebuilt; the policy build gets a larger heap.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UCzTd31GphpMXDhQqWrCMQ
This commit is contained in:
ekcSchiano
2026-11-02 20:09:13 +00:00
co-authored by Claude Opus 5.5
parent 1646844fa6
commit 5f66b9647a
20 changed files with 548 additions and 291 deletions
+3 -1
View File
@@ -93,6 +93,8 @@
[/^pause to assess the situation/, "combat_first", "Assess the situation"],
[/^charge the other cadet/, "combat_first", "Even the numbers (smaller cadet)"],
[/^unsheathe your weapon and charge between/, "combat_first", "Put yourself in the middle (bigger cadet)"],
[/^engage the smaller cadet/, "combat_second", "Engage the smaller cadet"],
[/^daggers or not/, "combat_second", "Daggers or not (protect squadmate)"],
[/^end the lives of the bullies/, "resolution", "Killed the bullies yourself"],
[/^allow your squadmate to exact/, "resolution", "Squadmate's revenge"],
[/^leave the bullies alive/, "resolution", "Left bullies to the dragons"],
@@ -125,7 +127,7 @@
/** A coded community-form run (engine.codeRow output) in the same shape. */
function formRunVariables(run) {
const keep = ["company", "direction", "first_sighting", "scream", "combat_first", "resolution", "post_path", "hour", "branch", "outcome", "outcome_color"];
const keep = ["company", "direction", "first_sighting", "scream", "combat_first", "combat_second", "resolution", "post_path", "hour", "branch", "outcome", "outcome_color"];
const vars = {};
for (const k of keep) vars[k] = run[k] == null ? null : run[k];
return vars;
+56 -12
View File
@@ -3,7 +3,7 @@
*
* Model: the threshing as a decision tree with perfect recall (an influence diagram).
* decision nodes company, direction, the cadet encounter in the game's order (the scream: investigate or keep walking; the
* clearing: help your squadmate or walk away; the bullies' fate; or the wounded cadet), fork in the road, tree or valley, how to climb down,
* clearing: help your squadmate or walk away; your first move in the fight and, after pausing, the dagger; the bullies' fate; or the wounded cadet), fork in the road, tree or valley, how to climb down,
* whether to face the valley Red, and at every bonding encounter: attempt the bond or die on purpose
* chance nodes first dragon colour, dying at the sighting / in the bully fight / before the hour,
* the shadow at the tree and its colour, which dragon waits in the meadow, the encounter outcome
@@ -50,6 +50,9 @@
// bullies' fate, or (if you keep walking) the wounded cadet
scream: ["Investigate the scream", "Keep walking"],
clearing: ["Help your squadmate", "Walk away"],
// the fight itself: your first move, and (if you paused to assess) what to do about the smaller cadet's dagger
fight: ["Pause to assess", "Charge the smaller cadet", "Charge between the bigger cadet and your squadmate"],
dagger: ["Engage the smaller cadet", "Charge the bigger cadet anyway"],
fate: ["Killed the bullies yourself", "Squadmate's revenge", "Left bullies to the dragons"],
wounded: ["Tourniquet", "Left injured cadet", "Took their weapons"],
post: ["Forest", "West", "East"],
@@ -61,10 +64,17 @@
const LABEL = {
company: "Company", direction: "First direction", fs: "First dragon", dieSight: "Survive the first dragon",
cadet: "Cadet encounter", scream: "The scream", clearing: "The clearing (your squadmate vs two bullies)",
fate: "The bullies' fate", wounded: "The wounded cadet", dieCombat: "Survive the fight", post: "Fork in the road", dieHour: "Survive the hour",
fight: "The fight: your first move", dagger: "The smaller cadet's dagger", fate: "The bullies' fate", wounded: "The wounded cadet", dieCombat: "Survive the fight", post: "Fork in the road", dieHour: "Survive the hour",
hour: "After an hour", shadow: "Shadow at the tree", shadowColour: "Shadow dragon", descend: "Climb down",
valley: "Valley centre", meadow: "Meadow dragon", encounter: "Bonding encounter",
};
// community-form codes for the fight moves -> the solver's option names
const FIGHT_OF = { "Assess the situation": "Pause to assess", "Even the numbers (smaller cadet)": "Charge the smaller cadet",
"Put yourself in the middle (bigger cadet)": "Charge between the bigger cadet and your squadmate" };
const DAGGER_OF = { "Engage the smaller cadet": "Engage the smaller cadet", "Daggers or not (protect squadmate)": "Charge the bigger cadet anyway" };
const NO_DAGGER = "(no dagger choice)";
// the fight moves in a history; a run that charged straight in never faces the dagger
const daggerAfter = (fight, dagger) => (fight == null ? null : fight === "Pause to assess" ? dagger || null : NO_DAGGER);
const encColour = (ctx) => (ctx === "tree-Greens" ? "Green" : ctx.split("-")[1]);
/** The colour (or colours) a rider's stated goal commits them to, for deciding whether an attempt was genuine. */
@@ -89,6 +99,8 @@
const res = r.resolution;
if (r.scream === "Investigate & help") {
v.help = true;
v.fight = FIGHT_OF[r.combat_first] || null;
v.dagger = daggerAfter(v.fight, DAGGER_OF[r.combat_second]);
v.diedCombat = res === "DIED in combat";
v.cadet = HELP[res] ? res : null;
if (v.diedCombat) return v;
@@ -132,7 +144,7 @@
const CHANCE = {
fs: { cats: ["Red", "Brown", "Green", "Orange"], ctx: ["direction", "company"], get: (v) => v.fs },
dieSight: { cats: ["die", "live"], ctx: ["fs", "direction", "company"], get: (v) => (v.fs ? (v.diedSight ? "die" : "live") : null) },
dieCombat: { cats: ["die", "live"], ctx: ["fs", "direction"], get: (v) => (v.help ? (v.diedCombat ? "die" : "live") : null) },
dieCombat: { cats: ["die", "live"], ctx: ["fight", "dagger", "fs", "direction"], get: (v) => (v.help ? (v.diedCombat ? "die" : "live") : null) },
dieHour: { cats: ["die", "live"], ctx: ["cadet", "post"], get: (v) => (v.survivedCadets ? (v.diedHour ? "die" : "live") : null) },
shadow: { cats: ["yes", "no"], ctx: ["cadet", "post", "fs", "direction", "company"], get: (v) => (v.shadow === undefined ? null : v.shadow ? "yes" : "no") },
shadowColour: { cats: ["Black", "Blue"], ctx: [], get: (v) => v.shadowColour || null },
@@ -341,8 +353,11 @@
return best("clearing", h1, support.clearing, (cl) => {
const h2 = { ...h1, clearing: cl };
if (cl === "Walk away") return hour({ ...h2, cadet: "Left them to it", post: "(no fork)" });
return mix(params.chance("dieCombat", h2), (s) => s === "die" ? die() :
best("fate", h2, support.fate, (o) => { const h3 = { ...h2, cadet: o }; return best("post", h3, support.post, (p) => hour({ ...h3, post: p })); }));
const combat = (hf) => mix(params.chance("dieCombat", hf), (s) => s === "die" ? die() :
best("fate", hf, support.fate, (o) => { const h3 = { ...h2, cadet: o }; return best("post", h3, support.post, (p) => hour({ ...h3, post: p })); }));
return best("fight", h2, support.fight, (f) => f === "Pause to assess"
? best("dagger", { ...h2, fight: f }, support.dagger, (d) => combat({ ...h2, fight: f, dagger: d }))
: combat({ ...h2, fight: f, dagger: NO_DAGGER }));
});
});
const sighting = (h) => mix(params.chance("fs", h), (c) => {
@@ -352,6 +367,7 @@
const root = best("company", {}, support.company, (c) =>
best("direction", { company: c }, support.direction, (d) => sighting({ company: c, direction: d })));
memo.clear(); // the values are no longer needed; posterior draws keep only their choices
const decide = (name, h) => choices.get(name + "@" + JSON.stringify(h));
return { value: root, decide, optionValues: (name, h) => optVals && optVals.get(name + "@" + JSON.stringify(h)) };
}
@@ -395,8 +411,11 @@
return pick("clearing", h1, (cl) => {
const h2 = { ...h1, clearing: cl };
if (cl === "Walk away") return hour({ ...h2, cadet: "Left them to it", post: "(no fork)" });
return mix(params.chance("dieCombat", h2), (s) => s === "die" ? ZERO :
pick("fate", h2, (o) => { const h3 = { ...h2, cadet: o }; return pick("post", h3, (p) => hour({ ...h3, post: p })); }));
const combat = (hf) => mix(params.chance("dieCombat", hf), (s) => s === "die" ? ZERO :
pick("fate", hf, (o) => { const h3 = { ...h2, cadet: o }; return pick("post", h3, (p) => hour({ ...h3, post: p })); }));
return pick("fight", h2, (f) => f === "Pause to assess"
? pick("dagger", { ...h2, fight: f }, (d) => combat({ ...h2, fight: f, dagger: d }))
: combat({ ...h2, fight: f, dagger: NO_DAGGER }));
});
});
const sighting = (h) => mix(params.chance("fs", h), (c) => {
@@ -449,8 +468,11 @@
return decision("clearing", h1, (cl) => {
const h2 = { ...h1, clearing: cl };
if (cl === "Walk away") return hour({ ...h2, cadet: "Left them to it", post: "(no fork)" });
return chance("dieCombat", params.chance("dieCombat", h2), (s) => s === "die" ? end("killed in the fight") :
decision("fate", h2, (o) => { const h3 = { ...h2, cadet: o }; return decision("post", h3, (p) => hour({ ...h3, post: p })); }));
const combat = (hf) => chance("dieCombat", params.chance("dieCombat", hf), (s) => s === "die" ? end("killed in the fight") :
decision("fate", hf, (o) => { const h3 = { ...h2, cadet: o }; return decision("post", h3, (p) => hour({ ...h3, post: p })); }));
return decision("fight", h2, (f) => f === "Pause to assess"
? decision("dagger", { ...h2, fight: f }, (d) => combat({ ...h2, fight: f, dagger: d }))
: combat({ ...h2, fight: f, dagger: NO_DAGGER }));
});
});
const sighting = (h) => chance("fs", params.chance("fs", h), (c) => {
@@ -482,12 +504,17 @@
else {
bump("clearing", v.cadet === "Left them to it" ? "Walk away" : "Help your squadmate");
if (HELP[v.cadet]) bump("fate", v.cadet);
if (v.help && v.fight) { bump("fight", v.fight); if (v.dagger && v.dagger !== NO_DAGGER) bump("dagger", v.dagger); }
}
}
}
const s = { encounter: DECISIONS.encounter };
for (const k of ["company", "direction", "cadet", "scream", "clearing", "fate", "wounded", "post", "hour", "descend", "valley"])
for (const k of ["company", "direction", "cadet", "scream", "clearing", "fight", "dagger", "fate", "wounded", "post", "hour", "descend", "valley"])
{
s[k] = DECISIONS[k].filter((o) => ((n[k] || {})[o] || 0) >= min);
// a step the data never record (e.g. the fight moves in an old export) is not restricted
if (!s[k].length) s[k] = DECISIONS[k].slice();
}
return { support: s, counts: n };
}
@@ -560,6 +587,9 @@
},
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/ },
fight: { "Pause to assess": /^pause to assess/, "Charge the smaller cadet": /^charge the other cadet/,
"Charge between the bigger cadet and your squadmate": /^unsheathe your weapon/ },
dagger: { "Engage the smaller cadet": /^engage the smaller cadet/, "Charge the bigger cadet anyway": /^daggers or not/ },
};
const norm = (t) => String(t || "").toLowerCase().replace(/[‘’']/g, "'").replace(/[–—-]/g, " ").replace(/[^a-z0-9'\s]/g, " ").replace(/\s+/g, " ").trim();
@@ -577,6 +607,8 @@
else if (vars.scream === "Investigate & help" || vars.scream === "Investigate & leave" || vars.scream_investigate) h.scream = "Investigate the scream";
if (vars.scream === "Investigate & help") h.clearing = "Help your squadmate";
if (vars.scream === "Investigate & leave") h.clearing = "Walk away";
if (FIGHT_OF[vars.combat_first]) h.fight = FIGHT_OF[vars.combat_first];
if (DAGGER_OF[vars.combat_second]) h.dagger = DAGGER_OF[vars.combat_second];
if (DECISIONS.cadet.includes(vars.resolution)) {
h.cadet = vars.resolution;
if (HELP[h.cadet]) h.fate = h.cadet;
@@ -636,7 +668,13 @@
const h2 = { ...h1, clearing: cl };
if (cl === "Walk away") c = { ...h2, cadet: "Left them to it", post: "(no fork)" };
else {
if (!cad) return ["fate", h2];
// older records may skip the fight moves; assume the usual ones (pause, then engage) so advice can continue
const f = h.fight || (cad ? "Pause to assess" : null);
if (!f) return ["fight", h2];
const dg = daggerAfter(f, h.dagger || (cad ? "Engage the smaller cadet" : null));
if (!dg) return ["dagger", { ...h2, fight: f }];
const hf = { ...h2, fight: f, dagger: dg };
if (!cad) return ["fate", hf];
const h3 = { ...h2, cadet: cad };
if (!h.post) return ["post", h3];
c = { ...h3, post: h.post };
@@ -695,7 +733,13 @@
const h2 = { ...h1, clearing: cl };
if (cl === "Walk away") c = { ...h2, cadet: "Left them to it", post: "(no fork)" };
else {
if (!cad) return dec("fate", h2, { risk: { label: "Killed in the fight", p: params.chance("dieCombat", h2).die } });
const f = h.fight || (cad ? "Pause to assess" : null);
if (!f) return dec("fight", h2);
const dg = daggerAfter(f, h.dagger || (cad ? "Engage the smaller cadet" : null));
if (!dg) return dec("dagger", { ...h2, fight: f });
const hf = { ...h2, fight: f, dagger: dg };
if (!cad) return dec("fate", hf, { risk: { label: "Killed in the fight", p: params.chance("dieCombat", hf).die } });
// nothing after the fight depends on its moves, so the rest of the history leaves them out (shared subtree)
const h3 = { ...h2, cadet: cad };
if (!h.post) return dec("post", h3);
c = { ...h3, post: h.post };