diff --git a/apps/atlas/explorer.js b/apps/atlas/explorer.js index 3c08568..13adc87 100644 --- a/apps/atlas/explorer.js +++ b/apps/atlas/explorer.js @@ -190,8 +190,11 @@ }; // label text is always dark ink (light dragon colours like Orange are unreadable as text on paper); // the dragon's colour goes on the border instead - function pill(g, x, y, text, { ink = PAPER.ink, edge = null, strong = false, bg = PAPER.halo } = {}) { + let pills = []; // every label drawn this render, so overlapping ones can be pushed apart afterwards + function pill(g0, x, y, text, { ink = PAPER.ink, edge = null, strong = false, bg = PAPER.halo } = {}) { const w = 10 + text.length * (strong ? 7.2 : 6.4), h = strong ? 20 : 17; + const g = el("g", {}, g0); + 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; } @@ -272,8 +275,9 @@ if (!P || P.kind === "dragon") return; const strong = onRoute.has(id); el("circle", { cx: P.x, cy: P.y, r: strong ? 6 : 4.5, fill: PAPER.ink, "fill-opacity": strong ? 0.95 : 0.7, stroke: PAPER.halo, "stroke-width": 2 }, g); - const right = (P.lab || "right") !== "left"; - const t = el("text", { x: P.x + (right ? 10 : -10), y: P.y + 4, "text-anchor": right ? "start" : "end", "font-family": "var(--font-display)", "font-size": strong ? 14 : 13, + // small choice points sit close together, so they honour "above" as well as left/right + const pos = P.kind === "small" && P.lab === "above" ? "above" : (P.lab || "right") === "left" ? "left" : "right"; + const t = el("text", { x: P.x + (pos === "right" ? 10 : pos === "left" ? -10 : 0), y: P.y + (pos === "above" ? -10 : 4), "text-anchor": pos === "right" ? "start" : pos === "left" ? "end" : "middle", "font-family": "var(--font-display)", "font-size": strong ? 14 : 13, fill: PAPER.ink, "fill-opacity": strong ? 1 : 0.8, "paint-order": "stroke", stroke: PAPER.halo, "stroke-width": 3.5, "stroke-linejoin": "round" }, g); t.textContent = LANDMARK_NAME[id] || P.name; }); @@ -345,8 +349,9 @@ if (!pid || !L[pid] || v === m.s.taken) return; const B = L[pid], rel2 = val.pX / best2; const p = el("path", { d: curve(P, B, 0.1), fill: "none", stroke: tc, "stroke-width": 2 + 4 * rel2, "stroke-opacity": 0.35 + 0.5 * rel2, "stroke-dasharray": "6 6", "stroke-linecap": "round", class: "ex-alt", tabindex: 0, role: "button", "aria-label": `${v}: ${pct(val.pX)}. Take this instead.` }, gLab); - const m2 = mid(P, B, 0.72, 0.1); - pill(gLab, m2.x, m2.y, `${v.length > 18 ? v.slice(0, 17) + "…" : v} ${pct(val.pX)}`); + // the option's own place is labelled on the map, so its chance sits just under that place + onRoute.add(pid); + pill(gLab, B.x, B.y + 17, pct(val.pX)); const pick = () => choose(m.s.var, v); p.addEventListener("click", pick); p.addEventListener("keydown", (e) => { if (e.key === "Enter" || e.key === " ") { e.preventDefault(); pick(); } }); @@ -357,6 +362,26 @@ return onRoute; } + /** Push overlapping labels apart vertically (a few relaxation passes), so no two chances sit on top of each other. */ + function spreadPills() { + const gap = 3; + for (let pass = 0; pass < 30; pass++) { + let moved = false; + for (let i = 0; i < pills.length; i++) for (let j = i + 1; j < pills.length; j++) { + const a = pills[i], b = pills[j]; + const ox = Math.min(a.x + a.w / 2, b.x + b.w / 2) - Math.max(a.x - a.w / 2, b.x - b.w / 2); + const ay = a.y + a.dy, by = b.y + b.dy; + const oy = Math.min(ay + a.h / 2, by + b.h / 2) - Math.max(ay - a.h / 2, by - b.h / 2); + if (ox > 0 && oy > -gap) { + const push = (oy + gap) / 2, down = by >= ay ? 1 : -1; + a.dy -= push * down; b.dy += push * down; moved = true; + } + } + if (!moved) break; + } + pills.forEach((p) => { if (p.dy) p.g.setAttribute("transform", `translate(0 ${p.dy.toFixed(1)})`); }); + } + /* ---------- tooltip ---------- */ function showTip(e, html) { const t = $("#ex-tip"); t.innerHTML = html; t.hidden = false; moveTip(e); } function moveTip(e) { @@ -500,7 +525,9 @@ return r; }).sort((a, b) => b.value.x - a.value.x); if (!st.focus || !routes.some((r) => r.enc === st.focus)) st.focus = routes[0].enc; + pills = []; onRoute = drawRoutes(gRoute, gLab, routes); + spreadPills(); } drawLandmarks(gLand, onRoute); drawScenery(gScene, onRoute); diff --git a/apps/atlas/index.html b/apps/atlas/index.html index f8ccfa0..7470bd8 100644 --- a/apps/atlas/index.html +++ b/apps/atlas/index.html @@ -229,7 +229,7 @@ section h2 { font-family: var(--font-crest); letter-spacing: 0.03em; } .dcard svg { width: 64px; height: 64px; } .dcard .nm { font-family: var(--font-crest); font-weight: 700; font-size: 1rem; letter-spacing: 0.03em; overflow-wrap: anywhere; } .dcard .meta { font-size: 12px; color: var(--muted); line-height: 1.35; } -.dcard .age { position: absolute; top: 8px; right: 10px; font-family: var(--font-data); font-size: 11px; color: var(--muted); } +.dcard .age { position: absolute; top: 34px; right: 16px; font-family: var(--font-data); font-size: 11px; color: var(--muted); } .viewtoggle { display: inline-flex; } /* ---------- dusk & gold theme layer ---------- */ @@ -387,6 +387,18 @@ footer { border-top-color: var(--line); } .ladder li i { display: block; height: 10px; border-radius: 4px; width: var(--w); background: var(--c); } .ladder li b { font-family: var(--font-data); text-align: right; } .combo { grid-template-columns: minmax(0, 1fr); } + +/* prose uses the full width of its column (it looked cramped on wide screens) */ +p, .lede, .lore, .method p, .method li { max-width: none; } +footer p + p { margin-top: 8px; } +a { color: var(--accent); text-underline-offset: 2px; } +/* methods as tabs */ +.mtabs { display: flex; flex-wrap: wrap; gap: 6px; border-bottom: 1px solid var(--line); padding-bottom: 10px; } +.mtab { border-radius: 999px; padding: 7px 14px; font-size: .7rem; background: transparent; } +.mtab[aria-selected="true"] { background: color-mix(in srgb, var(--accent) 22%, var(--raised)); border-color: var(--accent); color: var(--ink); } +.mpanel { padding: 18px 20px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); } +.mpanel[hidden] { display: none; } +.mpanel h3 { margin: 0; }
@@ -434,7 +446,7 @@ footer { border-top-color: var(--line); }

How a run unfolds

-

In the books, first-years who survive to Threshing walk into a valley of unbonded dragons, and the dragons do the choosing. The Dragonkind site recreates that: every choice can end with you incinerated, and the author has said there is a 10% chance of that no matter what you pick.

+

In the books, first-years who survive to Threshing walk into a valley of unbonded dragons, and the dragons do the choosing. The Dragonkind site recreates that: every choice can end with you incinerated, and the author has said there is a 10% chance of that no matter what you pick.

@@ -596,10 +608,10 @@ footer { border-top-color: var(--line); }
How every number is made

Methods

-
-
-

1. From form answers to runs

-

Each row of the "Threshing Routes" form (and each row pasted in from players' own logs) is one threshing run. The page reads the raw export and codes every row with the same fixed rules, which are visible in engine.js:

+
+
+

1. From form answers to runs

+

Each row of the "Threshing Routes" form (and each row pasted in from players' own logs) is one threshing run. The page reads the raw export and codes every row with the same fixed rules, which are visible in engine.js:

  • Source. Rows with a real timestamp are form submissions. Rows labelled "Data Import", "Manual Upload" or "Historical import" were bulk-pasted from players' own run logs and are called bulk logs here.
  • Cadet encounter. Split into the scream choice (help, investigate and leave, or ignore) and its resolution (killed the bullies, squadmate's revenge, left them to the dragons, tourniquet, left the cadet, took their weapons). The fork in the road only exists after helping, so other branches are coded "(no fork)".
  • @@ -607,50 +619,60 @@ footer { border-top-color: var(--line); }
  • Outcome. Bonded to the one dragon marked "Bonded!". Otherwise incinerated by the last dragon marked "Incinerated" in encounter order, or died before the hour. "Saved by another" on the Greens plus a bonded Orange or Brown counts as a rescue bond.
  • Flags. Rows are flagged, not deleted, when answers contradict each other: several directions or wings, Greens in the valley, two bonds, or a first sighting outside the documented pool. You can drop flagged rows with the checkbox on Deep Dive's route map.
-

2. Rates and their uncertainty

-

A rate is k events out of n runs that could have had that event. The denominator matters. The meadow Blue rate divides by runs that reached the meadow, not by all runs. Intervals are 95% Wilson score intervals, which behave well for small n and for rates near 0%:

+
+ -
-

3. Comparing choices

-

For one answer against the rest, the 2×2 table is [a b; c d] = [event, no event] × [this answer, other answers].

+
+ + +
-

6. Best routes, the valley map and The Odds

-

The valley map and The Odds come from a solver (solver.js) that treats a run as a decision tree. Your choices are decisions (company, direction, the cadet encounter, the fork, tree or valley, how to climb down, whether to face the valley Red, and at every bonding encounter whether to attempt the bond or die on purpose). The game's rolls are chance events: which dragon appears first, whether you die at the sighting, in the fight or before the hour, whether the shadow appears and which dragon it is, which dragon waits in the meadow, and how the bonding encounter ends.

-

Each roll's probability may depend on the choices before it. It is estimated with hierarchical Dirichlet back-off: the estimate for a full history is pulled toward the estimate for a shorter history, which is pulled toward the overall rate. How strongly is chosen from the data for each roll (empirical Bayes), so the solver does not chase noise in small groups. The best route is then found by backward induction, for two goals: the chance of bonding the dragon on this attempt, and, for riders who die on purpose whenever a run goes wrong, the chance that the account eventually ends on that dragon rather than another (maximised by Dinkelbach iteration). Ranges come from 200 posterior draws; "stays best in N%" is how often the recommended choice is still best across those draws.

-

Encounter outcomes use only genuine attempts: runs where the rider wanted that colour, any dragon, or said they would not seek Malek. The two summary cards on The Odds use the same rule in reverse: runs where the rider died on purpose at an encounter they did not want are left out, so they describe cadets who went into the valley and either bonded or died. The "low-bias" numbers use only bulk logs and form runs from riders who were not chasing a rare dragon.

-

Missing answers

-

"Unsure", blank answers, conflicting answers and questions an older version of the form did not ask are treated as missing information, never as a choice. Each comparison uses the runs that answered that question; models use runs that answered every question in them (complete cases). "I've lost count" counts as a later attempt. The only exception is the chase goal used to adjust for reporting bias: runs from before that question existed stay in the models as their own adjustment group, but that group is not shown as a finding. The solver and the valley map ignore missing steps in the same way.

-
+ + + - + diff --git a/apps/atlas/register.js b/apps/atlas/register.js index 0604e63..df4b34c 100644 --- a/apps/atlas/register.js +++ b/apps/atlas/register.js @@ -42,7 +42,8 @@ const items = raw.rows.map((r, i) => ({ source: "Register form", source_url: null, submitted: str(r[C.timestamp]), cadet: str(r[C.cadet]), wing: str(r[C.wing]), section: str(r[C.section]), squad: str(r[C.squad]), - name: str(r[C.name]), lineage_raw: str(r[C.lineage]), colour: title(str(r[C.colour])), tail: tailOf(r[C.tail]), + // names typed in capitals ("RAERNUAL") are shown as names ("Raernual") + name: ((n) => (n && n.length > 1 && n === n.toUpperCase() ? n[0] + n.slice(1).toLowerCase() : n))(str(r[C.name])), lineage_raw: str(r[C.lineage]), colour: title(str(r[C.colour])), tail: tailOf(r[C.tail]), sex: title(str(r[C.sex])), age: parseInt(r[C.age], 10), flags: [], })); (raw.extra || []).forEach((e) => items.push({ diff --git a/apps/atlas/ui.js b/apps/atlas/ui.js index 5e97cac..53e4f76 100644 --- a/apps/atlas/ui.js +++ b/apps/atlas/ui.js @@ -77,6 +77,21 @@ const initial = tabOf(location.hash); showTab(initial || "valley", false, initial === "valley"); + // ------------------------------------------------------------ methods tabs (arrow keys move between them) + const mtabs = $$(".mtab"); + const showM = (b, focus) => { + mtabs.forEach((t) => { const on = t === b; t.setAttribute("aria-selected", on); t.tabIndex = on ? 0 : -1; $("#" + t.getAttribute("aria-controls")).hidden = !on; }); + if (focus) b.focus(); + }; + mtabs.forEach((b, i) => { + b.addEventListener("click", () => showM(b)); + b.addEventListener("keydown", (e) => { + if (e.key !== "ArrowRight" && e.key !== "ArrowLeft") return; + e.preventDefault(); + showM(mtabs[(i + (e.key === "ArrowRight" ? 1 : mtabs.length - 1)) % mtabs.length], true); + }); + }); + // ------------------------------------------------------------ hero art (original, generic silhouettes) function drawHero() { const svg = $("#hero-art"); @@ -149,7 +164,7 @@ return `${art(c)} ${p >= 0.5 ? pct(p) : `1 in ${oneIn(p)}`}${p >= 0.5 ? "of runs" : "runs"} end bonded to ${/^[AEIOU]/.test(c) ? "an" : "a"} ${c}, on the best route ${dots(Math.round(p * 1000), 1000, cssVar(DV[c]))} - ${pct(p, p < 0.1 ? 1 : 0)} per attempt (95% ${pct(lo, 1)}–${pct(hi, 1)}), from riders who logged every run${Math.abs(pAll - p) / p > 0.25 ? `; all form posts suggest ${pct(pAll, 1)}` : ""}. At ${ENC_LABEL[ENC_OF[c]]}, ${e.k} of ${e.n} genuine attempts bonded. + ${pct(p, p < 0.1 ? 1 : 0)} per attempt (95% ${pct(lo, 1)}–${pct(hi, 1)}), from riders who logged every run${Math.abs(pAll - p) / p > 0.25 ? `; all form posts suggest ${pct(pAll, 1)}` : ""}. At ${ENC_LABEL[ENC_OF[c]]}, ${e.k} of ${e.n} genuine attempts bonded. See the route →`; }).join(""); const meadowAlpha = all.model.alphas.meadow, shadowAlpha = all.model.alphas.shadow; diff --git a/apps/atlas/valley.js b/apps/atlas/valley.js index 02b49e1..a618722 100644 --- a/apps/atlas/valley.js +++ b/apps/atlas/valley.js @@ -55,7 +55,7 @@ "res:Left bullies to the dragons": { x: 404, y: 410, name: "Dragons decide", kind: "small", lab: "right", desc: "Leave the bullies to the dragons." }, away: { x: 500, y: 440, name: "Walked away", kind: "small", lab: "right", desc: "Investigated the scream, then left them to it." }, wounded: { x: 684, y: 462, name: "The wounded cadet", kind: "way", lab: "right", desc: "Ignore the scream and you trip over a cadet missing a leg." }, - "res:Tourniquet": { x: 600, y: 410, name: "Tourniquet", kind: "small", lab: "left", desc: "Use their belt as a tourniquet." }, + "res:Tourniquet": { x: 616, y: 410, name: "Tourniquet", kind: "small", lab: "left", desc: "Use their belt as a tourniquet." }, "res:Left injured cadet": { x: 690, y: 398, name: "Leave them", kind: "small", lab: "above", desc: "Leave them to die." }, "res:Took their weapons": { x: 780, y: 410, name: "Take their weapons", kind: "small", lab: "right", desc: "Take their weapons and go." }, "fork:West": { x: 196, y: 336, name: "West fork", kind: "way", lab: "left", desc: "After the fight, the path splits: west." },