From 83bc19521e416b5dbd9492b4fc93316d91242100 Mon Sep 17 00:00:00 2001 From: ekcSchiano Date: Mon, 2 Nov 2026 20:50:59 +0000 Subject: [PATCH] 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 Claude-Session: https://claude.ai/code/session_01UCzTd31GphpMXDhQqWrCMQ --- apps/atlas/explorer.js | 40 ++- apps/atlas/index.html | 3 +- data/public/policy.json | 2 +- docs/POLICY.md | 598 +++++++++++++++++++--------------- packages/core/src/graph.js | 11 +- packages/core/src/solver.js | 107 ++++-- tests/solver.test.js | 7 +- undefined/desktop-data.png | Bin 755741 -> 755846 bytes undefined/desktop-deep.png | Bin 2685449 -> 2685466 bytes undefined/desktop-dragons.png | Bin 2214500 -> 2214747 bytes undefined/desktop-odds.png | Bin 857932 -> 857442 bytes undefined/desktop-valley.png | Bin 1365778 -> 1365906 bytes undefined/log.json | 10 +- undefined/phone-data.png | Bin 619492 -> 619657 bytes undefined/phone-deep.png | Bin 1936603 -> 1936969 bytes undefined/phone-dragons.png | Bin 3688894 -> 3689010 bytes undefined/phone-odds.png | Bin 712623 -> 713622 bytes undefined/phone-valley.png | Bin 561783 -> 561813 bytes undefined/text-odds.txt | 16 +- 19 files changed, 471 insertions(+), 323 deletions(-) diff --git a/apps/atlas/explorer.js b/apps/atlas/explorer.js index 8bf46cd..1497d91 100644 --- a/apps/atlas/explorer.js +++ b/apps/atlas/explorer.js @@ -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 @@ ${chooser()}
+ ${st.blocked ? `

Your choices so far can't reach a ${st.colour} dragon.

` : ""}
${routes.map(card).join("")}

best route under half as likely under a tenth · line width: chance you are still on the route

${esc(ENC_NAME[focus.enc])}: step by step
    ${steps}
-

Diamonds on the map are choices: click one to see where the other options lead. Changed your mind?

+

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? `}

Why this route?

Best route for any ${st.colour}: ${pct(b.pX.mean)} 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)}.

Each roll's odds may depend on your earlier choices, as far as the data support it. Choices marked "no clear winner" in Deep Dive are within the noise.${risks.length ? ` Risks on this route: ${risks.join(", ")}.` : ""}

@@ -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); diff --git a/apps/atlas/index.html b/apps/atlas/index.html index 4cdf393..3670792 100644 --- a/apps/atlas/index.html +++ b/apps/atlas/index.html @@ -672,10 +672,11 @@ adjusted OR = exp(βⱼ), 95% CI = exp(βⱼ ± 1.96·SEⱼ)