Paths of all riders: one Google Sheet layer, deaths as line styles; silhouettes with their interior lines
CI / test (pull_request) Successful in 44s
CI / test (pull_request) Successful in 44s
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
7ef8a58a0e
commit
57839fcc87
@@ -90,18 +90,15 @@ route_thresholds: [5, 10, 20, 30]
|
||||
rare_goals: [Blue, Black, Blue or Black]
|
||||
|
||||
# "Show the paths of all riders" on the valley map (site/atlas/explorer.js): one layer per source that records a
|
||||
# route, and two layers of deaths. Unlike everything above, the layers use every source of runs_clean.csv. A layer
|
||||
# takes runs by source (and, for the spreadsheet, by its row label `entry`); the death layers take every death from
|
||||
# the route-recording sources: "deliberate" = burned at an encounter the rider did not genuinely attempt (the route
|
||||
# model's rule), "failed" = every other death. Discord has no runs yet: its layer is ready for when it is imported.
|
||||
# route, each with its own switch. Unlike everything above, the layers use every source of runs_clean.csv. Within a
|
||||
# layer the runs are split by how they ended, drawn as line styles in the layer's colour: solid (did not die), dashed
|
||||
# (chose to die: burned at an encounter the rider did not genuinely attempt, the route model's rule) and dotted
|
||||
# (failed: every other death). Discord has no runs yet: its layer is ready for when it is imported.
|
||||
path_layers:
|
||||
- { key: form, label: "Google Sheet: form posts", sources: [reddit spreadsheet], entry: [Form] }
|
||||
- { key: bulk, label: "Google Sheet: bulk logs", sources: [reddit spreadsheet], entry_not: [Form] }
|
||||
- { key: sheet, label: "Google Sheet", sources: [reddit spreadsheet] }
|
||||
- { key: reported, label: "Reported on the Atlas", sources: [reported] }
|
||||
- { key: reddit, label: "Reddit megathread comments", sources: [reddit comment] }
|
||||
- { key: bot, label: "DragonKind bot", sources: [bot] }
|
||||
- { key: discord, label: "Discord", sources: [discord] }
|
||||
- { key: died_deliberate, label: "Deaths: chose to die", death: deliberate }
|
||||
- { key: died_failed, label: "Deaths: failed runs", death: failed }
|
||||
# sources that record which dragon bonded but not the route: counted on the map, not drawn
|
||||
path_unrouted: [reddit thread, register]
|
||||
|
||||
@@ -468,30 +468,27 @@ def deliberate(r):
|
||||
|
||||
|
||||
def path_layers(runs):
|
||||
"""'Show the paths of all riders' on the valley map: for every layer in measures.yaml path_layers, how many runs
|
||||
went from each place to the next (like valley()), plus where the death layers' runs ended. Every source is used
|
||||
here, not only the statistics' sources. Sources that record no route are counted only (path_unrouted)."""
|
||||
cfg = M["path_layers"]
|
||||
routed = sorted({s for layer in cfg for s in layer.get("sources", [])})
|
||||
"""'Show the paths of all riders' on the valley map: for every layer in measures.yaml path_layers (one source or
|
||||
more), how many runs went from each place to the next (like valley()), split by how the runs ended: `lived` (did
|
||||
not die), `chose` (a deliberate death) and `failed` (every other death), plus where the deaths happened. Every
|
||||
source is used here, not only the statistics' sources. Sources that record no route are counted only."""
|
||||
out = []
|
||||
for layer in cfg:
|
||||
if "death" in layer:
|
||||
sel = [r for r in runs if r["source"] in routed and r["outcome"] in DEATHS
|
||||
and deliberate(r) == (layer["death"] == "deliberate")]
|
||||
else:
|
||||
sel = [r for r in runs if r["source"] in layer["sources"]
|
||||
and (not layer.get("entry") or r.get("entry") in layer["entry"])
|
||||
and (not layer.get("entry_not") or r.get("entry") not in layer["entry_not"])]
|
||||
v = valley(sel)
|
||||
item = {"key": layer["key"], "label": layer["label"], "runs": len(sel), "edges": v["edges"]}
|
||||
if "death" in layer:
|
||||
ends = {}
|
||||
for r in sel:
|
||||
for layer in M["path_layers"]:
|
||||
sel = [r for r in runs if r["source"] in layer["sources"]]
|
||||
kinds = {"lived": [], "chose": [], "failed": []}
|
||||
for r in sel:
|
||||
kinds["lived" if r["outcome"] not in DEATHS else "chose" if deliberate(r) else "failed"].append(r)
|
||||
ends = {}
|
||||
for k in ("chose", "failed"):
|
||||
e = {}
|
||||
for r in kinds[k]:
|
||||
seq = place_path(r)
|
||||
if seq:
|
||||
ends[seq[-1]] = ends.get(seq[-1], 0) + 1
|
||||
item["ends"] = dict(sorted(ends.items(), key=lambda kv: -kv[1]))
|
||||
out.append(item)
|
||||
e[seq[-1]] = e.get(seq[-1], 0) + 1
|
||||
ends[k] = dict(sorted(e.items(), key=lambda kv: -kv[1]))
|
||||
out.append({"key": layer["key"], "label": layer["label"], "runs": len(sel),
|
||||
"counts": {k: len(v) for k, v in kinds.items()},
|
||||
"lines": {k: valley(v)["edges"] for k, v in kinds.items()}, "ends": ends})
|
||||
unrouted = {s: sum(1 for r in runs if r["source"] == s) for s in M.get("path_unrouted", [])}
|
||||
return {"layers": out, "unrouted": unrouted}
|
||||
|
||||
|
||||
+31
-10
File diff suppressed because one or more lines are too long
+35
-25
@@ -434,12 +434,14 @@
|
||||
}
|
||||
}
|
||||
|
||||
// "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", reddit: "#a8792a", bot: "#28588a", discord: "#5865f2",
|
||||
died_deliberate: "#7d8794", died_failed: "#c2410c",
|
||||
// "Show the paths of all riders": one ink per source layer (data/stats.json paths.layers; measures.yaml path_layers),
|
||||
// and one line style per way the runs ended
|
||||
const LAYER_INK = { sheet: "#6b4a33", reported: "#7a4f8f", reddit: "#a8792a", bot: "#28588a", discord: "#5865f2" };
|
||||
const KIND = {
|
||||
lived: { dash: null, cap: "round", label: "survived" },
|
||||
chose: { dash: "11 6", cap: "butt", label: "chose to die" },
|
||||
failed: { dash: "0.1 6", cap: "round", label: "died (failed run)" },
|
||||
};
|
||||
const isDeath = (k) => k.startsWith("died_");
|
||||
const layerOn = (k) => st.layers[k] !== false; // every layer starts on
|
||||
|
||||
function drawTraffic(g) {
|
||||
@@ -453,26 +455,32 @@
|
||||
});
|
||||
}
|
||||
|
||||
/** Every layer that is switched on, side by side; the death layers dashed, with a mark where their runs ended. */
|
||||
/** Every source layer that is switched on, side by side in its own ink: solid for runs that survived, dashed for
|
||||
* deliberate deaths, dotted for failed runs, and a mark where the deaths happened. */
|
||||
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])));
|
||||
const shown = layers.filter((l) => l.runs && layerOn(l.key) && l.lines);
|
||||
const all = shown.flatMap((l) => Object.values(l.lines).flatMap((es) => es.map((e) => e[2])));
|
||||
const max = Math.max(1, ...all);
|
||||
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);
|
||||
const base = (i - (shown.length - 1) / 2) * 9, ink = LAYER_INK[l.key] || "#6b4a33";
|
||||
["lived", "chose", "failed"].forEach((k, j) => {
|
||||
const off = base + (j - 1) * 3, kd = KIND[k];
|
||||
(l.lines[k] || []).forEach(([a, b, n]) => {
|
||||
if (!L[a] || !L[b]) return;
|
||||
const w = 1.2 + 14 * Math.sqrt(n / max);
|
||||
el("path", { d: curve(L[a], L[b], 0.05, off), fill: "none", stroke: ink, "stroke-opacity": k === "lived" ? 0.36 : 0.6,
|
||||
"stroke-width": k === "failed" ? Math.max(2.2, w) : w, "stroke-linecap": kd.cap, "stroke-dasharray": kd.dash }, g);
|
||||
});
|
||||
}
|
||||
});
|
||||
// where the deaths happened: one mark per place, sized by the deaths there
|
||||
const ends = {};
|
||||
["chose", "failed"].forEach((k) => Object.entries((l.ends || {})[k] || {}).forEach(([p, n]) => (ends[p] = (ends[p] || 0) + n)));
|
||||
const emax = Math.max(1, ...Object.values(ends));
|
||||
Object.entries(ends).forEach(([p, n]) => {
|
||||
if (!L[p]) return;
|
||||
const r = 2.5 + 9 * Math.sqrt(n / emax), x = L[p].x + base, y = L[p].y;
|
||||
el("path", { d: `M${x - r * 0.6},${y - r * 0.6}L${x + r * 0.6},${y + r * 0.6}M${x + r * 0.6},${y - r * 0.6}L${x - r * 0.6},${y + r * 0.6}`, stroke: ink, "stroke-width": 2, "stroke-opacity": 0.8 }, g);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -671,12 +679,14 @@
|
||||
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;
|
||||
if (!st.traffic || !st.paths || !st.paths.layers || !st.paths.layers.some((l) => l.lines)) 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("");
|
||||
<span class="sw" 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 key = Object.values(KIND).map((kd) => `<span class="ex-kind"><svg viewBox="0 0 34 8" aria-hidden="true"><path d="M3 4H31" stroke="currentColor" stroke-width="2.6" stroke-linecap="${kd.cap}"${kd.dash ? ` stroke-dasharray="${kd.dash === "11 6" ? "8 4" : "0.1 5"}"` : ""}/></svg>${kd.label}</span>`).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>`;
|
||||
<div class="ex-kinds">${key}</div>
|
||||
<p class="small muted">Each source in its own colour; line width is how many runs took each step, and ✕ marks where runs died.${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>`;
|
||||
|
||||
@@ -342,8 +342,10 @@ footer { border-top-color: var(--line); }
|
||||
.ex-layer { display: grid; grid-template-columns: auto 22px minmax(0, 1fr) auto; gap: 8px; align-items: center; font-size: var(--step--1); color: inherit; cursor: pointer; }
|
||||
.ex-layer.none { color: var(--muted); cursor: default; }
|
||||
.ex-layer .sw { height: 0; border-top: 4px solid var(--sw); border-radius: 2px; }
|
||||
.ex-layer .sw.dash { border-top-style: dashed; }
|
||||
.ex-layer .n { color: var(--muted); font-variant-numeric: tabular-nums; }
|
||||
.ex-kinds { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 4px; font-size: var(--step--1); color: var(--muted); }
|
||||
.ex-kind { display: inline-flex; align-items: center; gap: 6px; }
|
||||
.ex-kind svg { width: 34px; height: 8px; }
|
||||
.ex-head { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; gap: 10px; align-items: center; }
|
||||
.ex-head svg { width: 64px; height: 52px; }
|
||||
.ex-head h2 { color: var(--c); }
|
||||
|
||||
Reference in New Issue
Block a user