Dice beside every roll; click them for the odds of each outcome
CI / test (pull_request) Successful in 44s
CI / test (pull_request) Successful in 44s
- site/atlas/dice.js: a pair of dice marks a step the game decides at random (not the rider's choice). Clicking (or Enter on) the dice opens a small popover with every outcome of that roll and its odds; Escape, scrolling or a click elsewhere closes it. Dice.html for text, Dice.svg for the maps, Dice.legend for the keys. - Route map: dice after each "game roll" heading (first sighting, encounter), with the share of riders at each outcome in the runs shown. Legend: dice and gold headings = steps the game rolls. - Valley map: dice on the "roll" / "shadow" labels of a route (the model's odds given the route so far), on the "First dragon" step of the route list, in the first-sighting card, on the guide's own roll notes (no odds: the guide gives none) and on the bot's answers that led to different screens. Legend under the route key. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UCzTd31GphpMXDhQqWrCMQ
This commit is contained in:
+15
-6
@@ -325,6 +325,13 @@
|
||||
pills.push({ g, x, y, w, h, dy: 0 });
|
||||
el("rect", { x: x - w / 2, y: y - h / 2, width: w, height: h, rx: h / 2, fill: bg, "fill-opacity": 0.95, stroke: edge || ink, "stroke-opacity": edge ? 0.95 : 0.4, "stroke-width": edge ? 2 : 1 }, g);
|
||||
el("text", { x, y: y + (strong ? 4.5 : 4), "text-anchor": "middle", "font-size": strong ? 12.5 : 11, "font-weight": strong ? 700 : 500, fill: ink, "font-family": "var(--font-data)" }, g).textContent = text;
|
||||
return { g, w };
|
||||
}
|
||||
|
||||
/** What a roll on the route can come out as: every outcome with its odds, for the dice. */
|
||||
function rollOf(s, title) {
|
||||
return { title: title || s.label || "A roll", options: Object.entries(s.probs || {}).filter(([, p]) => p > 0.0005),
|
||||
note: "The game decides this at random. The odds are the model's, given the choices on this route so far." };
|
||||
}
|
||||
|
||||
function drawDragons(g, routesOn) {
|
||||
@@ -527,7 +534,8 @@
|
||||
if (p > 0.995) return;
|
||||
// the last roll leads straight into the dragon, whose own label sits there: put the roll under the fork point
|
||||
const at = !ro.at ? { x: ro.P.x + 34, y: ro.P.y - 22 } : ro.at === pts.length - 1 ? { x: pts[ro.at - 1].P.x, y: pts[ro.at - 1].P.y + 24 } : mid(pts[ro.at - 1].P, pts[ro.at].P, 0.38);
|
||||
pill(gLab, at.x, at.y, ro.s.var === "shadow" ? (ro.s.taken === "yes" ? `shadow ${pct(p)}` : `no shadow ${pct(p)}`) : `roll ${pct(p)}`);
|
||||
const lab = pill(gLab, at.x, at.y, ro.s.var === "shadow" ? (ro.s.taken === "yes" ? `shadow ${pct(p)}` : `no shadow ${pct(p)}`) : `roll ${pct(p)}`);
|
||||
Dice.svg(lab.g, at.x - lab.w / 2 - 14, at.y, rollOf(ro.s, ro.s.var === "shadow" ? "Does the shadow show at the tree?" : null));
|
||||
});
|
||||
// destination label
|
||||
const end = pts[pts.length - 1];
|
||||
@@ -715,7 +723,7 @@
|
||||
const sp = st.info, dir = sp.place.split(":")[1];
|
||||
const fs = st.policy ? S.makeParams(model().model.tables, { alphas: model().model.alphas }).chance("fs", { direction: dir }) : null;
|
||||
info = `<div class="ex-card"><span class="eyebrow">First sighting · ${dir === "Center" ? "forest centre" : dir.toLowerCase()}</span>
|
||||
<p class="small">The first dragon is a roll of the dice: nobody bonds here, it decides what you face next.${fs ? ` Going ${dir === "Center" ? "to the forest centre" : dir.toLowerCase()}, riders met: ${Object.entries(fs).sort((a, b) => b[1] - a[1]).filter(([, p]) => p > 0.005).map(([k, p]) => `${k} ${pct(p)}`).join(", ")}.` : ""}</p></div>`;
|
||||
<p class="small">The first dragon is a roll of the dice${fs ? ` ${Dice.html({ title: `First dragon, going ${dir === "Center" ? "to the forest centre" : dir.toLowerCase()}`, options: Object.entries(fs).filter(([, p]) => p > 0.0005), note: "The game decides which dragon you see first. Which way you went changes the odds." })}` : ""}: nobody bonds here, it decides what you face next.${fs ? ` Going ${dir === "Center" ? "to the forest centre" : dir.toLowerCase()}, riders met: ${Object.entries(fs).sort((a, b) => b[1] - a[1]).filter(([, p]) => p > 0.005).map(([k, p]) => `${k} ${pct(p)}`).join(", ")}.` : ""}</p></div>`;
|
||||
}
|
||||
return `<span class="eyebrow">Unofficial atlas · built from ${st.nRuns ? st.nRuns.toLocaleString() : "thousands of"} logged runs</span>
|
||||
<h2 id="h-valley">The valley</h2>
|
||||
@@ -784,7 +792,7 @@
|
||||
}
|
||||
const endOf = (o) => (o.end ? o.end : "continues");
|
||||
function treeList(options) {
|
||||
return `<ul>${options.map((o) => o.roll ? `<li class="roll"><em>${esc(o.roll)}</em></li>` :
|
||||
return `<ul>${options.map((o) => o.roll ? `<li class="roll">${Dice.html({ title: "A roll (from the community guide)", note: `The guide notes: ${o.roll}. It gives no odds for it.` })}<em>${esc(o.roll)}</em></li>` :
|
||||
`<li class="${o.best ? "best" : ""}${o.unconfirmed ? " pale" : ""}">${esc(o.say)}${o.pct ? ` <small>${esc(o.pct)}</small>` : ""}${o.end ? ` → <b>${esc(o.end)}</b>` : ""}${o.then ? treeList(o.then) : ""}</li>`).join("")}</ul>`;
|
||||
}
|
||||
function guideAnswers(enc) {
|
||||
@@ -798,7 +806,7 @@
|
||||
if (!E) return "";
|
||||
const next = keys[ki + 1] ? (g.encounters[keys[ki + 1]] || {}).title || "" : "";
|
||||
const steps = guidePath(E.options, st.colour, next ? next.replace(/^The /, "") : null);
|
||||
const rows = steps.map((s, i) => `<li><span class="n">${i + 1}</span><div><b>${esc(s.pick.say)}</b>${s.roll ? `<small class="ex-roll">The guide notes: ${esc(s.roll)}.</small>` : ""}
|
||||
const rows = steps.map((s, i) => `<li><span class="n">${i + 1}</span><div><b>${esc(s.pick.say)}</b>${s.roll ? `<small class="ex-roll">${Dice.html({ title: "A roll (from the community guide)", note: `The guide notes: ${s.roll}. It gives no odds for it.` })}The guide notes: ${esc(s.roll)}.</small>` : ""}
|
||||
<small>${s.pick.pct ? `the guide's rate: ${esc(s.pick.pct)}` : ""}${s.pick.unconfirmed ? " · unconfirmed" : ""}${s.pick.end ? `${s.pick.pct ? " · " : ""}${esc(s.pick.end)}` : ""}</small>
|
||||
${s.others.length ? `<details><summary>Other answers here</summary><ul>${s.others.map((o) => `<li>${esc(o.say)}${o.pct ? ` <small>${esc(o.pct)}</small>` : ""} → ${esc(endOf(o))}</li>`).join("")}</ul></details>` : ""}</div></li>`).join("");
|
||||
return `<p class="small"><b>${esc(E.title)}</b>: <em>${esc(E.scene)}</em>${E.warning ? ` <span class="ex-warn">${esc(E.warning)}</span>` : ""}</p>
|
||||
@@ -831,7 +839,7 @@
|
||||
const others = Object.entries(sc.options).filter(([k]) => k !== p.option).map(([, o]) =>
|
||||
`<li>${esc(o.text)} <small>${o.n ? `died ${died(o)} of ${o.n}` : "untested"}</small></li>`).join("");
|
||||
return `<li><span class="n">${i + 1}</span><div><b>${esc(p.text)}</b>
|
||||
<small>${me.n ? `got through ${lived} of ${me.n} times` : ""}${me.kind === "fixed" && me.n ? " · always the same so far" : me.kind === "dice" ? " · a roll" : ""}</small>
|
||||
<small>${me.n ? `got through ${lived} of ${me.n} times` : ""}${me.kind === "fixed" && me.n ? " · always the same so far" : me.kind === "dice" ? ` · a roll ${Dice.html({ title: p.text, n: me.n, options: Object.entries(me.to || {}).map(([k, o]) => [k === "DIED" ? "died" : k.startsWith("BONDED") ? k.replace("BONDED_", "bonded ").toLowerCase() : (t.screens[k] ? `then: ${t.screens[k].stage.toLowerCase().replace(/_/g, " ")}${t.screens[k].tint ? ` (${t.screens[k].tint})` : ""}` : k), o.n / me.n]), note: "The same answer led to different screens in the bot's runs: the game rolled." })}` : ""}</small>
|
||||
${others ? `<details><summary>Other answers here</summary><ul>${others}</ul></details>` : ""}</div></li>`;
|
||||
}).join("");
|
||||
const end = Object.keys((t.screens[picks[picks.length - 1].screen] || { options: {} }).options[picks[picks.length - 1].option]?.to || {}).find((k) => k.startsWith("BONDED"));
|
||||
@@ -855,7 +863,7 @@
|
||||
<b>${pct(r.value.x)}</b><small>${st.colour === "Black" ? "on a first attempt" : "per attempt"} · ${bond}${n < 30 ? ` · only ${n} attempts logged` : ""}${r.value.o > 0.005 ? ` · ends on another dragon ${pct(r.value.o)}` : ""}</small></button>`;
|
||||
};
|
||||
const steps = focus.steps.filter((s) => s.kind === "decision" || s.kind === "chance").map((s) => {
|
||||
if (s.kind === "chance") return `<li class="chance"><span>${esc(s.label)}</span><b>${esc(String(s.taken))}</b><small>roll ${pct(s.probs[s.taken])}</small></li>`;
|
||||
if (s.kind === "chance") return `<li class="chance"><span>${esc(s.label)} ${Dice.html(rollOf(s))}</span><b>${esc(String(s.taken))}</b><small>roll ${pct(s.probs[s.taken])}</small></li>`;
|
||||
const open = st.expanded === s.var;
|
||||
const opts = open ? `<div class="ex-opts">${Object.entries(s.options).sort((a, c) => c[1].pX - a[1].pX).map(([v, val]) =>
|
||||
`<button type="button" class="ex-opt${v === s.taken ? " on" : ""}" data-var="${s.var}" data-v="${esc(v)}"><span>${esc(v)}${v === s.choice ? ' <em class="rec">best</em>' : ""}</span><b>${pct(val.pX)}</b></button>`).join("")}</div>` : "";
|
||||
@@ -871,6 +879,7 @@
|
||||
${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>
|
||||
<p class="small muted">${Dice.legend()}</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. ${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>
|
||||
|
||||
Reference in New Issue
Block a user