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:
co-authored by
Claude Opus 5.5
parent
c2dcaee16f
commit
83bc19521e
+27
-13
@@ -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);
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user