Site: show precomputed statistics; drop the upload and the click-to-select route map (#12)
Step 4a of the Python-first core. - analysis/stats/measures.yaml (declarative): outcomes and denominators, route targets and comparison groups, encounter contexts, the route map's stages, six filter presets and the route thresholds (5, 10, 20, 30). - analysis/stats/site_stats.py computes every number the page shows, for every preset, and writes data/public/stats.json: factor tables, models, chance events, encounters, the route map for every outcome, route rankings with q-values at every threshold, the valley map's place and step counts, and The Odds' summary cards. - The page now only displays: app.js, ui.js and explorer.js read stats.json; engine.js is no longer loaded. The three filter controls become one "Runs" menu; minimum runs become fixed thresholds. Removed: "Load a newer route export", click-to-select and "Follow" on the Deep Dive route map, and the unused old valley renderer. The coded runs are a CSV download. - tests/parity/compare_stats.py: every number matches what engine.js computed, for all six presets (factor tables, models, encounters, route rankings at every threshold, route map). Claude-Session: https://claude.ai/code/session_01UCzTd31GphpMXDhQqWrCMQ Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
963b08c522
commit
d04b88e7b4
+11
-18
@@ -433,18 +433,10 @@
|
||||
}
|
||||
|
||||
function drawTraffic(g) {
|
||||
if (!st.runs) return;
|
||||
const edges = new Map();
|
||||
st.runs.forEach((r) => {
|
||||
const seq = V.path(r);
|
||||
for (let i = 1; i < seq.length; i++) {
|
||||
const k = seq[i - 1] + ">" + seq[i];
|
||||
edges.set(k, (edges.get(k) || 0) + 1);
|
||||
}
|
||||
});
|
||||
const max = Math.max(1, ...edges.values());
|
||||
[...edges.entries()].sort((a, b) => b[1] - a[1]).forEach(([k, n]) => {
|
||||
const [a, b] = k.split(">");
|
||||
// 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]) => {
|
||||
if (!L[a] || !L[b]) return;
|
||||
el("path", { d: curve(L[a], L[b], 0.05), fill: "none", stroke: "#6b4a33", "stroke-opacity": 0.32, "stroke-width": 1.5 + 18 * Math.sqrt(n / max), "stroke-linecap": "round" }, g);
|
||||
});
|
||||
@@ -655,7 +647,7 @@
|
||||
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>`;
|
||||
}
|
||||
return `<span class="eyebrow">Unofficial atlas · built from ${st.runs ? st.runs.length.toLocaleString() : "thousands of"} logged runs</span>
|
||||
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>
|
||||
<p class="small muted">Every dragon is drawn where riders meet it. The fainter it is, the fewer riders reach it. Choose one to see its best route and the choices on it. Or click a key moment on the map, including the entrance, to see the choices you make there and your best chance at each dragon from it.</p>
|
||||
${chooser()}${info}
|
||||
@@ -852,10 +844,11 @@
|
||||
if (wrap && !wrap.dataset.centred && wrap.scrollWidth > wrap.clientWidth) { wrap.scrollLeft = (wrap.scrollWidth - wrap.clientWidth) / 2; wrap.dataset.centred = "1"; }
|
||||
}
|
||||
|
||||
function setRuns(state) {
|
||||
st.runs = state.runs;
|
||||
st.counts = {};
|
||||
state.runs.forEach((r) => V.path(r).forEach((id) => (st.counts[id] = (st.counts[id] || 0) + 1)));
|
||||
/** The runs selected on the page (one preset of data/stats.json): how many reached each place, and each step. */
|
||||
function setStats(P) {
|
||||
st.nRuns = P.analyse.n;
|
||||
st.counts = P.valley.counts;
|
||||
st.edges = P.valley.edges;
|
||||
render();
|
||||
}
|
||||
|
||||
@@ -867,6 +860,6 @@
|
||||
render();
|
||||
}).catch(() => { $("#ex-panel").innerHTML = '<p class="small muted">The route model (data/policy.json) could not be loaded.</p>'; });
|
||||
}
|
||||
window.ValleyExplorer = { setRuns, fromHash, state: st, render };
|
||||
window.ValleyExplorer = { setStats, fromHash, state: st, render };
|
||||
if (document.readyState === "loading") document.addEventListener("DOMContentLoaded", init); else init();
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user