Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e457f89b40 |
@@ -88,17 +88,3 @@ presets:
|
|||||||
route_thresholds: [5, 10, 20, 30]
|
route_thresholds: [5, 10, 20, 30]
|
||||||
|
|
||||||
rare_goals: [Blue, Black, Blue or Black]
|
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, 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: 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] }
|
|
||||||
# sources that record which dragon bonded but not the route: counted on the map, not drawn
|
|
||||||
path_unrouted: [reddit thread, register]
|
|
||||||
|
|||||||
@@ -399,7 +399,7 @@ def place_path(r):
|
|||||||
s.append("bully")
|
s.append("bully")
|
||||||
if "res:" + r["resolution"] in L:
|
if "res:" + r["resolution"] in L:
|
||||||
s.append("res:" + r["resolution"])
|
s.append("res:" + r["resolution"])
|
||||||
if (r.get("resolution") or "").startswith("DIED"):
|
if r["resolution"].startswith("DIED"):
|
||||||
return s
|
return s
|
||||||
if r.get("post_path") in ("Forest", "West", "East"):
|
if r.get("post_path") in ("Forest", "West", "East"):
|
||||||
s.append("fork:" + r["post_path"])
|
s.append("fork:" + r["post_path"])
|
||||||
@@ -452,51 +452,17 @@ def valley(runs):
|
|||||||
return {"counts": counts, "edges": [[*k.split(">"), n] for k, n in sorted(edges.items(), key=lambda kv: -kv[1])]}
|
return {"counts": counts, "edges": [[*k.split(">"), n] for k, n in sorted(edges.items(), key=lambda kv: -kv[1])]}
|
||||||
|
|
||||||
|
|
||||||
DEATHS = ("Incinerated", "Died before the hour")
|
|
||||||
|
|
||||||
|
|
||||||
def deliberate(r):
|
|
||||||
"""A deliberate death: burned at a bonding encounter the rider did not genuinely attempt (chasing another colour,
|
|
||||||
choosing to die and try again). The route model's own rule."""
|
|
||||||
if r["outcome"] != "Incinerated":
|
|
||||||
return False
|
|
||||||
try:
|
|
||||||
v = model.prepare_run(r)
|
|
||||||
return bool(v.get("encCtx")) and not model.genuine_attempt(r, v["encCtx"])
|
|
||||||
except (KeyError, TypeError, ValueError): # a source coded from other questions (e.g. the bot): not known
|
|
||||||
return False
|
|
||||||
|
|
||||||
|
|
||||||
def path_layers(runs):
|
|
||||||
"""'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 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:
|
|
||||||
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}
|
|
||||||
|
|
||||||
|
|
||||||
def overview(runs):
|
def overview(runs):
|
||||||
"""The Odds' summary cards: cadets who went in and either bonded or died. Deliberate deaths (burned at an
|
"""The Odds' summary cards: cadets who went in and either bonded or died. Deliberate deaths (burned at an
|
||||||
encounter the rider did not genuinely attempt) and runs with no recorded outcome are left out."""
|
encounter the rider did not genuinely attempt) and runs with no recorded outcome are left out."""
|
||||||
ended = [r for r in runs if r["outcome"] in ("Bonded", "Incinerated", "Died before the hour")]
|
ended = [r for r in runs if r["outcome"] in ("Bonded", "Incinerated", "Died before the hour")]
|
||||||
|
|
||||||
|
def deliberate(r):
|
||||||
|
if r["outcome"] != "Incinerated":
|
||||||
|
return False
|
||||||
|
v = model.prepare_run(r)
|
||||||
|
return bool(v.get("encCtx")) and not model.genuine_attempt(r, v["encCtx"])
|
||||||
|
|
||||||
cadets = [r for r in ended if not deliberate(r)]
|
cadets = [r for r in ended if not deliberate(r)]
|
||||||
bonded = sum(1 for r in cadets if r["outcome"] == "Bonded")
|
bonded = sum(1 for r in cadets if r["outcome"] == "Bonded")
|
||||||
return {"cadets": len(cadets), "bonded": bonded, "dead": len(cadets) - bonded, "deliberate": len(ended) - len(cadets),
|
return {"cadets": len(cadets), "bonded": bonded, "dead": len(cadets) - bonded, "deliberate": len(ended) - len(cadets),
|
||||||
@@ -517,7 +483,7 @@ def clean(o):
|
|||||||
return o
|
return o
|
||||||
|
|
||||||
|
|
||||||
def build(runs, rows, exported=None, every_run=None):
|
def build(runs, rows, exported=None):
|
||||||
global PLACES
|
global PLACES
|
||||||
PLACES = place_ids()
|
PLACES = place_ids()
|
||||||
th = M["route_thresholds"]
|
th = M["route_thresholds"]
|
||||||
@@ -540,8 +506,6 @@ def build(runs, rows, exported=None, every_run=None):
|
|||||||
"routes": {t: rank_routes(sub, t, th) for t in TARGETS},
|
"routes": {t: rank_routes(sub, t, th) for t in TARGETS},
|
||||||
"map": route_map(sub), "valley": valley(sub), "overview": overview(sub),
|
"map": route_map(sub), "valley": valley(sub), "overview": overview(sub),
|
||||||
}
|
}
|
||||||
if every_run is not None:
|
|
||||||
out["paths"] = path_layers(every_run)
|
|
||||||
return clean(out)
|
return clean(out)
|
||||||
|
|
||||||
|
|
||||||
@@ -551,7 +515,7 @@ def main(argv=None):
|
|||||||
ap.add_argument("--out", default=str(ROOT / "data/public/stats.json"))
|
ap.add_argument("--out", default=str(ROOT / "data/public/stats.json"))
|
||||||
a = ap.parse_args(argv)
|
a = ap.parse_args(argv)
|
||||||
runs = runs_io.read(a.data, sources=M["sources"])
|
runs = runs_io.read(a.data, sources=M["sources"])
|
||||||
out = build(runs, len(runs), exported(), every_run=runs_io.read(a.data))
|
out = build(runs, len(runs), exported())
|
||||||
Path(a.out).write_text(json.dumps(out, separators=(",", ":"), ensure_ascii=False), encoding="utf-8")
|
Path(a.out).write_text(json.dumps(out, separators=(",", ":"), ensure_ascii=False), encoding="utf-8")
|
||||||
print(f"{a.out}: {len(runs)} runs, {len(out['presets'])} presets, {Path(a.out).stat().st_size / 1e6:.1f} MB")
|
print(f"{a.out}: {len(runs)} runs, {len(out['presets'])} presets, {Path(a.out).stat().st_size / 1e6:.1f} MB")
|
||||||
|
|
||||||
|
|||||||
@@ -191,11 +191,63 @@ def answers_row(run_id, source, date, answers, flags=None):
|
|||||||
row["saw_blue_meadow"] = True
|
row["saw_blue_meadow"] = True
|
||||||
if row["outcome"] == "Bonded" and not row["outcome_color"]:
|
if row["outcome"] == "Bonded" and not row["outcome_color"]:
|
||||||
flags.append("bonded, colour not given")
|
flags.append("bonded, colour not given")
|
||||||
|
flags += rule_flags(row)
|
||||||
encounter_columns(row)
|
encounter_columns(row)
|
||||||
row["data_flags"] = "; ".join(flags)
|
row["data_flags"] = "; ".join(flags)
|
||||||
return row
|
return row
|
||||||
|
|
||||||
|
|
||||||
|
# the scream answer each cadet outcome follows (a run cannot end the encounter on another path)
|
||||||
|
CADET_PATH = {
|
||||||
|
"Killed the bullies yourself": "Investigate & help", "Squadmate's revenge": "Investigate & help",
|
||||||
|
"Left bullies to the dragons": "Investigate & help", "DIED in combat": "Investigate & help",
|
||||||
|
"Tourniquet": "Ignore the scream", "Left injured cadet": "Ignore the scream", "Took their weapons": "Ignore the scream",
|
||||||
|
"Left them to it": "Investigate & leave",
|
||||||
|
}
|
||||||
|
REACHED = ("Tree", "Valley")
|
||||||
|
|
||||||
|
|
||||||
|
@functools.lru_cache(maxsize=1)
|
||||||
|
def _form_rules():
|
||||||
|
from atlas import spec as atlas_spec
|
||||||
|
f = atlas_spec.form()
|
||||||
|
return f["sighting_pool"], {k: set(v) for k, v in f["encounter_colours"].items()}
|
||||||
|
|
||||||
|
|
||||||
|
def rule_flags(row):
|
||||||
|
"""The game's own rules, for runs answered through "Report a run": the checks core/atlas/coding.py makes on
|
||||||
|
the community form (first-dragon pools, Greens in the valley) plus the encounter's dragons and the cadet path.
|
||||||
|
Each broken rule is a flag; the run is kept."""
|
||||||
|
pools, enc_colours = _form_rules()
|
||||||
|
flags = []
|
||||||
|
company, direction, first = row["company"], row["direction"], row["first_sighting"]
|
||||||
|
if company in pools and direction in pools[company] and first in COLOURS:
|
||||||
|
pool = list(pools[company][direction]) + (list(pools["Alone"][direction]) if row["left_squadmates"] is True else [])
|
||||||
|
if first not in pool:
|
||||||
|
flags.append(f"first sighting {first} not in documented pool for {company}/{direction}")
|
||||||
|
colour, branch = row["outcome_color"], row["branch"]
|
||||||
|
if row["outcome"] in ("Bonded", "Incinerated") and colour:
|
||||||
|
if branch in enc_colours and colour not in enc_colours[branch]:
|
||||||
|
flags.append(f"{colour} at the {branch} encounter, which has only {'/'.join(sorted(enc_colours[branch]))}")
|
||||||
|
if row["hour"] == "Valley" and colour == "Green":
|
||||||
|
flags.append("Green recorded on a Valley run (no Greens in the valley)")
|
||||||
|
scream, res = row["scream"], row["resolution"]
|
||||||
|
if scream in ("Investigate & help", "Ignore the scream", "Investigate & leave"):
|
||||||
|
if res in CADET_PATH and CADET_PATH[res] != scream:
|
||||||
|
flags.append(f"cadet outcome {res!r} does not follow {scream!r}")
|
||||||
|
if scream != "Investigate & help" and (row["combat_first"] not in (None, "(not recorded)")
|
||||||
|
or row["combat_second"] not in (None, "(not recorded)")):
|
||||||
|
flags.append("fight answers on a run that did not help")
|
||||||
|
if scream != "Investigate & help" and row["post_path"] in ("Forest", "West", "East"):
|
||||||
|
flags.append("a path after the fight on a run without a fight")
|
||||||
|
if row["combat_second"] not in (None, "(not recorded)") and row["combat_first"] != "Assess the situation":
|
||||||
|
flags.append("a second fight move without pausing to assess")
|
||||||
|
died_early = (scream or "").startswith("DIED") or (res or "").startswith("DIED")
|
||||||
|
if died_early and (row["hour"] in REACHED or row["outcome"] in ("Bonded", "Incinerated")):
|
||||||
|
flags.append("died before the hour, yet reached the tree, the valley or a bonding encounter")
|
||||||
|
return flags
|
||||||
|
|
||||||
|
|
||||||
def _norm(text):
|
def _norm(text):
|
||||||
from .transform.bot import normalize
|
from .transform.bot import normalize
|
||||||
return normalize(text)
|
return normalize(text)
|
||||||
|
|||||||
@@ -153,6 +153,17 @@ sighting_pool:
|
|||||||
1 Squadmate: { East: [Green, Orange, Red], West: [Red, Brown, Green], Center: [Red, Brown] }
|
1 Squadmate: { East: [Green, Orange, Red], West: [Red, Brown, Green], Center: [Red, Brown] }
|
||||||
2 Squadmates: { East: [Red, Orange], West: [Green, Brown, Red], Center: [Red, Brown] }
|
2 Squadmates: { East: [Red, Orange], West: [Green, Brown, Red], Center: [Red, Brown] }
|
||||||
|
|
||||||
|
# The dragons each bonding encounter can end with (bond or burn), from the community PDF. Only used to FLAG runs
|
||||||
|
# answered through "Report a run" (reported, reddit comment) that end with a dragon the encounter does not have.
|
||||||
|
# Orange and Brown after the two Greens: a Green's rescue, then the Orange or Brown.
|
||||||
|
encounter_colours:
|
||||||
|
"Shadow (rare)": [Blue, Black]
|
||||||
|
"Descend quickly: Red": [Red]
|
||||||
|
"Descend quickly: let the Red pass": [Green]
|
||||||
|
"Descend slowly: two Greens": [Green, Orange, Brown]
|
||||||
|
"Valley Red": [Red]
|
||||||
|
"Passed the Red: meadow": [Orange, Brown, Blue]
|
||||||
|
|
||||||
# First-sighting answers that are not a single colour: coded as this colour, and the row is flagged with the
|
# First-sighting answers that are not a single colour: coded as this colour, and the row is flagged with the
|
||||||
# original answer (data_flags), so nothing is lost.
|
# original answer (data_flags), so nothing is lost.
|
||||||
first_sighting_alias:
|
first_sighting_alias:
|
||||||
|
|||||||
+10
-1
@@ -36,6 +36,15 @@ def low_bias(r, lb=CONFIG["low_bias"]):
|
|||||||
return r["goal"] not in lb["rare_goals"]
|
return r["goal"] not in lb["rare_goals"]
|
||||||
|
|
||||||
|
|
||||||
|
def drop_flagged(runs, cfg=CONFIG.get("drop_flagged") or {}):
|
||||||
|
"""Without the flagged runs of the sources read automatically from free text (planner/policy.yaml drop_flagged)."""
|
||||||
|
sources, keep = set(cfg.get("sources") or ()), tuple(cfg.get("except") or ())
|
||||||
|
|
||||||
|
def problems(r):
|
||||||
|
return [f for f in (r.get("data_flags") or "").split("; ") if f and not f.startswith(keep)] if keep else [f for f in (r.get("data_flags") or "").split("; ") if f]
|
||||||
|
return [r for r in runs if r["source"] not in sources or not problems(r)]
|
||||||
|
|
||||||
|
|
||||||
def clean(o):
|
def clean(o):
|
||||||
"""JSON-safe: numpy numbers to floats, infinities and NaN to null (as JavaScript's JSON.stringify does)."""
|
"""JSON-safe: numpy numbers to floats, infinities and NaN to null (as JavaScript's JSON.stringify does)."""
|
||||||
if isinstance(o, dict):
|
if isinstance(o, dict):
|
||||||
@@ -56,7 +65,7 @@ def main(argv=None):
|
|||||||
ap.add_argument("--out", default=str(ROOT / "data/public/policy.json"))
|
ap.add_argument("--out", default=str(ROOT / "data/public/policy.json"))
|
||||||
a = ap.parse_args(argv)
|
a = ap.parse_args(argv)
|
||||||
|
|
||||||
runs = runs_io.read(a.data, sources=SOURCES)
|
runs = drop_flagged(runs_io.read(a.data, sources=SOURCES))
|
||||||
rows = len(runs)
|
rows = len(runs)
|
||||||
samples = {
|
samples = {
|
||||||
"all": runs,
|
"all": runs,
|
||||||
|
|||||||
@@ -8,6 +8,14 @@ version: 1
|
|||||||
# the `source` values of data/public/runs_clean.csv the model learns from
|
# the `source` values of data/public/runs_clean.csv the model learns from
|
||||||
sources: [reddit spreadsheet, reported, bot]
|
sources: [reddit spreadsheet, reported, bot]
|
||||||
|
|
||||||
|
# Sources read automatically from free text: a run with any data flag (a broken game rule, an unrecognised answer)
|
||||||
|
# is left out of the model, since the flag may mean the text was misread or misremembered. Flags that only say where
|
||||||
|
# the run came from (`except`, matched at the start of a flag) do not count. A hand fix that clears the flags
|
||||||
|
# brings the run back. Applies once the source is also listed in `sources` above.
|
||||||
|
drop_flagged:
|
||||||
|
sources: [reddit comment]
|
||||||
|
except: ["read from a Reddit comment"]
|
||||||
|
|
||||||
# Two samples. "all" is every run above. "lowBias" leaves out runs where a rare sighting is more likely to have
|
# Two samples. "all" is every run above. "lowBias" leaves out runs where a rare sighting is more likely to have
|
||||||
# been reported than a miss: form submissions and reports from riders chasing Blue or Black. The bot logs every
|
# been reported than a miss: form submissions and reports from riders chasing Blue or Black. The bot logs every
|
||||||
# run, and bulk-pasted logs record every run of the players who kept them, so both stay in.
|
# run, and bulk-pasted logs record every run of the players who kept them, so both stay in.
|
||||||
|
|||||||
+98
-35
File diff suppressed because one or more lines are too long
+13
-68
@@ -9,9 +9,7 @@
|
|||||||
* 3 click a choice point on the highlighted route: its other options branch off, each with the chance it gives.
|
* 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.
|
* 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.
|
* 4 "Why this route?" in the side panel: intervals, how often the choice stays best, low-bias numbers, risks.
|
||||||
* "Show the paths of all riders" adds, underneath, the paths every source logged (one layer each: the sheet's form
|
* A toggle adds the community's actual traffic underneath. The URL keeps the selection (#valley/blue/meadow-Blue).
|
||||||
* 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 () {
|
(function () {
|
||||||
"use strict";
|
"use strict";
|
||||||
@@ -41,15 +39,15 @@
|
|||||||
};
|
};
|
||||||
const RESCUE = { Orange: "tree-Greens", Brown: "tree-Greens" };
|
const RESCUE = { Orange: "tree-Greens", Brown: "tree-Greens" };
|
||||||
const SPOTS = [
|
const SPOTS = [
|
||||||
{ place: "treeRed", enc: "tree-Red", colour: "Red", pose: "roaring", flip: true, sc: 0.36 },
|
{ place: "treeRed", enc: "tree-Red", colour: "Red", pose: "prowling", flip: true, sc: 0.36 },
|
||||||
{ place: "greens", enc: "tree-Greens", colour: "Green", pose: "prowling", sc: 0.3, dx: -16 },
|
{ place: "greens", enc: "tree-Greens", colour: "Green", pose: "resting", sc: 0.3, dx: -16 },
|
||||||
{ place: "greens", enc: "tree-Greens", colour: "Green", pose: "prowling", flip: true, sc: 0.27, dx: 20, dy: -4, twin: true },
|
{ 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: "resting", flip: true, sc: 0.38 },
|
{ place: "black", enc: "shadow-Black", colour: "Black", pose: "flying", flip: true, sc: 0.38 },
|
||||||
{ place: "redwood", enc: "shadow-Blue", colour: "Blue", pose: "coiled", sc: 0.3 },
|
{ 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: "valleyRed", enc: "valley-Red", colour: "Red", pose: "roaring", sc: 0.36, dy: -12 },
|
||||||
{ place: "meadow:Orange", enc: "meadow-Orange", colour: "Orange", pose: "flying", flip: true, sc: 0.3 },
|
{ place: "meadow:Orange", enc: "meadow-Orange", colour: "Orange", pose: "sitting", flip: true, sc: 0.3 },
|
||||||
{ place: "meadow:Brown", enc: "meadow-Brown", colour: "Brown", pose: "sitting", sc: 0.32 },
|
{ place: "meadow:Brown", enc: "meadow-Brown", colour: "Brown", pose: "resting", sc: 0.32 },
|
||||||
{ place: "meadow:Blue", enc: "meadow-Blue", colour: "Blue", pose: "coiled", sc: 0.32 },
|
{ place: "meadow:Blue", enc: "meadow-Blue", colour: "Blue", pose: "sitting", sc: 0.32 },
|
||||||
];
|
];
|
||||||
const FIRST_POSE = { Red: "roaring", Brown: "sitting", Green: "prowling", Orange: "flying" };
|
const FIRST_POSE = { Red: "roaring", Brown: "sitting", Green: "prowling", Orange: "flying" };
|
||||||
Object.keys(L).filter((k) => k.startsWith("see:")).forEach((k) => {
|
Object.keys(L).filter((k) => k.startsWith("see:")).forEach((k) => {
|
||||||
@@ -87,7 +85,7 @@
|
|||||||
const st = {
|
const st = {
|
||||||
point: null, // a place picked before any dragon: show the best way from there to every dragon
|
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: {},
|
policy: null, runs: null, counts: {}, colour: null, focus: null, expanded: null, over: {},
|
||||||
objective: "eventually", sample: "all", traffic: false, layers: {}, paths: null, cache: new Map(), pendingHash: null, info: null,
|
objective: "eventually", sample: "all", traffic: false, cache: new Map(), pendingHash: null, info: null,
|
||||||
};
|
};
|
||||||
const model = () => st.policy.samples[st.sample];
|
const model = () => st.policy.samples[st.sample];
|
||||||
function advisorFor(enc, colour = st.colour) {
|
function advisorFor(enc, colour = st.colour) {
|
||||||
@@ -434,19 +432,8 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// "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 layerOn = (k) => st.layers[k] !== false; // every layer starts on
|
|
||||||
|
|
||||||
function drawTraffic(g) {
|
function drawTraffic(g) {
|
||||||
if (st.paths && st.paths.layers) return drawLayers(g, st.paths.layers);
|
// how many logged runs went from each place to the next (precomputed in data/stats.json)
|
||||||
// older stats.json: how many logged runs went from each place to the next (precomputed in data/stats.json)
|
|
||||||
if (!st.edges) return;
|
if (!st.edges) return;
|
||||||
const max = Math.max(1, ...st.edges.map((e) => e[2]));
|
const max = Math.max(1, ...st.edges.map((e) => e[2]));
|
||||||
st.edges.forEach(([a, b, n]) => {
|
st.edges.forEach(([a, b, n]) => {
|
||||||
@@ -455,35 +442,6 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 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) && 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 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);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function drawRoutes(gRoute, gLab, routes) {
|
function drawRoutes(gRoute, gLab, routes) {
|
||||||
const best = Math.max(1e-12, ...routes.map((r) => r.value.x));
|
const best = Math.max(1e-12, ...routes.map((r) => r.value.x));
|
||||||
const onRoute = new Set();
|
const onRoute = new Set();
|
||||||
@@ -675,19 +633,8 @@
|
|||||||
|
|
||||||
/* ---------- panel ---------- */
|
/* ---------- 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 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: "sitting", Green: "prowling", Blue: "coiled", Black: "resting" };
|
const POSE_OF = { Red: "roaring", Orange: "flying", Brown: "resting", Green: "prowling", Blue: "coiled", Black: "flying" };
|
||||||
const UNROUTED = { "reddit thread": "Reddit result pages", register: "the Dragon Register" };
|
const trafficToggle = () => `<label class="ex-toggle"><input type="checkbox" id="ex-traffic"${st.traffic ? " checked" : ""}> Show where riders actually went</label>`;
|
||||||
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 || !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" 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}
|
|
||||||
<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() {
|
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>`;
|
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>`;
|
||||||
}
|
}
|
||||||
@@ -788,7 +735,6 @@
|
|||||||
$$("[data-o]", p).forEach((b) => b.addEventListener("click", () => { st.objective = b.dataset.o; render(); }));
|
$$("[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(); }));
|
$$("[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(); });
|
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));
|
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(); }));
|
$$("[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(); });
|
const cp = $("#ex-clear-point", p); if (cp) cp.addEventListener("click", () => { st.point = null; writeHash(); render(); });
|
||||||
@@ -900,8 +846,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** The runs selected on the page (one preset of data/stats.json): how many reached each place, and each step. */
|
/** The runs selected on the page (one preset of data/stats.json): how many reached each place, and each step. */
|
||||||
function setStats(P, paths) {
|
function setStats(P) {
|
||||||
if (paths) st.paths = paths;
|
|
||||||
st.nRuns = P.analyse.n;
|
st.nRuns = P.analyse.n;
|
||||||
st.counts = P.valley.counts;
|
st.counts = P.valley.counts;
|
||||||
st.edges = P.valley.edges;
|
st.edges = P.valley.edges;
|
||||||
|
|||||||
@@ -338,14 +338,6 @@ footer { border-top-color: var(--line); }
|
|||||||
.ex-dchip[aria-pressed="true"] { background: color-mix(in srgb, var(--c) 22%, var(--raised)); box-shadow: 0 0 14px color-mix(in srgb, var(--c) 35%, transparent), inset 0 0 0 1px var(--c); }
|
.ex-dchip[aria-pressed="true"] { background: color-mix(in srgb, var(--c) 22%, var(--raised)); box-shadow: 0 0 14px color-mix(in srgb, var(--c) 35%, transparent), inset 0 0 0 1px var(--c); }
|
||||||
.ex-card { padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--raised); }
|
.ex-card { padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--raised); }
|
||||||
.ex-toggle { display: flex; gap: 8px; align-items: center; font-size: var(--step--1); color: var(--muted); }
|
.ex-toggle { display: flex; gap: 8px; align-items: center; font-size: var(--step--1); color: var(--muted); }
|
||||||
.ex-layers { display: grid; gap: 4px; margin: 4px 0 0 24px; }
|
|
||||||
.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 .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 { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; gap: 10px; align-items: center; }
|
||||||
.ex-head svg { width: 64px; height: 52px; }
|
.ex-head svg { width: 64px; height: 52px; }
|
||||||
.ex-head h2 { color: var(--c); }
|
.ex-head h2 { color: var(--c); }
|
||||||
|
|||||||
+2
-2
@@ -148,7 +148,7 @@
|
|||||||
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: "sitting", Green: "prowling", Blue: "coiled", Black: "resting" };
|
const POSE = { Red: "roaring", Orange: "flying", Brown: "resting", Green: "prowling", Blue: "coiled", Black: "flying" };
|
||||||
|
|
||||||
let blackP = null;
|
let blackP = null;
|
||||||
const getBlack = () => blackP || (blackP = fetch("data/black.json").then((r) => r.json()).catch(() => null));
|
const getBlack = () => blackP || (blackP = fetch("data/black.json").then((r) => r.json()).catch(() => null));
|
||||||
@@ -260,7 +260,7 @@
|
|||||||
window.AtlasUI = {
|
window.AtlasUI = {
|
||||||
render(state) {
|
render(state) {
|
||||||
renderOverview(state);
|
renderOverview(state);
|
||||||
if (window.ValleyExplorer) window.ValleyExplorer.setStats(state.P, state.stats && state.stats.paths);
|
if (window.ValleyExplorer) window.ValleyExplorer.setStats(state.P);
|
||||||
},
|
},
|
||||||
showTab,
|
showTab,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -278,7 +278,7 @@ class RedditComments(unittest.TestCase):
|
|||||||
"answers": {"company": "Alone", "outcome": "Incinerated at a bonding encounter", "outcome_color": "Red"}}]}),
|
"answers": {"company": "Alone", "outcome": "Incinerated at a bonding encounter", "outcome_color": "Red"}}]}),
|
||||||
encoding="utf-8")
|
encoding="utf-8")
|
||||||
manual = TMP / "reddit_comments_manual.yaml"
|
manual = TMP / "reddit_comments_manual.yaml"
|
||||||
manual.write_text("reject: [c2]\nfix: {c1: {outcome_color: Blue, direction: null}}\n"
|
manual.write_text("reject: [c2]\nfix: {c1: {outcome_color: Blue, branch: 'Valley: passed the Red, the meadow', direction: null}}\n"
|
||||||
"add: [{id: c9, thread: abc, posted: '2026-11-16', "
|
"add: [{id: c9, thread: abc, posted: '2026-11-16', "
|
||||||
"answers: {company: Two squadmates, direction: West (toward the scent), outcome: Died before the hour}}]\n",
|
"answers: {company: Two squadmates, direction: West (toward the scent), outcome: Died before the hour}}]\n",
|
||||||
encoding="utf-8")
|
encoding="utf-8")
|
||||||
@@ -286,12 +286,53 @@ class RedditComments(unittest.TestCase):
|
|||||||
self.assertEqual([r["run_id"] for r in rows], ["comment-c1", "comment-c3", "comment-c9"])
|
self.assertEqual([r["run_id"] for r in rows], ["comment-c1", "comment-c3", "comment-c9"])
|
||||||
c1, c3, c9 = rows
|
c1, c3, c9 = rows
|
||||||
self.assertEqual((c1["source"], c1["outcome_color"], c1["direction"], c1["hour"], c1["enc_Blue"]),
|
self.assertEqual((c1["source"], c1["outcome_color"], c1["direction"], c1["hour"], c1["enc_Blue"]),
|
||||||
("reddit comment", "Blue", "Unknown", "Tree", "Bonded!"))
|
("reddit comment", "Blue", "Unknown", "Valley", "Bonded!"))
|
||||||
self.assertEqual(c1["data_flags"], "read from a Reddit comment")
|
self.assertEqual(c1["data_flags"], "read from a Reddit comment")
|
||||||
self.assertEqual(c3["data_flags"], "read from a Reddit comment automatically, not checked by hand")
|
self.assertEqual(c3["data_flags"], "read from a Reddit comment automatically, not checked by hand")
|
||||||
self.assertEqual((c9["company"], c9["direction"], c9["hour"]), ("2 Squadmates", "West", "DIED before the hour"))
|
self.assertEqual((c9["company"], c9["direction"], c9["hour"]), ("2 Squadmates", "West", "DIED before the hour"))
|
||||||
self.assertEqual(validate.problems(rows, runs.DICT), [])
|
self.assertEqual(validate.problems(rows, runs.DICT), [])
|
||||||
|
|
||||||
|
def test_game_rules_flag_impossible_runs(self):
|
||||||
|
def flags(**answers):
|
||||||
|
return runs.answers_row("x", "reddit comment", None, answers)["data_flags"]
|
||||||
|
ok = flags(company="Alone", direction="East (toward the roar)", first_sighting="Orange",
|
||||||
|
scream="Kept walking (ignored it)", resolution="Wounded cadet: tourniquet",
|
||||||
|
branch="Tree: climbed down slowly to the two Greens", outcome="Bonded", outcome_color="Brown")
|
||||||
|
self.assertEqual(ok, "") # Brown after the Greens: a Green's rescue
|
||||||
|
cases = {
|
||||||
|
"first sighting Orange not in documented pool for Alone/Center":
|
||||||
|
dict(company="Alone", direction="Toward the forest centre", first_sighting="Orange", outcome="Died before the hour"),
|
||||||
|
"Brown at the Shadow (rare) encounter, which has only Black/Blue":
|
||||||
|
dict(branch="Tree: the shadow (Blue or Black)", outcome="Bonded", outcome_color="Brown"),
|
||||||
|
"Red at the Passed the Red: meadow encounter":
|
||||||
|
dict(branch="Valley: passed the Red, the meadow", outcome="Incinerated at a bonding encounter", outcome_color="Red"),
|
||||||
|
"Green recorded on a Valley run":
|
||||||
|
dict(hour="Went to the valley centre", outcome="Bonded", outcome_color="Green"),
|
||||||
|
"does not follow 'Ignore the scream'":
|
||||||
|
dict(scream="Kept walking (ignored it)", resolution="Bullies: my squadmate's revenge", outcome="Died before the hour"),
|
||||||
|
"fight answers on a run that did not help":
|
||||||
|
dict(scream="Kept walking (ignored it)", combat_first="Pause to assess", outcome="Died before the hour"),
|
||||||
|
"a path after the fight on a run without a fight":
|
||||||
|
dict(scream="Investigated, and walked away", post_path="West", outcome="Died before the hour"),
|
||||||
|
"a second fight move without pausing to assess":
|
||||||
|
dict(scream="Investigated, and helped my squadmate", combat_first="Charge the smaller cadet",
|
||||||
|
combat_second="Engage the smaller cadet", outcome="Died before the hour"),
|
||||||
|
"died before the hour, yet reached":
|
||||||
|
dict(scream="Investigated, and helped my squadmate", resolution="I died in the fight", outcome="Bonded", outcome_color="Red"),
|
||||||
|
}
|
||||||
|
for expected, answers in cases.items():
|
||||||
|
self.assertIn(expected, flags(**answers), expected)
|
||||||
|
|
||||||
|
def test_flagged_comment_runs_stay_out_of_the_route_model(self):
|
||||||
|
sys.path.insert(0, str(ROOT / "planner"))
|
||||||
|
import build_policy
|
||||||
|
rows = [{"source": "reddit comment", "data_flags": "read from a Reddit comment automatically, not checked by hand"},
|
||||||
|
{"source": "reddit comment", "data_flags": "read from a Reddit comment; Green recorded on a Valley run (no Greens in the valley)"},
|
||||||
|
{"source": "reddit spreadsheet", "data_flags": "multiple wings"},
|
||||||
|
{"source": "reported", "data_flags": "Green recorded on a Valley run (no Greens in the valley)"}]
|
||||||
|
kept = build_policy.drop_flagged(rows)
|
||||||
|
self.assertEqual([r["source"] for r in kept], ["reddit comment", "reddit spreadsheet", "reported"])
|
||||||
|
|
||||||
def test_delivered_not_extracted(self):
|
def test_delivered_not_extracted(self):
|
||||||
spec = read_yaml("collection/pipeline.yaml")["sources"]["reddit_comments"]
|
spec = read_yaml("collection/pipeline.yaml")["sources"]["reddit_comments"]
|
||||||
with self.assertRaises(extract.Skip):
|
with self.assertRaises(extract.Skip):
|
||||||
|
|||||||
Reference in New Issue
Block a user