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);
|
||||
|
||||
Reference in New Issue
Block a user