Release pass: wording, colour-blind-safe colours, map visibility, phone layout

Walked every tab on desktop and phone, clicked every link and button:
- Colours: new map inks and page colours, checked with simulated
  protanopia/deuteranopia/tritanopia (worst pair ~12 CIEDE2000, was 1.4 for
  Red/Green on the map and 9.7 for Orange/Brown on the page). Map label text
  is always dark ink; dragon colour goes on borders. docs/COLOURS.md and
  research/python/check_colours.py.
- Valley map: dragons get a paper halo and a visibility floor (faded ones never
  drop below 0.3; bonding dragons start at 0.5); "no shadow" roll labelled
  correctly.
- Wording: methods updated (strata, the newer form's questions, missing
  answers, a new section on the solver, The Odds cards and genuine attempts);
  findings use readable factor names and no longer claim a date adjustment;
  'Load a newer route export above'; code links include solver.js and
  explorer.js; The Odds shows 93% instead of '1 in 1'.
- Deep Dive route map treats all six dragons alike ('Bond a dragon' row,
  default 'Bond any dragon'; rare sightings separate).
- Phone: Deep Dive no longer overflows (sections and selects can shrink).
- scripts/qa/crawl.js and mapcheck.js for future release checks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UCzTd31GphpMXDhQqWrCMQ
This commit is contained in:
ekcSchiano
2026-11-02 17:57:51 +00:00
co-authored by Claude Opus 5.5
parent 0ac5dfd971
commit 7366af2f7d
11 changed files with 236 additions and 27 deletions
+10
View File
@@ -105,3 +105,13 @@ stratified by the same factors. The page's Methods section has the details.
Code: MIT (`LICENSE`). Data produced by this project: CC BY 4.0 (`DATA_LICENSE.md`), which also lists Code: MIT (`LICENSE`). Data produced by this project: CC BY 4.0 (`DATA_LICENSE.md`), which also lists
third-party sources that keep their own terms. third-party sources that keep their own terms.
## Release checks
```
npm test # parity and unit tests
python research/python/check_colours.py # dragon colours stay distinguishable (docs/COLOURS.md)
npm run build && python3 -m http.server 8765 -d dist &
node scripts/qa/crawl.js /tmp/qa # every tab on desktop and phone: text, links, buttons, errors, overflow
node scripts/qa/mapcheck.js /tmp/qa # every dragon's routes: off-map labels, overlaps, too-faint dragons
```
+9 -8
View File
@@ -9,7 +9,7 @@
const state = { const state = {
raw: null, bundled: null, allRuns: [], runs: [], res: null, missing: [], raw: null, bundled: null, allRuns: [], runs: [], res: null, missing: [],
filters: { source: "all", goal: "all", excludeFlagged: false }, filters: { source: "all", goal: "all", excludeFlagged: false },
target: "bond_Blue", widthMode: "traffic", minN: 10, conds: {}, target: "bond_any", widthMode: "traffic", minN: 10, conds: {},
fxOutcome: "blue_meadow", fxFactor: "resolution", rtTarget: "see_Blue", rtMin: 10, fxOutcome: "blue_meadow", fxFactor: "resolution", rtTarget: "see_Blue", rtMin: 10,
}; };
@@ -148,7 +148,7 @@
const biasShown = chaseB && bulkB && chaseB.n >= 20 && bulkB.n >= 20 && chaseB.lo > bulkB.hi; const biasShown = chaseB && bulkB && chaseB.n >= 20 && bulkB.n >= 20 && chaseB.lo > bulkB.hi;
let t; let t;
if (biasShown) { if (biasShown) {
t = `<p><b>The meadow Blue appeared in ${rateTxt(cb.overall)} of logged meadow visits, but that figure is inflated.</b> Players chasing a Blue report it in ${pct(chaseB.p)} of their visits. Bulk logs, which record every run, show ${rateTxt(bulkB)}. The game cannot see what you are chasing, so that gap comes from which runs get reported.</p>`; t = `<p><b>The meadow Blue appeared in ${rateTxt(cb.overall)} of logged meadow visits, but that figure is inflated.</b> Players chasing a rare dragon report it in ${pct(chaseB.p)} of their visits. Bulk logs, which record every run, show ${rateTxt(bulkB)}. The game cannot see what you are chasing, so that gap comes from which runs get reported.</p>`;
t += `<p>A realistic expectation is nearer the bulk-log rate, about one meadow visit in ${Math.round(1 / Math.max(bulkB.p, 0.001))}, than the headline figure.${otherB ? ` Form players who were not chasing a Blue report ${pct(otherB.p)}, which still carries some selective reporting.` : ""}</p>`; t += `<p>A realistic expectation is nearer the bulk-log rate, about one meadow visit in ${Math.round(1 / Math.max(bulkB.p, 0.001))}, than the headline figure.${otherB ? ` Form players who were not chasing a Blue report ${pct(otherB.p)}, which still carries some selective reporting.` : ""}</p>`;
} else { } else {
t = `<p><b>The meadow Blue appeared in ${rateTxt(cb.overall)} of logged meadow visits in the current selection.</b> Compare the data-source filter settings to see how much this depends on who logged the runs.</p>`; t = `<p><b>The meadow Blue appeared in ${rateTxt(cb.overall)} of logged meadow visits in the current selection.</b> Compare the data-source filter settings to see how much this depends on who logged the runs.</p>`;
@@ -161,9 +161,9 @@
const rk = E.rankRoutes(state.runs, "see_Blue", state.rtMin); const rk = E.rankRoutes(state.runs, "see_Blue", state.rtMin);
const adjSig = rk.rows.filter((x) => x.mh_q !== undefined && x.mh_q < 0.05); const adjSig = rk.rows.filter((x) => x.mh_q !== undefined && x.mh_q < 0.05);
let t = sig.length let t = sig.length
? `<p><b>After adjusting for reporting bias, ${sig.length === 1 ? "one recorded choice was" : sig.length + " recorded choices were"} linked to the Blue appearing:</b> ${sig.map((s) => `${esc(s.term)} (OR ${fmtOR(s.or)}, 95% CI ${fmtOR(s.lo)}–${fmtOR(s.hi)}, p = ${fmtP(s.p)})`).join("; ")}.</p>` ? `<p><b>After adjusting for reporting bias, ${sig.length === 1 ? "one recorded choice was" : sig.length + " recorded choices were"} linked to the Blue appearing:</b> ${sig.map((s) => `${esc(labelFactor(s.factor))}: ${esc(s.level)} (OR ${fmtOR(s.or)}, 95% CI ${fmtOR(s.lo)}–${fmtOR(s.hi)}, p = ${fmtP(s.p)})`).join("; ")}.</p>`
: `<p><b>No recorded route choice changed the chance of the Blue appearing once reporting bias is held fixed.</b> Direction, first sighting, how you handled the cadet and who you entered with all have adjusted odds ratios whose 95% intervals include 1 (n = ${mb.n} meadow visits).</p>`; : `<p><b>No recorded route choice changed the chance of the Blue appearing once reporting bias is held fixed.</b> Direction, first sighting, how you handled the cadet and who you entered with all have adjusted odds ratios whose 95% intervals include 1 (n = ${mb.n} meadow visits).</p>`;
t += `<p>Of ${rk.n_routes_tested} full routes with at least ${state.rtMin} meadow visits, ${adjSig.length} beat the others after adjustment and correction for multiple testing. The "precise pathways" shared on Reddit may still matter through choices the form does not record, such as how you react to the first dragon.</p>`; t += `<p>Of ${rk.n_routes_tested} full routes with at least ${state.rtMin} meadow visits, ${adjSig.length} beat the others after adjustment and correction for multiple testing. The "precise pathways" shared on Reddit may still matter through choices the form does not record, such as the answers given inside each encounter.</p>`;
out.push(["blue", "Blue", t]); out.push(["blue", "Blue", t]);
} }
if (encBlue && encBlue.overall.n) { if (encBlue && encBlue.overall.n) {
@@ -186,7 +186,7 @@
const ms = r.models.shadow; const ms = r.models.shadow;
let t = `<p><b>Shadow leads to test, not established:</b> ${sh.map((x) => `<i>${esc(labelFactor(x.factor))}: ${esc(x.level)}</i> had the shadow in ${rateTxt(x)} vs the rest (OR ${fmtOR(x.or)}, q = ${fmtP(x.q)})`).join("; ")}.</p>`; let t = `<p><b>Shadow leads to test, not established:</b> ${sh.map((x) => `<i>${esc(labelFactor(x.factor))}: ${esc(x.level)}</i> had the shadow in ${rateTxt(x)} vs the rest (OR ${fmtOR(x.or)}, q = ${fmtP(x.q)})`).join("; ")}.</p>`;
const att = ms && ms.terms.find((tm) => tm.factor === "attempt" && tm.level === "First attempt"); const att = ms && ms.terms.find((tm) => tm.factor === "attempt" && tm.level === "First attempt");
if (att) t += `<p>The first-attempt pattern survives adjustment for source, goal, direction and date (OR ${fmtOR(att.or)}, 95% CI ${fmtOR(att.lo)}–${fmtOR(att.hi)}). That matches a theory on Reddit that a fresh account rolls the shadow more often, but players who strike lucky on a first run may also be more likely to submit the form.</p>`; if (att) t += `<p>The first-attempt pattern survives adjustment for data source, chase goal and direction (OR ${fmtOR(att.or)}, 95% CI ${fmtOR(att.lo)}–${fmtOR(att.hi)}). That matches a theory on Reddit that a fresh account rolls the shadow more often, but players who strike lucky on a first run may also be more likely to submit the form.</p>`;
t += `<p>The cheapest test is a bulk log that records every tree climb, including the dull ones, with these choices noted.</p>`; t += `<p>The cheapest test is a bulk log that records every tree climb, including the dull ones, with these choices noted.</p>`;
out.push(["lead", "Lead", t]); out.push(["lead", "Lead", t]);
} }
@@ -208,14 +208,15 @@
const labelFactor = (f) => FACTOR_LABEL[f] || f; const labelFactor = (f) => FACTOR_LABEL[f] || f;
// ------------------------------------------------------------ route map // ------------------------------------------------------------ route map
const RARE_T = ["bond_Blue", "bond_Black", "see_Blue", "see_shadow"]; // first row: bonding each dragon (all six treated alike); second row: the two rare sightings
const OTHER_T = ["bond_Red", "bond_Green", "bond_Orange", "bond_Brown", "bond_any"]; const RARE_T = ["bond_Red", "bond_Orange", "bond_Brown", "bond_Green", "bond_Blue", "bond_Black", "bond_any"];
const OTHER_T = ["see_Blue", "see_shadow"];
function renderTargets() { function renderTargets() {
const chip = (t, featured) => { const chip = (t, featured) => {
const c = E.TARGETS[t].color ? DRAGON_VAR[E.TARGETS[t].color] : "--dr-any"; const c = E.TARGETS[t].color ? DRAGON_VAR[E.TARGETS[t].color] : "--dr-any";
return `<button type="button" class="tchip${featured ? " featured" : ""}" data-t="${t}" aria-pressed="${state.target === t}" style="--c: var(${c})"><span class="sw"></span>${esc(E.TARGETS[t].label)}</button>`; return `<button type="button" class="tchip${featured ? " featured" : ""}" data-t="${t}" aria-pressed="${state.target === t}" style="--c: var(${c})"><span class="sw"></span>${esc(E.TARGETS[t].label)}</button>`;
}; };
$("#targets-rare").innerHTML = RARE_T.map((t) => chip(t, t.startsWith("bond"))).join(""); $("#targets-rare").innerHTML = RARE_T.map((t) => chip(t, false)).join("");
$("#targets-other").innerHTML = OTHER_T.map((t) => chip(t, false)).join(""); $("#targets-other").innerHTML = OTHER_T.map((t) => chip(t, false)).join("");
$$(".tchip[data-t]").forEach((b) => b.addEventListener("click", () => { state.target = b.dataset.t; $("#best-routes").innerHTML = ""; renderTargets(); renderMap(); })); $$(".tchip[data-t]").forEach((b) => b.addEventListener("click", () => { state.target = b.dataset.t; $("#best-routes").innerHTML = ""; renderTargets(); renderMap(); }));
} }
+11 -6
View File
@@ -188,9 +188,11 @@
const mx = (A.x + B.x) / 2 - (B.y - A.y) * bend, my = (A.y + B.y) / 2 + (B.x - A.x) * bend; const mx = (A.x + B.x) / 2 - (B.y - A.y) * bend, my = (A.y + B.y) / 2 + (B.x - A.x) * bend;
return { x: (1 - t) ** 2 * A.x + 2 * (1 - t) * t * mx + t * t * B.x, y: (1 - t) ** 2 * A.y + 2 * (1 - t) * t * my + t * t * B.y }; return { x: (1 - t) ** 2 * A.x + 2 * (1 - t) * t * mx + t * t * B.x, y: (1 - t) ** 2 * A.y + 2 * (1 - t) * t * my + t * t * B.y };
}; };
function pill(g, x, y, text, { ink = PAPER.ink, strong = false, bg = PAPER.halo } = {}) { // 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 } = {}) {
const w = 10 + text.length * (strong ? 7.2 : 6.4), h = strong ? 20 : 17; const w = 10 + text.length * (strong ? 7.2 : 6.4), h = strong ? 20 : 17;
el("rect", { x: x - w / 2, y: y - h / 2, width: w, height: h, rx: h / 2, fill: bg, "fill-opacity": 0.95, stroke: ink, "stroke-opacity": 0.4 }, g); 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; 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;
} }
@@ -201,15 +203,18 @@
const P = L[sp.place]; const P = L[sp.place];
if (!P) return; if (!P) return;
const n = st.counts[sp.place]; const n = st.counts[sp.place];
let op = n == null ? 0.85 : 0.22 + 0.78 * Math.sqrt(n / (sp.first ? maxF : maxN)); // faint = rarely met, but never so faint it disappears (bonding dragons keep a higher floor)
let op = n == null ? 0.85 : (sp.first ? 0.35 : 0.5) + (sp.first ? 0.65 : 0.5) * Math.sqrt(n / (sp.first ? maxF : maxN));
const isTarget = st.colour && !sp.first && (encColour(sp.enc) === st.colour || RESCUE[st.colour] === sp.enc); const isTarget = st.colour && !sp.first && (encColour(sp.enc) === st.colour || RESCUE[st.colour] === sp.enc);
if (st.colour && !isTarget) op *= 0.35; if (st.colour && !isTarget) op = Math.max(0.3, op * 0.5); // faded, but never lost
if (isTarget) op = Math.max(op, 0.9); if (isTarget) op = Math.max(op, 0.9);
const w = 200 * sp.sc, hgt = 160 * sp.sc; const w = 200 * sp.sc, hgt = 160 * sp.sc;
const x = P.x - w / 2 + (sp.dx || 0), y = P.y - hgt * 0.7 + (sp.dy || 0); const x = P.x - w / 2 + (sp.dx || 0), y = P.y - hgt * 0.7 + (sp.dy || 0);
const gg = el("g", { class: "ex-dragon", transform: `translate(${x} ${y}) scale(${sp.sc})`, opacity: op.toFixed(2), tabindex: sp.twin ? null : 0, role: sp.twin ? null : "button", const gg = el("g", { class: "ex-dragon", transform: `translate(${x} ${y}) scale(${sp.sc})`, opacity: op.toFixed(2), tabindex: sp.twin ? null : 0, role: sp.twin ? null : "button",
"aria-label": sp.first ? `${sp.colour} dragon, first sighting` : `${ENC_NAME[sp.enc]}. Show the routes to it.` }, g); "aria-label": sp.first ? `${sp.colour} dragon, first sighting` : `${ENC_NAME[sp.enc]}. Show the routes to it.` }, g);
if (isTarget && routesOn) el("ellipse", { cx: 100, cy: 140, rx: 80, ry: 16, fill: INK[sp.colour], "fill-opacity": 0.25 }, gg); if (isTarget && routesOn) el("ellipse", { cx: 100, cy: 140, rx: 80, ry: 16, fill: INK[sp.colour], "fill-opacity": 0.25 }, gg);
// a soft paper-coloured halo keeps dark dragons readable on the dark canopy
gg.innerHTML += `<g stroke="${PAPER.halo}" stroke-width="9" stroke-linejoin="round" opacity="0.55">${D.svg(sp.pose, { fill: PAPER.halo, eyeFill: PAPER.halo, flip: sp.flip })}</g>`;
gg.innerHTML += D.svg(sp.pose, { fill: INK[sp.colour], flip: sp.flip }); gg.innerHTML += D.svg(sp.pose, { fill: INK[sp.colour], flip: sp.flip });
el("rect", { x: 0, y: 0, width: 200, height: 160, fill: "transparent" }, gg); el("rect", { x: 0, y: 0, width: 200, height: 160, fill: "transparent" }, gg);
if (sp.twin) return; if (sp.twin) return;
@@ -318,11 +323,11 @@
if (p > 0.995) return; 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 // 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); 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" ? `shadow ${pct(p)}` : `roll ${pct(p)}`); pill(gLab, at.x, at.y, ro.s.var === "shadow" ? (ro.s.taken === "yes" ? `shadow ${pct(p)}` : `no shadow ${pct(p)}`) : `roll ${pct(p)}`);
}); });
// destination label // destination label
const end = pts[pts.length - 1]; const end = pts[pts.length - 1];
pill(gLab, end.P.x, end.P.y + 30, `${pct(r.value.x)} per attempt`, { ink: tc, strong: rel === 1 }); pill(gLab, end.P.x, end.P.y + 30, `${pct(r.value.x)} per attempt`, { edge: tc, strong: rel === 1 });
// choice points on the focused route // choice points on the focused route
if (focus) marks.forEach((m) => { if (focus) marks.forEach((m) => {
if (!m.at || m.s.var === "encounter") return; if (!m.at || m.s.var === "encounter") return;
+16 -10
View File
@@ -10,7 +10,7 @@
color-scheme: dark; color-scheme: dark;
--bg: #170911; --surface: #210f19; --raised: #2a1420; --ink: #f6e8d6; --muted: #cba890; --faint: #8e7069; --line: #4b2a36; --bg: #170911; --surface: #210f19; --raised: #2a1420; --ink: #f6e8d6; --muted: #cba890; --faint: #8e7069; --line: #4b2a36;
--accent: #e8b483; --accent-ink: #1d0a12; --good: #8fc98a; --warn: #f0a55a; --bad: #ef6b6b; --accent: #e8b483; --accent-ink: #1d0a12; --good: #8fc98a; --warn: #f0a55a; --bad: #ef6b6b;
--dr-red: #e4566d; --dr-green: #84c27c; --dr-orange: #f29a4c; --dr-brown: #c8976b; --dr-blue: #82a8f2; --dr-black: #b9abd3; --dr-any: #e0a9c6; --dr-red: #e8435e; --dr-green: #3fc0a8; --dr-orange: #ff9533; --dr-brown: #d1a47a; --dr-blue: #7ea6ff; --dr-black: #e0d8ea; /* checked for colour-blind separation (see docs/COLOURS.md) */ --dr-any: #e0a9c6;
--link-low: #4f2f3c; --death: #9fb6c3; --ember: #e3692f; --death-bg: #1b0811; --frame: var(--accent); --link-low: #4f2f3c; --death: #9fb6c3; --ember: #e3692f; --death-bg: #1b0811; --frame: var(--accent);
--font-display: "Marcellus", "Iowan Old Style", Georgia, serif; --font-display: "Marcellus", "Iowan Old Style", Georgia, serif;
--font-crest: "Marcellus", "Iowan Old Style", Georgia, serif; --font-crest: "Marcellus", "Iowan Old Style", Georgia, serif;
@@ -171,6 +171,8 @@ body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-a
.tab[aria-selected="true"] { background: var(--bg); color: var(--ink); border-top-color: var(--accent); } .tab[aria-selected="true"] { background: var(--bg); color: var(--ink); border-top-color: var(--accent); }
.tab:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; } .tab:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.tabpanel { display: grid; gap: 44px; } .tabpanel { display: grid; gap: 44px; }
.tabpanel > section, .tabpanel > section > * { min-width: 0; }
select { max-width: 100%; }
.tabpanel[hidden] { display: none !important; } .tabpanel[hidden] { display: none !important; }
section h2 { font-family: var(--font-crest); letter-spacing: 0.03em; } section h2 { font-family: var(--font-crest); letter-spacing: 0.03em; }
@@ -471,11 +473,11 @@ footer { border-top-color: var(--line); }
</div> </div>
<div class="controls" id="map-controls"> <div class="controls" id="map-controls">
<div class="target-group"> <div class="target-group">
<span class="lbl small muted">Rare dragons</span> <span class="lbl small muted">Bond a dragon</span>
<div class="targets" id="targets-rare"></div> <div class="targets" id="targets-rare"></div>
</div> </div>
<div class="target-group"> <div class="target-group">
<span class="lbl small muted">Other outcomes</span> <span class="lbl small muted">Rare sightings</span>
<div class="targets" id="targets-other"></div> <div class="targets" id="targets-other"></div>
</div> </div>
</div> </div>
@@ -581,13 +583,13 @@ footer { border-top-color: var(--line); }
</section> </section>
<section id="share" aria-labelledby="h-share"> <section id="share" aria-labelledby="h-share">
<div class="section-head"><span class="eyebrow">Open by design</span><h2 id="h-share">Share &amp; reproduce</h2> <div class="section-head"><span class="eyebrow">Open by design</span><h2 id="h-share">Share &amp; reproduce</h2>
<p class="muted small">Everything on this page is recomputed in your browser from the raw form export. To update it, download the latest responses sheet (File → Download → Microsoft Excel) and load it with "Load a newer export" at the top. Column order does not matter, because questions are matched by their wording.</p></div> <p class="muted small">Everything on this page is recomputed in your browser from the raw form export. To update it, download the latest responses sheet (File → Download → Microsoft Excel) and load it with "Load a newer route export" above. Column order does not matter, because questions are matched by their wording.</p></div>
<div class="grid2"> <div class="grid2">
<div class="panel"><h3>Copy the outputs</h3> <div class="panel"><h3>Copy the outputs</h3>
<div class="btnrow"><button type="button" id="cp-reddit" class="primary">Copy Reddit post (Markdown)</button><button type="button" id="cp-csv">Copy coded runs (CSV)</button><button type="button" id="cp-json">Copy all results (JSON)</button></div> <div class="btnrow"><button type="button" id="cp-reddit" class="primary">Copy Reddit post (Markdown)</button><button type="button" id="cp-csv">Copy coded runs (CSV)</button><button type="button" id="cp-json">Copy all results (JSON)</button></div>
<p class="small muted">The Reddit post is written from the current numbers and filters.</p></div> <p class="small muted">The Reddit post is written from the current numbers and filters.</p></div>
<div class="panel"><h3>Read the code</h3> <div class="panel"><h3>Read the code</h3>
<div class="btnrow"><button type="button" data-src="engine.js">engine.js (all rules and statistics)</button><button type="button" data-src="app.js">app.js (this page)</button><button type="button" data-src="python/clean.py">clean.py</button><button type="button" data-src="python/analyze.py">analyze.py</button><button type="button" data-src="python/stats_core.py">stats_core.py</button><button type="button" data-src="register.js">register.js</button><button type="button" data-src="README.md">README</button></div> <div class="btnrow"><button type="button" data-src="engine.js">engine.js (all rules and statistics)</button><button type="button" data-src="app.js">app.js (this page)</button><button type="button" data-src="python/clean.py">clean.py</button><button type="button" data-src="python/analyze.py">analyze.py</button><button type="button" data-src="python/stats_core.py">stats_core.py</button><button type="button" data-src="solver.js">solver.js (best routes)</button><button type="button" data-src="explorer.js">explorer.js (the valley map)</button><button type="button" data-src="register.js">register.js</button><button type="button" data-src="README.md">README</button></div>
<p class="small muted">The Python files are an independent second implementation. The test scripts confirm that both produce identical coded runs and identical odds ratios, p-values and model estimates.</p> <p class="small muted">The Python files are an independent second implementation. The test scripts confirm that both produce identical coded runs and identical odds ratios, p-values and model estimates.</p>
<pre id="srcview" hidden></pre></div> <pre id="srcview" hidden></pre></div>
</div> </div>
@@ -603,7 +605,7 @@ footer { border-top-color: var(--line); }
<li><b>Cadet encounter.</b> 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)".</li> <li><b>Cadet encounter.</b> 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)".</li>
<li><b>Encounter branch.</b> A tree run with a Blue or Black recorded took the shadow. A tree run with Greens recorded descended slowly, and one with only a Red descended quickly. A valley run with an Orange, Brown or Blue recorded (or a Red marked "Changed my mind") passed the Red and reached the meadow.</li> <li><b>Encounter branch.</b> A tree run with a Blue or Black recorded took the shadow. A tree run with Greens recorded descended slowly, and one with only a Red descended quickly. A valley run with an Orange, Brown or Blue recorded (or a Red marked "Changed my mind") passed the Red and reached the meadow.</li>
<li><b>Outcome.</b> 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.</li> <li><b>Outcome.</b> 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.</li>
<li><b>Flags.</b> 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 above the map.</li> <li><b>Flags.</b> 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.</li>
</ul> </ul>
<h3>2. Rates and their uncertainty</h3> <h3>2. Rates and their uncertainty</h3>
<p>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%:</p> <p>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%:</p>
@@ -611,7 +613,7 @@ footer { border-top-color: var(--line); }
centre = (p̂ + z²/2n) / (1 + z²/n) centre = (p̂ + z²/2n) / (1 + z²/n)
half = z·√(p̂(1−p̂)/n + z²/4n²) / (1 + z²/n) half = z·√(p̂(1−p̂)/n + z²/4n²) / (1 + z²/n)
CI = centre ± half</div> CI = centre ± half</div>
<p>With 0 events in n runs, the upper end is still informative. For example, 0 shadows in 367 bulk-log tree climbs gives an upper bound near 1.0%.</p> <p>With 0 events in n runs, the upper end is still informative. For example, 0 shadows in a few hundred bulk-log tree climbs still gives an upper bound near 1%.</p>
</div> </div>
<div class="method"> <div class="method">
<h3>3. Comparing choices</h3> <h3>3. Comparing choices</h3>
@@ -627,18 +629,22 @@ q = Benjamini–Hochberg: sort p, q(i) = min over j≥i of p(j)·m/j</div>
<div class="formula">logit P(event) = β₀ + Σ βⱼ·xⱼ (x = 0/1 indicators; reference = most common answer) <div class="formula">logit P(event) = β₀ + Σ βⱼ·xⱼ (x = 0/1 indicators; reference = most common answer)
fitted by Newton–Raphson with a small ridge penalty λ = 1 on the slopes fitted by Newton–Raphson with a small ridge penalty λ = 1 on the slopes
adjusted OR = exp(βⱼ), 95% CI = exp(βⱼ ± 1.96·SEⱼ)</div> adjusted OR = exp(βⱼ), 95% CI = exp(βⱼ ± 1.96·SEⱼ)</div>
<p>The ridge penalty keeps estimates finite when an answer has 0 events. It shrinks extreme odds ratios slightly toward 1, which makes the model more cautious. Route rankings use the Mantel–Haenszel odds ratio across four strata (bulk logs, form runs chasing Blue, chasing Black, everything else) for the same reason.</p> <p>The ridge penalty keeps estimates finite when an answer has 0 events. It shrinks extreme odds ratios slightly toward 1, which makes the model more cautious. Route rankings use the Mantel–Haenszel odds ratio across strata of data source and chase goal (bulk logs; form runs chasing Blue, Black, or "Blue or Black" on the newer form; everything else) for the same reason.</p>
<h3>5. What this data cannot tell you</h3> <h3>5. What this data cannot tell you</h3>
<ul> <ul>
<li>It is self-reported and self-selected. Runs worth bragging about are over-represented, and that inflates every rare-dragon rate. Bulk logs are the least selected rows.</li> <li>It is self-reported and self-selected. Runs worth bragging about are over-represented, and that inflates every rare-dragon rate. Bulk logs are the least selected rows.</li>
<li>Runs are not independent. One player may log dozens of runs, and the form has no player ID, so intervals are somewhat too narrow.</li> <li>Runs are not independent. One player may log dozens of runs, and the form has no player ID, so intervals are somewhat too narrow.</li>
<li>The form records only stage-level choices. It does not record how you reacted to the first dragon (lower eyes, hold still…) or most choices inside an encounter, so route claims that depend on those cannot be tested here.</li> <li>The form records mostly stage-level choices. The newer form asks how you reacted to the first dragon, but most riders answer "unsure", and it does not record the answers given inside a bonding encounter, so route claims that depend on those cannot be tested here.</li>
<li>The form records dragons you <i>attempted</i>. A player who saw the Blue but chose the Orange would not record the Blue, so Blue sightings are slightly undercounted.</li> <li>The form records dragons you <i>attempted</i>. A player who saw the Blue but chose the Orange would not record the Blue, so Blue sightings are slightly undercounted.</li>
<li>Step-by-step survival inside an encounter comes from the community PDF, which coded the free-text answers by hand. It is shown as published and cannot be recomputed here.</li> <li>Step-by-step survival inside an encounter comes from the community PDF, which coded the free-text answers by hand. It is shown as published and cannot be recomputed here.</li>
</ul> </ul>
</div> </div>
</div> </div>
<h3>Missing answers</h3> <h3>6. Best routes, the valley map and The Odds</h3>
<p class="small">The valley map and The Odds come from a solver (<code>solver.js</code>) 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.</p>
<p class="small">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.</p>
<p class="small">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.</p>
<h3>Missing answers</h3>
<p class="small">"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.</p> <p class="small">"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.</p>
</section> </section>
</div> </div>
+2 -2
View File
@@ -133,7 +133,7 @@
let policyP = null; let policyP = null;
const getPolicy = () => policyP || (policyP = fetch("data/policy.json").then((r) => r.json()).catch(() => null)); const getPolicy = () => policyP || (policyP = fetch("data/policy.json").then((r) => r.json()).catch(() => null));
const ENC_OF = { Red: "valley-Red", Orange: "meadow-Orange", Brown: "meadow-Brown", Green: "tree-Greens", Blue: "meadow-Blue", Black: "shadow-Black" }; const ENC_OF = { Red: "valley-Red", Orange: "meadow-Orange", Brown: "meadow-Brown", Green: "tree-Greens", Blue: "meadow-Blue", Black: "shadow-Black" };
const ENC_LABEL = { "valley-Red": "the valley Red", "meadow-Orange": "the meadow Orange", "meadow-Brown": "the meadow Brown", "tree-Greens": "the two Greens", "meadow-Blue": "the meadow Blue", "shadow-Black": "the Black, after the shadow" }; const ENC_LABEL = { "valley-Red": "the valley Red", "meadow-Orange": "the meadow Orange", "meadow-Brown": "the meadow Brown", "tree-Greens": "the two Greens", "meadow-Blue": "the meadow Blue", "shadow-Black": "the Black after the shadow" };
const POSE = { Red: "roaring", Orange: "flying", Brown: "resting", Green: "prowling", Blue: "coiled", Black: "flying" }; const POSE = { Red: "roaring", Orange: "flying", Brown: "resting", Green: "prowling", Blue: "coiled", Black: "flying" };
function renderColourOdds(policy) { function renderColourOdds(policy) {
@@ -147,7 +147,7 @@
$("#odds-colours").innerHTML = cols.map(({ c, p, pAll, lo, hi }) => { $("#odds-colours").innerHTML = cols.map(({ c, p, pAll, lo, hi }) => {
const e = enc(c); const e = enc(c);
return `<a class="odd odd-colour" href="#valley/${c.toLowerCase()}" style="--c: var(${DV[c]})">${art(c)} return `<a class="odd odd-colour" href="#valley/${c.toLowerCase()}" style="--c: var(${DV[c]})">${art(c)}
<span class="big">1 in ${oneIn(p)}</span><span class="what">runs end bonded to ${/^[AEIOU]/.test(c) ? "an" : "a"} ${c}, on the best route</span> <span class="big">${p >= 0.5 ? pct(p) : `1 in ${oneIn(p)}`}</span><span class="what">${p >= 0.5 ? "of runs" : "runs"} end bonded to ${/^[AEIOU]/.test(c) ? "an" : "a"} ${c}, on the best route</span>
${dots(Math.round(p * 1000), 1000, cssVar(DV[c]))} ${dots(Math.round(p * 1000), 1000, cssVar(DV[c]))}
<span class="how">${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.</span> <span class="how">${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.</span>
<span class="go">See the route →</span></a>`; <span class="go">See the route →</span></a>`;
+2 -1
View File
@@ -13,7 +13,8 @@
const pct = (p, d = 0) => (p === null || p === undefined || isNaN(p) ? "–" : (p * 100).toFixed(d) + "%"); const pct = (p, d = 0) => (p === null || p === undefined || isNaN(p) ? "–" : (p * 100).toFixed(d) + "%");
const DV = { Red: "--dr-red", Green: "--dr-green", Orange: "--dr-orange", Brown: "--dr-brown", Blue: "--dr-blue", Black: "--dr-black" }; const DV = { Red: "--dr-red", Green: "--dr-green", Orange: "--dr-orange", Brown: "--dr-brown", Blue: "--dr-blue", Black: "--dr-black" };
// painted-map dragon inks (darker than the UI tones so they read on gold paper) // painted-map dragon inks (darker than the UI tones so they read on gold paper)
const INK = { Red: "#b8293f", Green: "#3f7a3a", Orange: "#d06a1c", Brown: "#7a4e2e", Blue: "#2f5fb8", Black: "#2a2230" }; // chosen so every pair stays distinguishable under common colour-vision deficiencies (docs/COLOURS.md)
const INK = { Red: "#cc3346", Green: "#2f8f6f", Orange: "#e08a2a", Brown: "#4e3020", Blue: "#2a58b8", Black: "#22182a" };
const PAPER = { ink: "#3b2416", halo: "#f6e6c4", trailLow: "#8a6446", death: "#c4471c" }; const PAPER = { ink: "#3b2416", halo: "#f6e6c4", trailLow: "#8a6446", death: "#c4471c" };
function el(tag, attrs = {}, parent) { function el(tag, attrs = {}, parent) {
const e = document.createElementNS(NS, tag); const e = document.createElementNS(NS, tag);
+32
View File
@@ -0,0 +1,32 @@
# Dragon colours
Two palettes, one per background. Both were chosen so that every pair of dragon colours stays distinguishable for
readers with the common colour-vision deficiencies, not only with normal vision. Check them with:
```
python research/python/check_colours.py
```
It reports CIEDE2000 colour differences for every pair under normal vision and simulated protanopia, deuteranopia and
tritanopia (Machado et al. 2009, full severity), and the contrast of each colour against its background.
| Dragon | Map ink (on the painted valley), `valley.js` `INK` | Page colour (on the dark page), `index.html` `--dr-*` |
|---|---|---|
| Red | `#cc3346` | `#e8435e` |
| Orange | `#e08a2a` | `#ff9533` |
| Brown | `#4e3020` | `#d1a47a` |
| Green | `#2f8f6f` (a blue-leaning green) | `#3fc0a8` |
| Blue | `#2a58b8` | `#7ea6ff` |
| Black | `#22182a` | `#e0d8ea` (silver, so it shows on the dark page) |
**Before this check**, the map's Red and Green were nearly identical under deuteranopia (difference 1.4), and on the dark
page Orange and Brown were too close even for normal vision (9.7). The worst pair is now about 12–13 on both palettes
(roughly "clearly different side by side").
What still relies on more than colour, on purpose:
- every dragon also has its own pose and sits in its own place on the map, and every route and card is labelled with
the dragon's name;
- text on the map is always dark ink; the dragon colour is used for lines, silhouettes and label borders only
(Orange and Green are too light to read as text on the paper background);
- silhouettes carry a paper-coloured halo so dark dragons stay visible on the dark canopy.
+42
View File
@@ -0,0 +1,42 @@
"""check_colours.py: are the dragon colours (valley.js INK, index.html --dr-*) still distinguishable?
python research/python/check_colours.py
"""
"""Pairwise CIEDE2000 between dragon colours, normal vision and simulated colour-vision deficiencies (Machado 2009, severity 1),
plus contrast against the backgrounds they sit on."""
import itertools, sys
import numpy as np
from skimage.color import rgb2lab, deltaE_ciede2000
MAP = {"Red": "#cc3346", "Orange": "#e08a2a", "Brown": "#4e3020", "Green": "#2f8f6f", "Blue": "#2a58b8", "Black": "#22182a"}
UI = {"Red": "#e8435e", "Orange": "#ff9533", "Brown": "#d1a47a", "Green": "#3fc0a8", "Blue": "#7ea6ff", "Black": "#e0d8ea"}
if len(sys.argv) > 1: # candidate palettes passed as name=hex,...
for arg in sys.argv[1:]:
k, v = arg.split(":", 1)
d = dict(x.split("=") for x in v.split(","))
(MAP if k == "map" else UI).update(d)
BG = {"map paper": "#e9c88f", "map canopy": "#6c6b40", "ui dark": "#210f19"}
M = { # Machado et al. 2009, severity 1.0, applied in linear RGB
"protan": [[0.152286, 1.052583, -0.204868], [0.114503, 0.786281, 0.099216], [-0.003882, -0.048116, 1.051998]],
"deutan": [[0.367322, 0.860646, -0.227968], [0.280085, 0.672501, 0.047413], [-0.011820, 0.042940, 0.968881]],
"tritan": [[1.255528, -0.076749, -0.178779], [-0.078411, 0.930809, 0.147602], [0.004733, 0.691367, 0.303900]],
}
def rgb(h): h = h.lstrip("#"); return np.array([int(h[i:i + 2], 16) for i in (0, 2, 4)]) / 255
def lin(c): return np.where(c <= 0.04045, c / 12.92, ((c + 0.055) / 1.055) ** 2.4)
def unlin(c): c = np.clip(c, 0, 1); return np.where(c <= 0.0031308, c * 12.92, 1.055 * c ** (1 / 2.4) - 0.055)
def sim(c, kind): return c if kind == "normal" else unlin(np.array(M[kind]) @ lin(c))
def lab(c): return rgb2lab(c.reshape(1, 1, 3)).reshape(3)
def de(a, b): return float(deltaE_ciede2000(lab(a), lab(b)))
def lum(c): l = lin(c); return 0.2126 * l[0] + 0.7152 * l[1] + 0.0722 * l[2]
def contrast(a, b): x, y = sorted([lum(a), lum(b)], reverse=True); return (x + 0.05) / (y + 0.05)
for name, P in [("MAP (on paper)", MAP), ("UI (on dark)", UI)]:
print(f"\n== {name}: pairs with CIEDE2000 < 20 under any vision (flag), worst first")
rows = []
for a, b in itertools.combinations(P, 2):
ds = {k: de(sim(rgb(P[a]), k), sim(rgb(P[b]), k)) for k in ["normal", "protan", "deutan", "tritan"]}
rows.append((min(ds.values()), a, b, ds))
for m, a, b, ds in sorted(rows):
if m < 20: print(f" {a:6} vs {b:6} " + " ".join(f"{k} {v:5.1f}" for k, v in ds.items()))
print(" contrast vs backgrounds:")
for c in P:
print(f" {c:6} " + " ".join(f"{bg} {contrast(rgb(P[c]), rgb(h)):.1f}" for bg, h in BG.items() if (bg.startswith('map') if P is MAP else bg.startswith('ui'))))
+1
View File
@@ -3,3 +3,4 @@ numpy>=1.24
scipy>=1.10 scipy>=1.10
openpyxl>=3.1 openpyxl>=3.1
pypdf>=4.0 pypdf>=4.0
scikit-image>=0.20
+70
View File
@@ -0,0 +1,70 @@
// QA crawl: every tab, text dump, links, buttons, console errors. node crawl.js <outdir>
const { chromium } = require("playwright");
const fs = require("fs");
const OUT = process.argv[2];
const BASE = "http://localhost:8765/";
(async () => {
const b = await chromium.launch();
const log = { errors: [], links: [], buttons: [], tabs: {} };
for (const [vpName, vp] of [["desktop", { width: 1440, height: 1000 }], ["phone", { width: 390, height: 844 }]]) {
const p = await b.newPage({ viewport: vp });
p.on("pageerror", (e) => log.errors.push(`${vpName} pageerror: ${e.message}`));
p.on("console", (m) => { if (m.type() === "error" && !/net::ERR|Failed to load resource/.test(m.text())) log.errors.push(`${vpName} console: ${m.text()}`); });
for (const t of ["valley", "odds", "dragons", "deep", "data"]) {
await p.goto(BASE + "#" + t); await p.waitForTimeout(t === "valley" ? 2500 : 1800);
// open every <details> so hidden text is reviewed too
await p.$$eval(`#panel-${t} details`, (ds) => ds.forEach((d) => (d.open = true)));
await p.waitForTimeout(300);
await p.screenshot({ path: `${OUT}/${vpName}-${t}.png`, fullPage: true });
if (vpName === "desktop") {
log.tabs[t] = await p.evaluate((t) => document.querySelector("#panel-" + t).innerText, t);
const links = await p.$$eval(`#panel-${t} a[href], header a[href], footer a[href]`, (as) => as.map((a) => ({ text: a.innerText.trim().slice(0, 60), href: a.getAttribute("href") })));
links.forEach((l) => log.links.push({ tab: t, ...l }));
const btns = await p.$$eval(`#panel-${t} button`, (bs) => bs.map((x) => x.innerText.trim().replace(/\s+/g, " ").slice(0, 50)));
log.buttons.push({ tab: t, n: btns.length, sample: [...new Set(btns)].slice(0, 40) });
}
// overflow check
const sw = await p.evaluate(() => document.documentElement.scrollWidth);
if (sw > vp.width + 1) log.errors.push(`${vpName} ${t}: horizontal overflow ${sw}px`);
}
await p.close();
}
// click every button in every tab (desktop), checking for errors after each
const p = await b.newPage({ viewport: { width: 1440, height: 1000 } });
p.on("pageerror", (e) => log.errors.push(`click pageerror: ${e.message}`));
for (const t of ["valley", "odds", "dragons", "deep", "data"]) {
await p.goto(BASE + "#" + t); await p.waitForTimeout(2000);
const n = await p.$$eval(`#panel-${t} button`, (bs) => bs.length);
let clicked = 0;
for (let i = 0; i < Math.min(n, 120); i++) {
const bs = await p.$$(`#panel-${t} button`);
if (!bs[i]) continue;
const vis = await bs[i].isVisible();
if (!vis) continue;
const label = (await bs[i].innerText()).trim().slice(0, 40);
if (/download|copy/i.test(label)) continue;
try { await bs[i].click({ timeout: 1500 }); clicked++; await p.waitForTimeout(120); } catch (e) { log.errors.push(`${t}: could not click "${label}": ${e.message.split("\n")[0]}`); }
const cur = await p.evaluate(() => location.hash);
if (!cur.startsWith("#" + t)) { await p.goto(BASE + "#" + t); await p.waitForTimeout(1200); }
}
log.tabs[t + "_clicked"] = clicked;
}
// in-page links
await p.goto(BASE); await p.waitForTimeout(2000);
for (const l of log.links.filter((x) => x.href.startsWith("#"))) {
await p.goto(BASE + "#" + l.tab); await p.waitForTimeout(800);
const el = await p.$(`#panel-${l.tab} a[href="${l.href}"]`);
if (!el || !(await el.isVisible())) continue;
await el.click(); await p.waitForTimeout(800);
const sel = await p.evaluate(() => document.querySelector("[role=tab][aria-selected=true]").id);
const target = l.href.slice(1).split("/")[0];
const exists = await p.evaluate((id) => !!document.getElementById(id) || ["valley","odds","dragons","deep","data"].includes(id), target);
l.result = `${sel}${exists ? "" : " MISSING TARGET"}`;
}
fs.writeFileSync(`${OUT}/log.json`, JSON.stringify(log, null, 1));
for (const [t, txt] of Object.entries(log.tabs)) if (typeof txt === "string") fs.writeFileSync(`${OUT}/text-${t}.txt`, txt);
console.log("errors:", log.errors.length, log.errors.slice(0, 20));
console.log("clicked:", Object.entries(log.tabs).filter(([k]) => k.endsWith("_clicked")));
console.log("links:"); log.links.forEach((l) => console.log(" ", l.tab, "|", l.text, "|", l.href, "|", l.result || ""));
await b.close();
})();
+41
View File
@@ -0,0 +1,41 @@
// Valley map QA: for idle and every dragon/route, find text or labels that overlap, fall outside the map, or are too faint.
const { chromium } = require("playwright");
const OUT = process.argv[2];
(async () => {
const b = await chromium.launch();
const p = await b.newPage({ viewport: { width: 1440, height: 1000 } });
const states = [["idle", "#valley"]];
for (const c of ["red", "orange", "brown", "green", "blue", "black"]) states.push([c, "#valley/" + c]);
const extra = { blue: ["shadow-Blue"], red: ["tree-Red"], orange: ["tree-Greens"], brown: ["tree-Greens"] };
for (const [c, encs] of Object.entries(extra)) encs.forEach((e) => states.push([c + "/" + e, `#valley/${c}/${e}`]));
for (const [name, hash] of states) {
await p.goto("http://localhost:8765/" + hash); await p.waitForTimeout(1800);
const res = await p.evaluate(() => {
const svg = document.querySelector("#ex-map"), S = svg.getBoundingClientRect();
const items = [];
svg.querySelectorAll("text").forEach((t) => {
const r = t.getBoundingClientRect();
if (!r.width) return;
// walk up for opacity
let op = 1; for (let e = t; e && e !== svg; e = e.parentElement) op *= parseFloat(getComputedStyle(e).opacity || 1) * parseFloat(e.getAttribute("fill-opacity") || 1);
items.push({ kind: "text", txt: t.textContent.trim(), r: { l: r.left, t: r.top, rr: r.right, b: r.bottom }, op });
});
const out = [], over = [];
items.forEach((a) => { if (a.r.l < S.left - 1 || a.r.rr > S.right + 1 || a.r.t < S.top - 1 || a.r.b > S.bottom + 1) out.push(a.txt); });
for (let i = 0; i < items.length; i++) for (let j = i + 1; j < items.length; j++) {
const A = items[i].r, B = items[j].r;
const ix = Math.min(A.rr, B.rr) - Math.max(A.l, B.l), iy = Math.min(A.b, B.b) - Math.max(A.t, B.t);
if (ix > 3 && iy > 3 && items[i].txt !== items[j].txt) over.push(`"${items[i].txt}" × "${items[j].txt}"`);
}
const dragons = [...svg.querySelectorAll(".ex-dragon")].map((d) => ({ l: d.getAttribute("aria-label") || "twin", op: +d.getAttribute("opacity") })).filter((d) => d.op < 0.3);
const card = document.querySelector(".ex-route-card.on");
return { out, over, faint: dragons.map((d) => `${d.l.split(".")[0]} ${d.op}`), focus: card ? card.innerText.split("\n")[0] : "" };
});
console.log(`\n[${name}] ${res.focus}`);
if (res.out.length) console.log(" outside:", res.out.join(" | "));
if (res.over.length) console.log(" overlaps:", [...new Set(res.over)].join(" | "));
if (res.faint.length) console.log(" faint (<0.3):", res.faint.join(" | "));
await p.locator("#ex-map").screenshot({ path: `${OUT}/map-${name.replace("/", "_")}.png` });
}
await b.close();
})();