Route model: every logged choice; map keeps your choices on every route

Solver: adds leaving your squadmates, your reaction to the first dragon (options offered per
dragon, from the form's categories) and, below the tree, jumping onto the Red or letting it pass
to the two Greens. Bot crosswalk and option patterns map the game's text for each.

Map: a choice you make now holds for every route to that dragon, together with the earlier steps
of the path you were looking at, so a later choice never sends the route back through another
place. Routes your choices rule out are hidden; choosing an option closes its card.

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:50:59 +00:00
co-authored by Claude Opus 5.5
parent c2dcaee16f
commit 83bc19521e
19 changed files with 471 additions and 323 deletions
+27 -13
View File
@@ -177,7 +177,7 @@
if (s.var === "shadowColour" || s.var === "meadow") { const c = encColour(enc); if (s.probs[c] != null) return c; }
return ent[0][0];
}
function walk(enc, colour = st.colour, over = st.over[enc] || {}) {
function walk(enc, colour = st.colour, over = st.over[colour] || {}) {
const adv = advisorFor(enc, colour), steps = [], h = {};
for (let i = 0; i < 20; i++) {
const s = adv.step(h);
@@ -190,7 +190,10 @@
s.userSet = !!ok;
h[key] = s.taken;
}
return { enc, adv, steps, value: Object.keys(over).length ? routeValue(adv, over) : adv.value };
const end = steps[steps.length - 1];
// a route your choices can no longer reach (e.g. you chose the tree, so the meadow is out)
const reachable = end.kind === "end" && end.encounter === enc && end.action !== "Die on purpose";
return { enc, adv, steps, reachable, value: Object.keys(over).length ? routeValue(adv, over) : adv.value };
}
/**
@@ -235,6 +238,7 @@
const v = s.taken, h = s.before;
switch (s.var) {
case "company": push("comp:" + v); break;
case "leave": case "react": break; // made where you stand (the start, the first dragon)
case "direction": push("dir:" + v); break;
case "fs": push(`see:${h.direction}:${v}`); break;
// the cadet encounter, step by step: you hear the scream, then either investigate (the clearing with your
@@ -247,6 +251,7 @@
case "shadow": if (v === "yes") push("stream"); break;
case "shadowColour": push(v === "Black" ? "black" : "redwood"); break;
case "descend": push(v.startsWith("Quickly") ? "treeRed" : "greens"); break;
case "red": if (!v.startsWith("Jump")) push("greens"); break;
case "valley": push(v === "Face the Red" ? "valleyRed" : "meadow"); break;
case "meadow": push("meadow:" + v); break;
default: break;
@@ -261,7 +266,8 @@
company: "comp:" + v, direction: "dir:" + v, post: "fork:" + v,
scream: v === "Keep walking" ? "wounded" : "bully",
clearing: v === "Walk away" ? "away" : "bully",
fight: "bully", dagger: "bully",
fight: "bully", dagger: "bully", leave: null, react: null,
red: v.startsWith("Jump") ? "treeRed" : "greens",
fate: "res:" + v, wounded: "res:" + v,
hour: v === "Tree" ? "tree" : "valley", descend: v.startsWith("Quickly") ? "treeRed" : "greens",
valley: v === "Face the Red" ? "valleyRed" : "meadow",
@@ -500,7 +506,7 @@
"Charge between the bigger cadet and your squadmate": "Get between them",
"Engage the smaller cadet": "Engage the smaller one", "Charge the bigger cadet anyway": "Charge the bigger one",
};
const CAPTION = { clearing: "Your squadmate vs two bullies", fight: "Your first move", dagger: "The smaller cadet has a dagger" };
const CAPTION = { leave: "Your squadmates", react: "When the first dragon appears", clearing: "Your squadmate vs two bullies", fight: "Your first move", dagger: "The smaller cadet has a dagger" };
/**
* The choices made at one place, in the game's order, as a small card beside it: one row per choice, every
* option with its chance (the one on this route is filled). Clicking an option takes it instead.
@@ -668,11 +674,12 @@
<button type="button" class="ex-close" id="ex-clear" aria-label="Back to the whole valley">×</button></div>
${chooser()}
<div class="seg" role="group" aria-label="Goal"><button type="button" data-o="eventually" aria-pressed="${st.objective === "eventually"}" title="Die on purpose and try again whenever it goes wrong; never risk ending on another dragon">Only this dragon</button><button type="button" data-o="thisAttempt" aria-pressed="${st.objective === "thisAttempt"}" title="Best chance on this one run">Best odds this run</button></div>
${st.blocked ? `<p class="small ex-warn">Your choices so far can't reach a ${st.colour} dragon. <button type="button" class="linklike" id="ex-reset-route">Reset your choices</button></p>` : ""}
<div class="ex-routes">${routes.map(card).join("")}</div>
<p class="small muted ex-key"><span class="solid"></span> best route <span class="dashed"></span> under half as likely <span class="dotted"></span> under a tenth · line width: chance you are still on the route</p>
<span class="eyebrow">${esc(ENC_NAME[focus.enc])}: step by step</span>
<ol class="ex-steps">${steps}</ol>
<p class="small muted">Diamonds on the map are choices: click one to see where the other options lead. Changed your mind? <button type="button" class="linklike" id="ex-reset-route">Reset this route</button></p>
<p class="small muted">Diamonds on the map are choices: click one to see where the other options lead. ${st.blocked ? "" : `Your choices apply to every route to this dragon. Changed your mind? <button type="button" class="linklike" id="ex-reset-route">Reset your choices</button>`}</p>
<details class="ex-why"><summary>Why this route?</summary>
<p class="small">Best route for any ${st.colour}: <b>${pct(b.pX.mean)}</b> per attempt (95% interval ${pct(b.pX.lo)}–${pct(b.pX.hi)}), about ${isFinite(b.expectedAttempts.mean) ? Math.round(b.expectedAttempts.mean) : "–"} attempts. Riders who logged every run suggest ${pct(lb.pX.mean)}.</p>
<p class="small">Each roll's odds may depend on your earlier choices, as far as the data support it. Choices marked "no clear winner" in <a href="#deep">Deep Dive</a> are within the noise.${risks.length ? ` Risks on this route: ${risks.join(", ")}.` : ""}</p>
@@ -695,11 +702,10 @@
const cp = $("#ex-clear-point", p); if (cp) cp.addEventListener("click", () => { st.point = null; writeHash(); render(); });
$$(".ex-from-row[data-c]", p).forEach((b) => b.addEventListener("click", () => {
// follow that dragon's route, keeping this place on it
const enc = b.dataset.enc;
st.over[enc] = { ...POINTS[st.point].force };
select(b.dataset.c, enc);
st.over[b.dataset.c] = { ...POINTS[st.point].force };
select(b.dataset.c, b.dataset.enc);
}));
const rr = $("#ex-reset-route", p); if (rr) rr.addEventListener("click", () => { delete st.over[st.focus]; st.expanded = null; render(); });
const rr = $("#ex-reset-route", p); if (rr) rr.addEventListener("click", () => { delete st.over[st.colour]; st.expanded = null; render(); });
}
/* ---------- actions ---------- */
@@ -713,12 +719,17 @@
function choose(v, val) {
const route = walk(st.focus);
const order = route.steps.map((s) => s.var);
const over = { ...(st.over[st.focus] || {}) };
const over = { ...(st.over[st.colour] || {}) };
// keep choices before this one, drop the ones after it
const idx = order.indexOf(v);
order.slice(idx + 1).forEach((k) => delete over[k]);
// the path up to here is the one you are looking at: keep its earlier choices too, so switching to another
// route to this dragon (e.g. the tree instead of the valley) never changes where you have already been
route.steps.slice(0, Math.max(0, idx)).forEach((s) => { if (s.kind === "decision" && over[s.var] == null) over[s.var] = s.taken; });
over[v] = val;
st.over[st.focus] = over;
// your choices hold for every route to this dragon: a later choice never sends the route back through another place
st.over[st.colour] = over;
st.expanded = null;
render();
}
function writeHash() {
@@ -742,8 +753,7 @@
if (!st.policy) { st.pendingHash = { c, enc }; return; }
// a link to a dragon opens its most probable route, fresh: no earlier detours, nothing expanded
st.colour = c; st.focus = enc; st.expanded = null; st.info = null;
delete st.over[enc || ""];
S.ENCOUNTERS[c].forEach((e) => delete st.over[e]);
delete st.over[c];
render();
}
@@ -764,6 +774,10 @@
r.geo = routePoints(r);
return r;
}).sort((a, b) => b.value.x - a.value.x);
// drop the routes your choices rule out; if every one is ruled out, keep them so the panel can say so
const open = routes.filter((r) => r.reachable);
st.blocked = !open.length;
if (open.length) routes = open;
if (!st.focus || !routes.some((r) => r.enc === st.focus)) st.focus = routes[0].enc;
pills = [];
onRoute = drawRoutes(gRoute, gLab, routes);
+2 -1
View File
@@ -672,10 +672,11 @@ adjusted OR = exp(βⱼ), 95% CI = exp(βⱼ ± 1.96·SEⱼ)</div>
</div>
<div class="mpanel method" role="tabpanel" id="mt-5-panel" aria-labelledby="mt-5" hidden>
<h3>6. Best routes, the valley map and The Odds</h3>
<p>The valley map and The Odds come from a solver (<code>solver.js</code>) that treats a run as a decision tree. Your choices are decisions (company, direction, the cadet encounter in the game's order — investigate the scream or keep walking, help your squadmate or walk away, your first move in the fight (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, then the bullies' fate or what to do for the wounded cadet — the fork, tree or valley, how to climb down, whether to face the valley Red, and at every bonding encounter whether to attempt the bond or die on purpose). The game's rolls are chance events: which dragon appears first, whether you die at the sighting, in the fight or before the hour, whether the shadow appears and which dragon it is, which dragon waits in the meadow, and how the bonding encounter ends.</p>
<p>The valley map and The Odds come from a solver (<code>solver.js</code>) that treats a run as a decision tree. Your choices are decisions (company and, with squadmates, whether you later leave them; direction; how you react when the first dragon appears; the cadet encounter in the game's order — investigate the scream or keep walking, help your squadmate or walk away, your first move in the fight (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, then the bullies' fate or what to do for the wounded cadet — the fork, tree or valley, how to climb down, whether to jump onto the Red below the tree or let it pass and go on to the two Greens, whether to face the valley Red, and at every bonding encounter whether to attempt the bond or die on purpose). The game's rolls are chance events: which dragon appears first, whether you die at the sighting, in the fight or before the hour, whether the shadow appears and which dragon it is, which dragon waits in the meadow, and how the bonding encounter ends.</p>
<p>Each roll's probability may depend on the choices before it. It is estimated with <b>hierarchical <a href="https://en.wikipedia.org/wiki/Dirichlet-multinomial_distribution" target="_blank" rel="noopener">Dirichlet</a> back-off</b>: the estimate for a full history is pulled toward the estimate for a shorter history, which is pulled toward the overall rate. How strongly is chosen from the data for each roll (<a href="https://en.wikipedia.org/wiki/Empirical_Bayes_method" target="_blank" rel="noopener">empirical Bayes</a>), so the solver does not chase noise in small groups. The best route is then found by <b><a href="https://en.wikipedia.org/wiki/Backward_induction" target="_blank" rel="noopener">backward induction</a></b>, for two goals: the chance of bonding the dragon on this attempt, and, for riders who die on purpose whenever a run goes wrong, the chance that the account eventually ends on that dragon rather than another (maximised by <a href="https://en.wikipedia.org/wiki/Fractional_programming" target="_blank" rel="noopener">Dinkelbach iteration</a>). Ranges come from 200 posterior draws; "stays best in N%" is how often the recommended choice is still best across those draws.</p>
<p>Encounter outcomes use only <b>genuine attempts</b>: runs where the rider wanted that colour, any dragon, or said they would not seek Malek. The two summary cards on The Odds use the same rule in reverse: runs where the rider died on purpose at an encounter they did not want are left out, so they describe cadets who went into the valley and either bonded or died. The "low-bias" numbers use only bulk logs and form runs from riders who were not chasing a rare dragon.</p>
<p><b>Starting from a place.</b> Clicking a place on the map before choosing a dragon shows your chance of each dragon <i>from there on</i>. Choices before that place are the ones that lead to it (or the solver's best, where several do); rolls before it are averaged over the outcomes that can still reach it, weighted by how often they happen and by survival. From the place onward the solver plays the best route for each dragon. A dragon is "not reachable from here" when no logged run went from that place to it. Clicking the bully fight means you stepped in to help: the chances assume your best first move and include the risk of dying in the fight. The move matters: about 3 in 10 riders who charged straight in were killed, against almost none who paused to assess. Several choices made at one place (as at the bully fight) share one diamond on the map, which opens a small card with each choice in order. For Orange and Brown, the Greens rescue is used only when their own meadow is out of reach.</p>
<p><b>Choices that are not modelled yet.</b> The answers you give at the bonding encounters themselves (for example which way to turn for the two Greens, or when to jump onto the Red) are not recorded by the community form, so every encounter uses its average bond chance. Ken's bot records every option it picks, so these can be added once enough bot runs come in. Letting the Red pass is rarely logged on its own; its chance is taken from the two Greens' encounter, which has plenty of data. Reactions to the first dragon use the form's categories, and only those logged at least 20 times for that dragon are offered. On the map, a choice you make holds for every route to that dragon, and routes it rules out are hidden.</p>
</div>
<div class="mpanel method" role="tabpanel" id="mt-6-panel" aria-labelledby="mt-6" hidden>
<h3>Missing answers</h3>
File diff suppressed because one or more lines are too long
+331 -267
View File
File diff suppressed because it is too large Load Diff
+9 -2
View File
@@ -87,6 +87,11 @@
[/^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"],
[/^run and hope/, "sighting_action", "Retreat / run"],
[/hold still/, "sighting_action", "Hold still"],
[/lower your eyes in respect|lower your eyes and turn to face it/, "sighting_action", "Respect / face it"],
[/meeting its gaze/, "sighting_action", "Meet its gaze"],
[/^hide behind a tree/, "sighting_action", "Hide"],
[/^investigate the scream/, "scream_investigate", true],
[/^help your squadmate/, "scream", "Investigate & help"],
[/^play it safe and leave them/, "scream", "Investigate & leave"],
@@ -105,7 +110,9 @@
[/^continue toward the center of the valley/, "hour", "Valley"],
[/^find the tallest tree/, "hour", "Tree"],
[/^descend quickly/, "branch", "Descend quickly: Red"],
[/^climb down slowly to pursue the green/, "branch", "Descend slowly: two Greens"]
[/^climb down slowly to pursue the green/, "branch", "Descend slowly: two Greens"],
[/^reds are too hot tempered/, "red", "Let it pass (two Greens)"],
[/^jump (now|in a few seconds)/, "red", "Jump onto the Red"]
];
/** Map one bot trajectory onto the form's decision variables. Unmapped choices are listed, not guessed. */
@@ -127,7 +134,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", "combat_second", "resolution", "post_path", "hour", "branch", "outcome", "outcome_color"];
const keep = ["company", "left_squadmates", "direction", "first_sighting", "sighting_action", "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;
+82 -25
View File
@@ -43,7 +43,11 @@
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"],
// entering with squadmates, you can later leave them and go on alone
leave: ["Stay together", "Leave them"],
direction: ["East", "West", "Center"],
// how you react when the first dragon appears (the form's categories; which ones are offered depends on the dragon)
react: ["Hold still", "Respect / face it", "Retreat / run", "Hide", "Weapon", "Meet its gaze", "Protect squadmate"],
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
@@ -58,11 +62,13 @@
post: ["Forest", "West", "East"],
hour: ["Tree", "Valley"],
descend: ["Quickly (Red)", "Slowly (two Greens)"],
// descending quickly puts you above a Red: jump onto it, or let it pass and go on to the two Greens
red: ["Jump onto the Red", "Let it pass (two Greens)"],
valley: ["Face the Red", "Pass the Red (meadow)"],
encounter: ["Attempt the bond", "Die on purpose"],
};
const LABEL = {
company: "Company", direction: "First direction", fs: "First dragon", dieSight: "Survive the first dragon",
company: "Company", leave: "Your squadmates", direction: "First direction", react: "Facing the first dragon", red: "The Red below the tree", fs: "First dragon", dieSight: "Survive the first dragon",
cadet: "Cadet encounter", scream: "The scream", clearing: "The clearing (your squadmate vs two bullies)",
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",
@@ -75,6 +81,8 @@
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 ALONE = "(alone)";
const leftOf = (h) => (h.company === "Alone" ? ALONE : h.left || null);
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. */
@@ -94,6 +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;
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;
const res = r.resolution;
@@ -118,7 +128,12 @@
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)"; v.encCtx = "tree-Red"; }
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 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"; }
@@ -142,8 +157,8 @@
// ctx: earlier variables the probability may depend on, most important first. Back-off drops from the end.
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) },
fs: { cats: ["Red", "Brown", "Green", "Orange"], ctx: ["direction", "company", "left"], get: (v) => v.fs },
dieSight: { cats: ["die", "live"], ctx: ["fs", "direction", "company", "left", "react"], get: (v) => (v.fs ? (v.diedSight ? "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") },
@@ -309,6 +324,7 @@
function solve(params, X, { lam = 0, support = DECISIONS, record = false, only = null } = {}) {
// only: bond only at these encounters (e.g. ["meadow-Blue"]); everywhere else the rider dies on purpose
const encOptions = (ctx) => (only && !only.includes(ctx) ? ["Die on purpose"] : support.encounter);
const reactOptions = (fs) => support["react:" + fs] || DECISIONS.react;
const score = (v) => (1 - lam) * v.x - lam * v.o + 1e-9 * v.x - 1e-12 * v.o;
const memo = new Map();
const choices = new Map();
@@ -341,7 +357,9 @@
});
const tree = (h) => mix(params.chance("shadow", h), (s) => s === "yes"
? mix(params.chance("shadowColour", h), (c) => encounter({ ...h, shadow: "yes" }, "shadow-" + c))
: best("descend", { ...h, shadow: "no" }, support.descend, (o) => encounter({ ...h, shadow: "no", descend: o }, o.startsWith("Quickly") ? "tree-Red" : "tree-Greens")));
: best("descend", { ...h, shadow: "no" }, support.descend, (o) => o.startsWith("Quickly")
? best("red", { ...h, shadow: "no", descend: o }, support.red, (rd) => encounter({ ...h, shadow: "no", descend: o, red: rd }, rd.startsWith("Jump") ? "tree-Red" : "tree-Greens"))
: encounter({ ...h, shadow: "no", descend: o }, "tree-Greens")));
const valley = (h) => best("valley", h, support.valley, (o) => o === "Face the Red"
? encounter({ ...h, valley: o }, "valley-Red")
: mix(params.chance("meadow", h), (c) => encounter({ ...h, valley: o, meadow: c }, "meadow-" + c)));
@@ -360,12 +378,16 @@
: combat({ ...h2, fight: f, dagger: NO_DAGGER }));
});
});
// the first dragon: which one appears (chance), how you react (decision), whether you survive (chance).
// Leaving your squadmates and your reaction only matter here, so the rest of the history leaves them out.
const sighting = (h) => mix(params.chance("fs", h), (c) => {
const h2 = { ...h, fs: c };
return mix(params.chance("dieSight", h2), (s) => (s === "die" ? die() : cadet(h2)));
const h2 = { ...h, fs: c }, rest = { company: h.company, direction: h.direction, fs: c };
return best("react", h2, reactOptions(c), (re) =>
mix(params.chance("dieSight", { ...h2, react: re }), (s) => (s === "die" ? die() : cadet(rest))));
});
const root = best("company", {}, support.company, (c) =>
best("direction", { company: c }, support.direction, (d) => sighting({ company: c, direction: d })));
const company = (c, f) => (c === "Alone" ? f({ company: c, left: ALONE }) : best("leave", { company: c }, support.leave, (l) => f({ company: c, left: l })));
const root = best("company", {}, support.company, (c) => company(c, (hc) =>
best("direction", hc, support.direction, (d) => sighting({ ...hc, 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));
@@ -399,7 +421,9 @@
});
const tree = (h) => mix(params.chance("shadow", h), (s) => s === "yes"
? mix(params.chance("shadowColour", h), (c) => encounter({ ...h, shadow: "yes" }, "shadow-" + c))
: pick("descend", { ...h, shadow: "no" }, (o) => encounter({ ...h, shadow: "no", descend: o }, o.startsWith("Quickly") ? "tree-Red" : "tree-Greens")));
: pick("descend", { ...h, shadow: "no" }, (o) => o.startsWith("Quickly")
? pick("red", { ...h, shadow: "no", descend: o }, (rd) => encounter({ ...h, shadow: "no", descend: o, red: rd }, rd.startsWith("Jump") ? "tree-Red" : "tree-Greens"))
: encounter({ ...h, shadow: "no", descend: o }, "tree-Greens")));
const valley = (h) => pick("valley", h, (o) => o === "Face the Red"
? encounter({ ...h, valley: o }, "valley-Red")
: mix(params.chance("meadow", h), (c) => encounter({ ...h, valley: o, meadow: c }, "meadow-" + c)));
@@ -419,10 +443,11 @@
});
});
const sighting = (h) => mix(params.chance("fs", h), (c) => {
const h2 = { ...h, fs: c };
return mix(params.chance("dieSight", h2), (s) => (s === "die" ? ZERO : cadet(h2)));
const h2 = { ...h, fs: c }, rest = { company: h.company, direction: h.direction, fs: c };
return pick("react", h2, (re) => mix(params.chance("dieSight", { ...h2, react: re }), (s) => (s === "die" ? ZERO : cadet(rest))));
});
return pick("company", {}, (c) => pick("direction", { company: c }, (d) => sighting({ company: c, direction: d })));
const company = (c, f) => (c === "Alone" ? f({ company: c, left: ALONE }) : pick("leave", { company: c }, (l) => f({ company: c, left: l })));
return pick("company", {}, (c) => company(c, (hc) => pick("direction", hc, (d) => sighting({ ...hc, direction: d }))));
}
/* ---------- 5. The published policy tree ---------- */
@@ -456,7 +481,9 @@
({ type: "end", what: `encounter: ${ctx}`, outcomes: params.encounter(ctx) }));
const tree = (h) => chance("shadow", params.chance("shadow", h), (s) => s === "yes"
? chance("shadowColour", params.chance("shadowColour", h), (c) => encounter({ ...h, shadow: "yes" }, "shadow-" + c))
: decision("descend", { ...h, shadow: "no" }, (o) => encounter({ ...h, shadow: "no", descend: o }, o.startsWith("Quickly") ? "tree-Red" : "tree-Greens")));
: decision("descend", { ...h, shadow: "no" }, (o) => o.startsWith("Quickly")
? decision("red", { ...h, shadow: "no", descend: o }, (rd) => encounter({ ...h, shadow: "no", descend: o, red: rd }, rd.startsWith("Jump") ? "tree-Red" : "tree-Greens"))
: encounter({ ...h, shadow: "no", descend: o }, "tree-Greens")));
const valley = (h) => decision("valley", h, (o) => o === "Face the Red"
? encounter({ ...h, valley: o }, "valley-Red")
: chance("meadow", params.chance("meadow", h), (c) => encounter({ ...h, valley: o, meadow: c }, "meadow-" + c)));
@@ -476,10 +503,11 @@
});
});
const sighting = (h) => chance("fs", params.chance("fs", h), (c) => {
const h2 = { ...h, fs: c };
return chance("dieSight", params.chance("dieSight", h2), (s) => (s === "die" ? end("incinerated at the first sighting") : cadet(h2)));
const h2 = { ...h, fs: c }, rest = { company: h.company, direction: h.direction, fs: c };
return decision("react", h2, (re) => chance("dieSight", params.chance("dieSight", { ...h2, react: re }), (s) => (s === "die" ? end("incinerated at the first sighting") : cadet(rest))));
});
return decision("company", {}, (c) => decision("direction", { company: c }, (d) => sighting({ company: c, direction: d })));
const company = (c, f) => (c === "Alone" ? f({ company: c, left: ALONE }) : decision("leave", { company: c }, (l) => f({ company: c, left: l })));
return decision("company", {}, (c) => company(c, (hc) => decision("direction", hc, (d) => sighting({ ...hc, direction: d }))));
}
const quantile = (xs, q) => {
@@ -495,6 +523,8 @@
const bump = (k, o) => { n[k] = n[k] || {}; n[k][o] = (n[k][o] || 0) + 1; };
for (const v of prepared) {
for (const k of ["company", "direction", "cadet", "hour", "descend", "valley"]) if (v[k]) bump(k, v[k]);
if (v.left && v.left !== ALONE) bump("leave", v.left);
if (v.fs && v.react) bump("react:" + v.fs, v.react);
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) {
@@ -509,12 +539,19 @@
}
}
const s = { encounter: DECISIONS.encounter };
for (const k of ["company", "direction", "cadet", "scream", "clearing", "fight", "dagger", "fate", "wounded", "post", "hour", "descend", "valley"])
for (const k of ["company", "leave", "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();
}
// reactions to the first dragon, per dragon (each dragon offers its own options)
for (const fs of ["Red", "Brown", "Green", "Orange"]) {
const k = "react:" + fs, ok = DECISIONS.react.filter((o) => ((n[k] || {})[o] || 0) >= min);
s[k] = ok.length ? ok : DECISIONS.react.slice();
}
// letting the Red pass is rarely logged, but its outcome is the two Greens' encounter, which has plenty of data
s.red = DECISIONS.red.slice();
return { support: s, counts: n };
}
@@ -590,6 +627,9 @@
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/ },
react: { "Hold still": /hold still/, "Respect / face it": /in respect|turn to face it/, "Retreat / run": /^run and hope/,
"Hide": /^hide/, "Meet its gaze": /meeting its gaze/ },
red: { "Jump onto the Red": /^jump/, "Let it pass (two Greens)": /^reds are too hot tempered/ },
};
const norm = (t) => String(t || "").toLowerCase().replace(/[‘’']/g, "'").replace(/[–—-]/g, " ").replace(/[^a-z0-9'\s]/g, " ").replace(/\s+/g, " ").trim();
@@ -601,7 +641,9 @@
function solverHistory(vars, seen = {}) {
const h = {};
if (DECISIONS.company.includes(vars.company)) h.company = vars.company;
if (h.company && h.company !== "Alone" && vars.left_squadmates != null) h.left = vars.left_squadmates === true || vars.left_squadmates === "true" ? "Leave them" : "Stay together";
if (DECISIONS.direction.includes(vars.direction)) h.direction = vars.direction;
if (DECISIONS.react.includes(vars.sighting_action)) h.react = vars.sighting_action;
if (["Red", "Brown", "Green", "Orange"].includes(vars.first_sighting)) h.fs = vars.first_sighting;
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";
@@ -618,6 +660,7 @@
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 (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";
if (vars.branch === "Passed the Red: meadow") h.valley = "Pass the Red (meadow)";
@@ -652,10 +695,14 @@
*/
function nextDecision(h) {
if (!h.company) return ["company", {}];
if (!h.direction) return ["direction", { company: h.company }];
const left = leftOf(h);
if (!left) return ["leave", { company: h.company }];
if (!h.direction) return ["direction", { company: h.company, left }];
if (!h.fs) return null;
const a = { company: h.company, direction: h.direction, fs: h.fs };
const sc = screamOf(h), cad = cadetOf(h);
// a history past the first dragon without a recorded reaction: no advice is needed for it any more
if (!h.react && !sc) return ["react", { company: h.company, left, direction: h.direction, fs: h.fs }];
if (!sc) return ["scream", a];
const h1 = { ...a, scream: sc };
let c;
@@ -686,7 +733,11 @@
if (!h.shadow) return null;
if (h.shadow === "yes") return h.shadowColour ? ["encounter", { ...d, shadow: "yes", enc: "shadow-" + h.shadowColour }] : null;
if (!h.descend) return ["descend", { ...d, shadow: "no" }];
return ["encounter", { ...d, shadow: "no", descend: h.descend, enc: h.descend.startsWith("Quickly") ? "tree-Red" : "tree-Greens" }];
if (h.descend.startsWith("Quickly")) {
if (!h.red) return ["red", { ...d, shadow: "no", descend: h.descend }];
return ["encounter", { ...d, shadow: "no", descend: h.descend, red: h.red, enc: h.red.startsWith("Jump") ? "tree-Red" : "tree-Greens" }];
}
return ["encounter", { ...d, shadow: "no", descend: h.descend, enc: "tree-Greens" }];
}
if (!h.valley) return ["valley", d];
if (h.valley === "Face the Red") return ["encounter", { ...d, valley: h.valley, enc: "valley-Red" }];
@@ -715,12 +766,15 @@
*/
function step(h) {
if (!h.company) return dec("company", {});
if (!h.direction) return dec("direction", { company: h.company });
const a0 = { company: h.company, direction: h.direction };
const left = leftOf(h);
if (!left) return dec("leave", { company: h.company });
if (!h.direction) return dec("direction", { company: h.company, left });
const a0 = { company: h.company, left, direction: h.direction };
if (!h.fs) return cha("fs", a0);
const a = { ...a0, fs: h.fs };
const riskSight = params.chance("dieSight", a).die;
const sc = screamOf(h), cad = cadetOf(h);
if (!h.react && !sc) return dec("react", { ...a0, fs: h.fs });
const riskSight = params.chance("dieSight", { ...a0, fs: h.fs, react: h.react || undefined }).die;
const a = { company: h.company, direction: h.direction, fs: h.fs };
if (!sc) return dec("scream", a, { risk: { label: "Killed at the first sighting", p: riskSight } });
const h1 = { ...a, scream: sc };
let c;
@@ -756,7 +810,10 @@
enc = "shadow-" + h.shadowColour; key = { ...d, shadow: "yes", enc };
} else {
if (!h.descend) return dec("descend", { ...d, shadow: "no" });
enc = h.descend.startsWith("Quickly") ? "tree-Red" : "tree-Greens"; key = { ...d, shadow: "no", descend: h.descend, enc };
if (h.descend.startsWith("Quickly")) {
if (!h.red) return dec("red", { ...d, shadow: "no", descend: h.descend });
enc = h.red.startsWith("Jump") ? "tree-Red" : "tree-Greens"; key = { ...d, shadow: "no", descend: h.descend, red: h.red, enc };
} else { enc = "tree-Greens"; key = { ...d, shadow: "no", descend: h.descend, enc }; }
}
} else {
if (!h.valley) return dec("valley", d);
+6 -1
View File
@@ -102,7 +102,12 @@ test("routing to one encounter: Blue only at the meadow equals the Blue policy;
test("the cadet encounter is asked in the game's order: scream, clearing or wounded cadet, the fight's moves, then the fate", () => {
const adv = S.advisor(policy, "Blue", "thisAttempt");
const base = { company: "Alone", direction: "Center", fs: "Red" };
// the first dragon: you react to it before the scream
assert.strictEqual(adv.step({ company: "Alone", direction: "Center", fs: "Red" }).var, "react");
// entering with squadmates asks whether you stay with them
assert.strictEqual(adv.step({ company: "1 Squadmate" }).var, "leave");
assert.strictEqual(adv.step({ company: "1 Squadmate", left: "Stay together" }).var, "direction");
const base = { company: "Alone", direction: "Center", fs: "Red", react: "Hold still" };
assert.strictEqual(adv.step(base).var, "scream");
// the synthetic world has no one who kept walking, so that option is (correctly) not offered
assert.deepStrictEqual(Object.keys(adv.step(base).options), ["Investigate the scream"]);
Binary file not shown.

Before

Width:  |  Height:  |  Size: 738 KiB

After

Width:  |  Height:  |  Size: 738 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 MiB

After

Width:  |  Height:  |  Size: 2.6 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 MiB

After

Width:  |  Height:  |  Size: 2.1 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 838 KiB

After

Width:  |  Height:  |  Size: 837 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 MiB

After

Width:  |  Height:  |  Size: 1.3 MiB

+5 -5
View File
File diff suppressed because one or more lines are too long
Binary file not shown.

Before

Width:  |  Height:  |  Size: 605 KiB

After

Width:  |  Height:  |  Size: 605 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 MiB

After

Width:  |  Height:  |  Size: 1.8 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 MiB

After

Width:  |  Height:  |  Size: 3.5 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 696 KiB

After

Width:  |  Height:  |  Size: 697 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 549 KiB

After

Width:  |  Height:  |  Size: 549 KiB

+8 -8
View File
@@ -4,29 +4,29 @@ become a rider
2,120
riders sent to Malek
78% of cadets were burned or killed. Deliberate deaths (2,501 runs where the rider chose to die and try again) are not counted.
93%
94%
of runs end bonded to a Red, on the best route
93% per attempt (95% 85.2%–97.9%), from riders who logged every run. At the valley Red, 72 of 77 genuine attempts bonded.
94% per attempt (95% 87.6%–97.6%), from riders who logged every run. At the valley Red, 72 of 77 genuine attempts bonded.
SEE THE ROUTE →
1 in 5
runs end bonded to a Green, on the best route
21% per attempt (95% 17.6%–25.3%), from riders who logged every run. At the two Greens, 107 of 464 genuine attempts bonded.
22% per attempt (95% 18.2%–25.7%), from riders who logged every run. At the two Greens, 107 of 464 genuine attempts bonded.
SEE THE ROUTE →
1 in 7
runs end bonded to an Orange, on the best route
15% per attempt (95% 11.4%–18.1%), from riders who logged every run. At the meadow Orange, 81 of 207 genuine attempts bonded.
15% per attempt (95% 11.9%–18.6%), from riders who logged every run. At the meadow Orange, 81 of 207 genuine attempts bonded.
SEE THE ROUTE →
1 in 11
runs end bonded to a Brown, on the best route
9.0% per attempt (95% 7.2%–11.0%), from riders who logged every run. At the meadow Brown, 74 of 272 genuine attempts bonded.
9.1% per attempt (95% 7.3%–11.0%), from riders who logged every run. At the meadow Brown, 74 of 272 genuine attempts bonded.
SEE THE ROUTE →
1 in 27
1 in 26
runs end bonded to a Blue, on the best route
3.7% per attempt (95% 2.6%–5.0%), from riders who logged every run; all form posts suggest 7.2%. At the meadow Blue, 129 of 518 genuine attempts bonded.
3.8% per attempt (95% 2.5%–5.4%), from riders who logged every run; all form posts suggest 7.3%. At the meadow Blue, 129 of 518 genuine attempts bonded.
SEE THE ROUTE →
1 in 45
runs end bonded to a Black, on the best route
2.2% per attempt (95% 0.7%–4.7%), from riders who logged every run. At the Black after the shadow, 30 of 43 genuine attempts bonded.
2.2% per attempt (95% 0.8%–4.3%), from riders who logged every run. At the Black after the shadow, 30 of 43 genuine attempts bonded.
SEE THE ROUTE →
SEVEN STEPS, TWO OF THEM PURE LUCK
How a run unfolds