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ⱼ)