Cadet encounter in the game's real order
The solver treated the cadet encounter as one seven-way choice made at the first dragon, so the map put a diamond there with no matching choices. It is now a sequence, as in the game: at the scream, investigate or keep walking; in the clearing, help your squadmate or walk away; then the bullies' fate (after surviving the fight) or what to do for the wounded cadet. Each choice point sits at its own place on the map and opens only its own options; an option that stays in the same place (helping, in the clearing) appears as a clickable label there. Bot histories that only know the final resolution still resolve correctly; the bot advisor maps each step onto the screen text. Policy rebuilt; tests added. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UCzTd31GphpMXDhQqWrCMQ
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
99f60282ed
commit
e8c177fc15
@@ -87,6 +87,7 @@
|
||||
[/^head west toward the scent/, "direction", "West"],
|
||||
[/^head toward the center of the forest/, "direction", "Center"],
|
||||
[/^keep walking the cadets are just as dangerous/, "scream", "Ignore the scream"],
|
||||
[/^investigate the scream/, "scream_investigate", true],
|
||||
[/^help your squadmate/, "scream", "Investigate & help"],
|
||||
[/^play it safe and leave them/, "scream", "Investigate & leave"],
|
||||
[/^pause to assess the situation/, "combat_first", "Assess the situation"],
|
||||
|
||||
+102
-33
@@ -2,7 +2,8 @@
|
||||
* solver.js: best decisions for bonding each dragon colour.
|
||||
*
|
||||
* Model: the threshing as a decision tree with perfect recall (an influence diagram).
|
||||
* decision nodes company, direction, cadet encounter, fork in the road, tree or valley, how to climb down,
|
||||
* 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,
|
||||
* 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
|
||||
@@ -36,11 +37,21 @@
|
||||
|
||||
const HELP = { "Killed the bullies yourself": 1, "Squadmate's revenge": 1, "Left bullies to the dragons": 1 };
|
||||
const IGNORE = { "Tourniquet": 1, "Left injured cadet": 1, "Took their weapons": 1 };
|
||||
// the resolution reached so far, whichever way the history was written down
|
||||
const cadetOf = (h) => h.cadet || h.fate || h.wounded || (h.clearing === "Walk away" ? "Left them to it" : null);
|
||||
const screamOf = (h) => h.scream || (cadetOf(h) ? (IGNORE[cadetOf(h)] ? "Keep walking" : "Investigate the scream") : null);
|
||||
const clearingOf = (h) => h.clearing || (cadetOf(h) && !IGNORE[cadetOf(h)] ? (cadetOf(h) === "Left them to it" ? "Walk away" : "Help your squadmate") : null);
|
||||
const DECISIONS = {
|
||||
company: ["Alone", "1 Squadmate", "2 Squadmates"],
|
||||
direction: ["East", "West", "Center"],
|
||||
cadet: ["Killed the bullies yourself", "Squadmate's revenge", "Left bullies to the dragons",
|
||||
"Tourniquet", "Left injured cadet", "Took their weapons", "Left them to it"],
|
||||
// the cadet encounter, in the game's own order: the scream, then (if you investigate) the clearing, then the
|
||||
// bullies' fate, or (if you keep walking) the wounded cadet
|
||||
scream: ["Investigate the scream", "Keep walking"],
|
||||
clearing: ["Help your squadmate", "Walk away"],
|
||||
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"],
|
||||
hour: ["Tree", "Valley"],
|
||||
descend: ["Quickly (Red)", "Slowly (two Greens)"],
|
||||
@@ -49,7 +60,8 @@
|
||||
};
|
||||
const LABEL = {
|
||||
company: "Company", direction: "First direction", fs: "First dragon", dieSight: "Survive the first dragon",
|
||||
cadet: "Cadet encounter", dieCombat: "Survive the fight", post: "Fork in the road", dieHour: "Survive the hour",
|
||||
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",
|
||||
hour: "After an hour", shadow: "Shadow at the tree", shadowColour: "Shadow dragon", descend: "Climb down",
|
||||
valley: "Valley centre", meadow: "Meadow dragon", encounter: "Bonding encounter",
|
||||
};
|
||||
@@ -323,11 +335,15 @@
|
||||
: mix(params.chance("meadow", h), (c) => encounter({ ...h, valley: o, meadow: c }, "meadow-" + c)));
|
||||
const hour = (h) => mix(params.chance("dieHour", h), (s) => s === "die" ? die() :
|
||||
best("hour", h, support.hour, (o) => (o === "Tree" ? tree : valley)({ ...h, hour: o })));
|
||||
const cadet = (h) => best("cadet", h, support.cadet, (o) => {
|
||||
const h2 = { ...h, cadet: o };
|
||||
if (HELP[o]) return mix(params.chance("dieCombat", h2), (s) => s === "die" ? die() :
|
||||
best("post", h2, support.post, (p) => hour({ ...h2, post: p })));
|
||||
return hour({ ...h2, post: "(no fork)" });
|
||||
const cadet = (h) => best("scream", h, support.scream, (sc) => {
|
||||
const h1 = { ...h, scream: sc };
|
||||
if (sc === "Keep walking") return best("wounded", h1, support.wounded, (o) => hour({ ...h1, cadet: o, post: "(no fork)" }));
|
||||
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 sighting = (h) => mix(params.chance("fs", h), (c) => {
|
||||
const h2 = { ...h, fs: c };
|
||||
@@ -373,11 +389,15 @@
|
||||
: mix(params.chance("meadow", h), (c) => encounter({ ...h, valley: o, meadow: c }, "meadow-" + c)));
|
||||
const hour = (h) => mix(params.chance("dieHour", h), (s) => s === "die" ? ZERO :
|
||||
pick("hour", h, (o) => (o === "Tree" ? tree : valley)({ ...h, hour: o })));
|
||||
const cadet = (h) => pick("cadet", h, (o) => {
|
||||
const h2 = { ...h, cadet: o };
|
||||
if (HELP[o]) return mix(params.chance("dieCombat", h2), (s) => s === "die" ? ZERO :
|
||||
pick("post", h2, (p) => hour({ ...h2, post: p })));
|
||||
return hour({ ...h2, post: "(no fork)" });
|
||||
const cadet = (h) => pick("scream", h, (sc) => {
|
||||
const h1 = { ...h, scream: sc };
|
||||
if (sc === "Keep walking") return pick("wounded", h1, (o) => hour({ ...h1, cadet: o, post: "(no fork)" }));
|
||||
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 sighting = (h) => mix(params.chance("fs", h), (c) => {
|
||||
const h2 = { ...h, fs: c };
|
||||
@@ -423,11 +443,15 @@
|
||||
: chance("meadow", params.chance("meadow", h), (c) => encounter({ ...h, valley: o, meadow: c }, "meadow-" + c)));
|
||||
const hour = (h) => chance("dieHour", params.chance("dieHour", h), (s) => s === "die" ? end("incinerated") :
|
||||
decision("hour", h, (o) => (o === "Tree" ? tree : valley)({ ...h, hour: o })));
|
||||
const cadet = (h) => decision("cadet", h, (o) => {
|
||||
const h2 = { ...h, cadet: o };
|
||||
if (HELP[o]) return chance("dieCombat", params.chance("dieCombat", h2), (s) => s === "die" ? end("killed in the fight") :
|
||||
decision("post", h2, (p) => hour({ ...h2, post: p })));
|
||||
return hour({ ...h2, post: "(no fork)" });
|
||||
const cadet = (h) => decision("scream", h, (sc) => {
|
||||
const h1 = { ...h, scream: sc };
|
||||
if (sc === "Keep walking") return decision("wounded", h1, (o) => hour({ ...h1, cadet: o, post: "(no fork)" }));
|
||||
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 sighting = (h) => chance("fs", params.chance("fs", h), (c) => {
|
||||
const h2 = { ...h, fs: c };
|
||||
@@ -450,9 +474,19 @@
|
||||
for (const v of prepared) {
|
||||
for (const k of ["company", "direction", "cadet", "hour", "descend", "valley"]) if (v[k]) bump(k, v[k]);
|
||||
if (v.post && v.post !== "(no fork)") bump("post", v.post);
|
||||
// the cadet encounter's steps, including riders killed in the fight (they chose to help)
|
||||
if (v.help || v.cadet) {
|
||||
const ignore = !!(v.cadet && IGNORE[v.cadet]);
|
||||
bump("scream", ignore ? "Keep walking" : "Investigate the scream");
|
||||
if (ignore) bump("wounded", v.cadet);
|
||||
else {
|
||||
bump("clearing", v.cadet === "Left them to it" ? "Walk away" : "Help your squadmate");
|
||||
if (HELP[v.cadet]) bump("fate", v.cadet);
|
||||
}
|
||||
}
|
||||
}
|
||||
const s = { encounter: DECISIONS.encounter };
|
||||
for (const k of ["company", "direction", "cadet", "post", "hour", "descend", "valley"])
|
||||
for (const k of ["company", "direction", "cadet", "scream", "clearing", "fate", "wounded", "post", "hour", "descend", "valley"])
|
||||
s[k] = DECISIONS[k].filter((o) => ((n[k] || {})[o] || 0) >= min);
|
||||
return { support: s, counts: n };
|
||||
}
|
||||
@@ -514,7 +548,6 @@
|
||||
|
||||
/* ---------- 6. Bot helper: what to pick on this screen ---------- */
|
||||
|
||||
const SCREAM_OF = (cadet) => (HELP[cadet] ? "help" : IGNORE[cadet] ? "ignore" : cadet === "Left them to it" ? "leave" : null);
|
||||
const OPTION_PATTERNS = {
|
||||
company: { "Alone": /^enter the valley alone/, "1 Squadmate": /^enter the valley with one/, "2 Squadmates": /^enter the valley with two/ },
|
||||
direction: { East: /^head east/, West: /^head west/, Center: /^head toward the center of the forest/ },
|
||||
@@ -525,7 +558,8 @@
|
||||
"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/,
|
||||
},
|
||||
scream: { help: /^(investigate the scream|help your squadmate)/, leave: /^(investigate the scream|play it safe and leave them)/, ignore: /^keep walking/ },
|
||||
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/ },
|
||||
};
|
||||
const norm = (t) => String(t || "").toLowerCase().replace(/[‘’']/g, "'").replace(/[–—-]/g, " ").replace(/[^a-z0-9'\s]/g, " ").replace(/\s+/g, " ").trim();
|
||||
|
||||
@@ -539,7 +573,15 @@
|
||||
if (DECISIONS.company.includes(vars.company)) h.company = vars.company;
|
||||
if (DECISIONS.direction.includes(vars.direction)) h.direction = vars.direction;
|
||||
if (["Red", "Brown", "Green", "Orange"].includes(vars.first_sighting)) h.fs = vars.first_sighting;
|
||||
if (DECISIONS.cadet.includes(vars.resolution)) h.cadet = vars.resolution;
|
||||
if (vars.scream === "Ignore the scream") h.scream = "Keep walking";
|
||||
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 (DECISIONS.cadet.includes(vars.resolution)) {
|
||||
h.cadet = vars.resolution;
|
||||
if (HELP[h.cadet]) h.fate = h.cadet;
|
||||
if (IGNORE[h.cadet]) h.wounded = h.cadet;
|
||||
}
|
||||
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;
|
||||
@@ -581,10 +623,25 @@
|
||||
if (!h.direction) return ["direction", { company: h.company }];
|
||||
if (!h.fs) return null;
|
||||
const a = { company: h.company, direction: h.direction, fs: h.fs };
|
||||
if (!h.cadet) return ["cadet", a];
|
||||
const b = { ...a, cadet: h.cadet };
|
||||
if (HELP[h.cadet] && !h.post) return ["post", b];
|
||||
const c = { ...b, post: HELP[h.cadet] ? h.post : "(no fork)" };
|
||||
const sc = screamOf(h), cad = cadetOf(h);
|
||||
if (!sc) return ["scream", a];
|
||||
const h1 = { ...a, scream: sc };
|
||||
let c;
|
||||
if (sc === "Keep walking") {
|
||||
if (!cad) return ["wounded", h1];
|
||||
c = { ...h1, cadet: cad, post: "(no fork)" };
|
||||
} else {
|
||||
const cl = clearingOf(h);
|
||||
if (!cl) return ["clearing", h1];
|
||||
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];
|
||||
const h3 = { ...h2, cadet: cad };
|
||||
if (!h.post) return ["post", h3];
|
||||
c = { ...h3, post: h.post };
|
||||
}
|
||||
}
|
||||
if (!h.hour) return ["hour", c];
|
||||
const d = { ...c, hour: h.hour };
|
||||
if (h.hour === "Tree") {
|
||||
@@ -625,11 +682,25 @@
|
||||
if (!h.fs) return cha("fs", a0);
|
||||
const a = { ...a0, fs: h.fs };
|
||||
const riskSight = params.chance("dieSight", a).die;
|
||||
if (!h.cadet) return dec("cadet", a, { risk: { label: "Killed at the first sighting", p: riskSight } });
|
||||
const b = { ...a, cadet: h.cadet };
|
||||
const riskCombat = HELP[h.cadet] ? params.chance("dieCombat", b).die : 0;
|
||||
if (HELP[h.cadet] && !h.post) return dec("post", b, { risk: { label: "Killed in the fight", p: riskCombat } });
|
||||
const c = { ...b, post: HELP[h.cadet] ? h.post : "(no fork)" };
|
||||
const sc = screamOf(h), cad = cadetOf(h);
|
||||
if (!sc) return dec("scream", a, { risk: { label: "Killed at the first sighting", p: riskSight } });
|
||||
const h1 = { ...a, scream: sc };
|
||||
let c;
|
||||
if (sc === "Keep walking") {
|
||||
if (!cad) return dec("wounded", h1);
|
||||
c = { ...h1, cadet: cad, post: "(no fork)" };
|
||||
} else {
|
||||
const cl = clearingOf(h);
|
||||
if (!cl) return dec("clearing", h1);
|
||||
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 h3 = { ...h2, cadet: cad };
|
||||
if (!h.post) return dec("post", h3);
|
||||
c = { ...h3, post: h.post };
|
||||
}
|
||||
}
|
||||
const riskHour = params.chance("dieHour", c).die;
|
||||
if (!h.hour) return dec("hour", c, { risk: { label: "Killed before the hour", p: riskHour } });
|
||||
const d = { ...c, hour: h.hour };
|
||||
@@ -681,10 +752,8 @@
|
||||
const texts = offered.map(norm);
|
||||
const find = (re) => texts.findIndex((t) => re.test(t));
|
||||
let idx = -1;
|
||||
if (rec.decision === "cadet") {
|
||||
if (rec.decision === "fate" || rec.decision === "wounded") {
|
||||
idx = find(OPTION_PATTERNS.resolution[rec.choice] || /$^/);
|
||||
const scream = SCREAM_OF(rec.choice);
|
||||
if (idx < 0 && scream) idx = find(OPTION_PATTERNS.scream[scream]);
|
||||
} else if (OPTION_PATTERNS[rec.decision]) {
|
||||
idx = find(OPTION_PATTERNS[rec.decision][rec.choice] || /$^/);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user