Valley map: progressive disclosure of choices
The idle map shows only the key moments (the entrance, the three directions, the scream, the bully fight, the wounded cadet, the hour's walk, the tree, the valley centre, the meadow and the shadow). Clicking one reveals the choices made there as places on the map and as chips in the panel (each a further place to start from, with a way back), plus the best route to every dragon. A picked dragon shows only the places on its routes; opening a choice adds the others. 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
83bc19521e
commit
0b025af0f0
+56
-10
@@ -54,12 +54,32 @@
|
||||
const c = L[k].colour;
|
||||
SPOTS.push({ place: k, first: true, colour: c, pose: FIRST_POSE[c], sc: 0.2, flip: L[k].x > 500 });
|
||||
});
|
||||
// every place a choice can lead to is on the map from the start, so no option is hidden until a route is drawn
|
||||
const LANDMARKS = ["comp:Alone", "comp:1 Squadmate", "comp:2 Squadmates", "dir:West", "dir:Center", "dir:East", "scream", "bully", "away", "wounded",
|
||||
"res:Killed the bullies yourself", "res:Squadmate's revenge", "res:Left bullies to the dragons",
|
||||
"res:Tourniquet", "res:Left injured cadet", "res:Took their weapons",
|
||||
"fork:West", "fork:Forest", "fork:East", "hour", "tree", "valley", "meadow", "stream"];
|
||||
const LANDMARK_NAME = { "dir:West": "West, toward the scent", "dir:Center": "Forest centre", "dir:East": "East, toward the roar", "fork:Forest": "The fork" };
|
||||
// Progressive disclosure: the idle map shows only the key moments. Clicking one reveals the choices made there
|
||||
// (and the best route to every dragon from it); a picked dragon shows only its path and the choices taken on it.
|
||||
const KEY = ["dir:West", "dir:Center", "dir:East", "scream", "bully", "wounded", "hour", "tree", "valley", "meadow", "stream"];
|
||||
const FATES = ["res:Killed the bullies yourself", "res:Squadmate's revenge", "res:Left bullies to the dragons"];
|
||||
const FORKS = ["fork:West", "fork:Forest", "fork:East"];
|
||||
const CHILDREN = {
|
||||
gate: ["comp:Alone", "comp:1 Squadmate", "comp:2 Squadmates"],
|
||||
bully: ["away"].concat(FATES),
|
||||
wounded: ["res:Tourniquet", "res:Left injured cadet", "res:Took their weapons"],
|
||||
...Object.fromEntries(FATES.map((f) => [f, FORKS])),
|
||||
};
|
||||
const PARENT = {};
|
||||
for (const [p, kids] of Object.entries(CHILDREN)) kids.forEach((k) => { if (!PARENT[k]) PARENT[k] = p; });
|
||||
/** Places drawn on the idle map: the key moments, plus the choices at (and around) the place you picked. */
|
||||
function visiblePlaces() {
|
||||
const ids = new Set(KEY);
|
||||
let p = st.point;
|
||||
if (p) {
|
||||
ids.add(p);
|
||||
(CHILDREN[p] || []).forEach((k) => ids.add(k));
|
||||
// the way here: each earlier choice point with its alternatives, so you can switch
|
||||
for (let q = PARENT[p]; q; q = PARENT[q]) { ids.add(q); (CHILDREN[q] || []).forEach((k) => ids.add(k)); }
|
||||
}
|
||||
return ids;
|
||||
}
|
||||
const LANDMARK_NAME = { gate: "The entrance", "dir:West": "West, toward the scent", "dir:Center": "Forest centre", "dir:East": "East, toward the roar", "fork:Forest": "The fork" };
|
||||
|
||||
/* ---------- state ---------- */
|
||||
const st = {
|
||||
@@ -84,6 +104,7 @@
|
||||
// face next ("at"). Choices before it that are not listed stay free, and the best play is assumed for them.
|
||||
const INV = "Investigate the scream", HELPC = "Help your squadmate";
|
||||
const POINTS = {
|
||||
gate: { force: {}, at: "company" },
|
||||
"comp:Alone": { force: { company: "Alone" }, at: "direction" },
|
||||
"comp:1 Squadmate": { force: { company: "1 Squadmate" }, at: "direction" },
|
||||
"comp:2 Squadmates": { force: { company: "2 Squadmates" }, at: "direction" },
|
||||
@@ -372,7 +393,8 @@
|
||||
}
|
||||
|
||||
function drawLandmarks(g, onRoute) {
|
||||
const ids = new Set(LANDMARKS);
|
||||
// with a dragon picked: only the places on its routes (opened choices add theirs)
|
||||
const ids = st.colour ? new Set() : visiblePlaces();
|
||||
onRoute.forEach((id) => { if (L[id] && L[id].kind !== "dragon") ids.add(id); });
|
||||
ids.forEach((id) => {
|
||||
const P = L[id];
|
||||
@@ -396,7 +418,18 @@
|
||||
hit.addEventListener("keydown", (e) => { if (e.key === "Enter" || e.key === " ") { e.preventDefault(); go(); } });
|
||||
}
|
||||
});
|
||||
el("text", { x: GATE.x, y: GATE.y + 14, "text-anchor": "middle", "font-size": 11, "letter-spacing": "0.16em", fill: PAPER.ink, "font-family": "var(--font-label)", "paint-order": "stroke", stroke: PAPER.halo, "stroke-width": 3 }, g).textContent = "ENTER THE VALLEY";
|
||||
const gt = el("text", { x: GATE.x, y: GATE.y + 14, "text-anchor": "middle", "font-size": 11, "letter-spacing": "0.16em", fill: PAPER.ink, "font-family": "var(--font-label)", "paint-order": "stroke", stroke: PAPER.halo, "stroke-width": 3 }, g);
|
||||
gt.textContent = "ENTER THE VALLEY";
|
||||
if (!st.colour && st.policy) {
|
||||
// the entrance is a key moment too: who you go in with
|
||||
const hit = el("g", { class: "ex-place", tabindex: 0, role: "button", "aria-label": "The entrance: who you enter with, and the best way to every dragon" }, g);
|
||||
el("rect", { x: GATE.x - 70, y: GATE.y - 2, width: 140, height: 22, fill: "transparent" }, hit);
|
||||
hit.appendChild(gt);
|
||||
el("title", {}, hit).textContent = "The entrance: who you enter with";
|
||||
const go = () => { st.point = st.point === "gate" ? null : "gate"; st.info = null; writeHash(); render(); };
|
||||
hit.addEventListener("click", go);
|
||||
hit.addEventListener("keydown", (e) => { if (e.key === "Enter" || e.key === " ") { e.preventDefault(); go(); } });
|
||||
}
|
||||
}
|
||||
|
||||
function drawTraffic(g) {
|
||||
@@ -624,12 +657,23 @@
|
||||
}
|
||||
return `<span class="eyebrow">Unofficial atlas · built from ${st.runs ? st.runs.length.toLocaleString() : "thousands of"} logged runs</span>
|
||||
<h2 id="h-valley">The valley</h2>
|
||||
<p class="small muted">Every dragon is drawn where riders meet it. The fainter it is, the fewer riders reach it. Choose one to see every way to it, and how likely each is. Or click a place name on the map to see your best chance at each dragon from there.</p>
|
||||
<p class="small muted">Every dragon is drawn where riders meet it. The fainter it is, the fewer riders reach it. Choose one to see its best route and the choices on it. Or click a key moment on the map, including the entrance, to see the choices you make there and your best chance at each dragon from it.</p>
|
||||
${chooser()}${info}
|
||||
${trafficToggle()}
|
||||
<p class="small muted">Prefer the numbers? <a href="#odds">The Odds</a> has the statistics behind the map.</p>`;
|
||||
}
|
||||
|
||||
const placeName = (id) => LANDMARK_NAME[id] || (L[id] && L[id].name) || id;
|
||||
/** The choices made at the picked place, each a further place to start from, and the way back up. */
|
||||
function choicesHere() {
|
||||
const kids = (CHILDREN[st.point] || []).filter((k) => POINTS[k]);
|
||||
const up = PARENT[st.point];
|
||||
if (!kids.length && !up) return "";
|
||||
return `<div class="ex-here">${kids.length ? `<span class="eyebrow">Your choices here</span>
|
||||
<div class="ex-here-row">${kids.map((k) => `<button type="button" class="ex-chip" data-pt="${esc(k)}">${esc((L[k] && L[k].name) || placeName(k))}</button>`).join("")}</div>` : ""}
|
||||
${up ? `<button type="button" class="linklike" data-pt="${esc(up)}">← Back to ${esc(placeName(up).toLowerCase())}</button>` : ""}</div>`;
|
||||
}
|
||||
|
||||
function panelFrom(list) {
|
||||
const name = LANDMARK_NAME[st.point] || (L[st.point] && L[st.point].name) || st.point;
|
||||
const top = Math.max(1e-12, ...list.map((x) => x.v || 0));
|
||||
@@ -641,7 +685,8 @@
|
||||
<div><span class="eyebrow">Starting from</span><h2 id="h-valley">${esc(name)}</h2></div>
|
||||
<button type="button" class="ex-close" id="ex-clear-point" aria-label="Back to the whole valley">×</button></div>
|
||||
${POINTS[st.point].note ? `<p class="small">${esc(POINTS[st.point].note)}</p>` : ""}
|
||||
<p class="small muted">If you are here, this is your best chance of bonding each dragon from here on, playing the best route after this point. Earlier rolls are averaged over the ways of getting here. Pick a dragon to follow its route step by step.</p>
|
||||
<p class="small muted">From here, this is your best chance of bonding each dragon from here on, playing the best route after this point. Earlier rolls are averaged over the ways of getting here. Pick a dragon to follow its route step by step.</p>
|
||||
${choicesHere()}
|
||||
<div class="ex-from">${rows}</div>
|
||||
<div class="seg" role="group" aria-label="Goal"><button type="button" data-o="eventually" aria-pressed="${st.objective === "eventually"}">Only this dragon</button><button type="button" data-o="thisAttempt" aria-pressed="${st.objective === "thisAttempt"}">Best odds this run</button></div>
|
||||
${trafficToggle()}`;
|
||||
@@ -699,6 +744,7 @@
|
||||
$$("[data-s]", p).forEach((b) => b.addEventListener("click", () => { st.sample = b.dataset.s; render(); }));
|
||||
const tr = $("#ex-traffic", p); if (tr) tr.addEventListener("change", () => { st.traffic = tr.checked; render(); });
|
||||
const cl = $("#ex-clear", p); if (cl) cl.addEventListener("click", () => select(null));
|
||||
$$("[data-pt]", p).forEach((b) => b.addEventListener("click", () => { st.point = b.dataset.pt; writeHash(); render(); }));
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user