Valley map: show the paths of all riders (per source, plus deaths); the six traced silhouettes
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
f3bbde24b7
commit
a9836c3191
+52
-7
@@ -9,7 +9,9 @@
|
||||
* 3 click a choice point on the highlighted route: its other options branch off, each with the chance it gives.
|
||||
* Picking one re-plans the route from there.
|
||||
* 4 "Why this route?" in the side panel: intervals, how often the choice stays best, low-bias numbers, risks.
|
||||
* A toggle adds the community's actual traffic underneath. The URL keeps the selection (#valley/blue/meadow-Blue).
|
||||
* "Show the paths of all riders" adds, underneath, the paths every source logged (one layer each: the sheet's form
|
||||
* posts and bulk logs, runs reported here, the bot, Discord) and the deaths (deliberate and failed), each layer with
|
||||
* its own switch; the counts come from data/stats.json `paths` (analysis/stats/site_stats.py). The URL keeps the selection (#valley/blue/meadow-Blue).
|
||||
*/
|
||||
(function () {
|
||||
"use strict";
|
||||
@@ -42,7 +44,7 @@
|
||||
{ place: "treeRed", enc: "tree-Red", colour: "Red", pose: "prowling", flip: true, sc: 0.36 },
|
||||
{ place: "greens", enc: "tree-Greens", colour: "Green", pose: "resting", sc: 0.3, dx: -16 },
|
||||
{ place: "greens", enc: "tree-Greens", colour: "Green", pose: "sitting", flip: true, sc: 0.27, dx: 20, dy: -4, twin: true },
|
||||
{ place: "black", enc: "shadow-Black", colour: "Black", pose: "flying", flip: true, sc: 0.38 },
|
||||
{ place: "black", enc: "shadow-Black", colour: "Black", pose: "sitting", flip: true, sc: 0.38 },
|
||||
{ place: "redwood", enc: "shadow-Blue", colour: "Blue", pose: "coiled", sc: 0.3 },
|
||||
{ place: "valleyRed", enc: "valley-Red", colour: "Red", pose: "roaring", sc: 0.36, dy: -12 },
|
||||
{ place: "meadow:Orange", enc: "meadow-Orange", colour: "Orange", pose: "sitting", flip: true, sc: 0.3 },
|
||||
@@ -85,7 +87,7 @@
|
||||
const st = {
|
||||
point: null, // a place picked before any dragon: show the best way from there to every dragon
|
||||
policy: null, runs: null, counts: {}, colour: null, focus: null, expanded: null, over: {},
|
||||
objective: "eventually", sample: "all", traffic: false, cache: new Map(), pendingHash: null, info: null,
|
||||
objective: "eventually", sample: "all", traffic: false, layers: {}, paths: null, cache: new Map(), pendingHash: null, info: null,
|
||||
};
|
||||
const model = () => st.policy.samples[st.sample];
|
||||
function advisorFor(enc, colour = st.colour) {
|
||||
@@ -432,8 +434,17 @@
|
||||
}
|
||||
}
|
||||
|
||||
// "Show the paths of all riders": one ink per layer (data/stats.json paths.layers; measures.yaml path_layers)
|
||||
const LAYER_INK = {
|
||||
form: "#6b4a33", bulk: "#2f6b57", reported: "#7a4f8f", bot: "#28588a", discord: "#5865f2",
|
||||
died_deliberate: "#7d8794", died_failed: "#c2410c",
|
||||
};
|
||||
const isDeath = (k) => k.startsWith("died_");
|
||||
const layerOn = (k) => st.layers[k] !== false; // every layer starts on
|
||||
|
||||
function drawTraffic(g) {
|
||||
// how many logged runs went from each place to the next (precomputed in data/stats.json)
|
||||
if (st.paths && st.paths.layers) return drawLayers(g, st.paths.layers);
|
||||
// older stats.json: how many logged runs went from each place to the next (precomputed in data/stats.json)
|
||||
if (!st.edges) return;
|
||||
const max = Math.max(1, ...st.edges.map((e) => e[2]));
|
||||
st.edges.forEach(([a, b, n]) => {
|
||||
@@ -442,6 +453,29 @@
|
||||
});
|
||||
}
|
||||
|
||||
/** Every layer that is switched on, side by side; the death layers dashed, with a mark where their runs ended. */
|
||||
function drawLayers(g, layers) {
|
||||
const shown = layers.filter((l) => l.runs && layerOn(l.key));
|
||||
const max = Math.max(1, ...shown.flatMap((l) => l.edges.map((e) => e[2])));
|
||||
shown.forEach((l, i) => {
|
||||
const off = (i - (shown.length - 1) / 2) * 6, ink = LAYER_INK[l.key] || "#6b4a33", death = isDeath(l.key);
|
||||
l.edges.forEach(([a, b, n]) => {
|
||||
if (!L[a] || !L[b]) return;
|
||||
el("path", { d: curve(L[a], L[b], 0.05, off), fill: "none", stroke: ink, "stroke-opacity": death ? 0.5 : 0.38,
|
||||
"stroke-width": 1.2 + 16 * Math.sqrt(n / max), "stroke-linecap": death ? "butt" : "round", "stroke-dasharray": death ? "10 6" : null }, g);
|
||||
});
|
||||
if (death && l.ends) {
|
||||
const emax = Math.max(1, ...Object.values(l.ends));
|
||||
Object.entries(l.ends).forEach(([p, n]) => {
|
||||
if (!L[p]) return;
|
||||
const r = 3 + 11 * Math.sqrt(n / emax), x = L[p].x + off, y = L[p].y;
|
||||
el("circle", { cx: x, cy: y, r, fill: ink, "fill-opacity": 0.35, stroke: ink, "stroke-width": 1.5 }, g);
|
||||
el("path", { d: `M${x - r * 0.5},${y - r * 0.5}L${x + r * 0.5},${y + r * 0.5}M${x + r * 0.5},${y - r * 0.5}L${x - r * 0.5},${y + r * 0.5}`, stroke: ink, "stroke-width": 1.5 }, g);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function drawRoutes(gRoute, gLab, routes) {
|
||||
const best = Math.max(1e-12, ...routes.map((r) => r.value.x));
|
||||
const onRoute = new Set();
|
||||
@@ -633,8 +667,17 @@
|
||||
|
||||
/* ---------- panel ---------- */
|
||||
const mini = (c, pose = "sitting") => `<svg viewBox="0 0 200 160" aria-hidden="true">${D.svg(pose, { fill: `var(${DV[c]})`, eyeFill: "var(--bg)" })}</svg>`;
|
||||
const POSE_OF = { Red: "roaring", Orange: "flying", Brown: "resting", Green: "prowling", Blue: "coiled", Black: "flying" };
|
||||
const trafficToggle = () => `<label class="ex-toggle"><input type="checkbox" id="ex-traffic"${st.traffic ? " checked" : ""}> Show where riders actually went</label>`;
|
||||
const POSE_OF = { Red: "roaring", Orange: "flying", Brown: "resting", Green: "prowling", Blue: "coiled", Black: "sitting" };
|
||||
const UNROUTED = { "reddit thread": "Reddit result pages", register: "the Dragon Register" };
|
||||
function trafficToggle() {
|
||||
const box = `<label class="ex-toggle"><input type="checkbox" id="ex-traffic"${st.traffic ? " checked" : ""}> Show the paths of all riders</label>`;
|
||||
if (!st.traffic || !st.paths || !st.paths.layers) return box;
|
||||
const rows = st.paths.layers.map((l) => `<label class="ex-layer${l.runs ? "" : " none"}"><input type="checkbox" data-layer="${esc(l.key)}"${l.runs && layerOn(l.key) ? " checked" : ""}${l.runs ? "" : " disabled"}>
|
||||
<span class="sw${isDeath(l.key) ? " dash" : ""}" style="--sw: ${LAYER_INK[l.key] || "#6b4a33"}"></span><span>${esc(l.label)}</span><span class="n">${l.runs ? l.runs.toLocaleString() : "none yet"}</span></label>`).join("");
|
||||
const un = Object.entries(st.paths.unrouted || {}).filter(([, n]) => n).map(([s, n]) => `${n.toLocaleString()} from ${esc(UNROUTED[s] || s)}`);
|
||||
return `${box}<div class="ex-layers" role="group" aria-label="Which riders' paths to show">${rows}
|
||||
<p class="small muted">Line width: how many runs took each step. Dashed lines are deaths; ✕ marks where those runs ended.${un.length ? ` Not drawn (they record the dragon, not the route): ${un.join(", ")}.` : ""}</p></div>`;
|
||||
}
|
||||
function chooser() {
|
||||
return `<div class="ex-choose">${COLOURS.map((c) => `<button type="button" class="ex-dchip" data-c="${c}" aria-pressed="${st.colour === c}" style="--c: var(${DV[c]})">${mini(c, POSE_OF[c])}<span>${c}</span></button>`).join("")}</div>`;
|
||||
}
|
||||
@@ -735,6 +778,7 @@
|
||||
$$("[data-o]", p).forEach((b) => b.addEventListener("click", () => { st.objective = b.dataset.o; render(); }));
|
||||
$$("[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(); });
|
||||
$$("[data-layer]", p).forEach((b) => b.addEventListener("change", () => { st.layers[b.dataset.layer] = b.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(); });
|
||||
@@ -846,7 +890,8 @@
|
||||
}
|
||||
|
||||
/** The runs selected on the page (one preset of data/stats.json): how many reached each place, and each step. */
|
||||
function setStats(P) {
|
||||
function setStats(P, paths) {
|
||||
if (paths) st.paths = paths;
|
||||
st.nRuns = P.analyse.n;
|
||||
st.counts = P.valley.counts;
|
||||
st.edges = P.valley.edges;
|
||||
|
||||
Reference in New Issue
Block a user