diff --git a/analysis/black/evidence.py b/analysis/black/evidence.py
index 604c154..ca2baea 100644
--- a/analysis/black/evidence.py
+++ b/analysis/black/evidence.py
@@ -20,6 +20,7 @@ sys.path.insert(0, str(ROOT / "core"))
from atlas import runs as runs_io # noqa: E402
OUT = ROOT / "analysis/reports/BLACK.md"
+OUT_JSON = ROOT / "data/public/black.json" # the same numbers, for the page
ROUTE = ["company", "direction", "combat_first", "combat_second", "resolution", "post_path"]
ROUTE_NAMES = "company, first direction, first move in the fight, the dagger, the bullies' fate, the fork"
@@ -97,8 +98,10 @@ def blue_mistake(note):
def build():
+ """(the report as Markdown, its key numbers as a dict for the page)."""
runs = runs_io.read()
G = [r for r in runs if gated_tree(r)]
+ facts = {"schema": 1, "by_attempt": {}}
L = ["# The Black dragon: what the runs show", "",
"Written by `analysis/black/evidence.py` from `data/public/runs_clean.csv`. Counts only; nothing is fitted. "
"\"Gated tree runs\" investigated the scream, helped the squadmate and climbed the tree, the two gates the "
@@ -114,6 +117,7 @@ def build():
for g in ("form", "bulk logs", "bot"):
rs = [r for r in G if group(r) == g and r["attempt"] and lo <= r["attempt"] <= hi]
cells.append(frac(sum(bool(r["saw_shadow"]) for r in rs), len(rs)))
+ facts["by_attempt"].setdefault(g, {})[name] = [sum(bool(r["saw_shadow"]) for r in rs), len(rs)]
L.append(f"| {name} | " + " | ".join(cells) + " |")
cells = []
for g in ("form", "bulk logs", "bot"):
@@ -136,6 +140,10 @@ def build():
c[i] += bool(r["saw_shadow"])
c[i + 1] += 1
orr, obs, exp, z = mantel_haenszel(by.values())
+ facts["same_route"] = {"routes": len(by), "first_shadows": round(obs), "expected": round(exp, 1),
+ "odds_ratio": round(orr, 1), "z": round(z, 1)}
+ facts["form_first"] = [sum(c[0] for c in by.values()), sum(c[1] for c in by.values())]
+ facts["form_later"] = [sum(c[2] for c in by.values()), sum(c[3] for c in by.values())]
L += ["## 2. The same route on a first attempt and on a later one", "",
f"If the shadow depended only on the choices the form records ({ROUTE_NAMES}), a route would do as well on a "
"later attempt as on a first. It does not.", "",
@@ -151,6 +159,7 @@ def build():
# 3. is it decided by route + cadet assignment?
best_key, best = max(((k, v) for k, v in by.items() if v[1] >= 20), key=lambda kv: kv[1][0] / kv[1][1])
+ facts["best_route"] = {"route": list(best_key), "first": [best[0], best[1]], "later": [best[2], best[3]]}
B = [r for r in F if r["attempt"] == 1 and tuple(r[k] for k in ROUTE) == best_key]
cells = tally(B, lambda r: (r["wing"], r["section"], r["squad"]))
multi = {k: v for k, v in cells.items() if v[1] >= 2}
@@ -178,6 +187,7 @@ def build():
t = collections.Counter(r[col] for r in S1)
L.append(f"- **{label}:** " + ", ".join(f"{k} {v}" for k, v in t.most_common()))
outside = [r for r in runs if r["saw_shadow"] and not (r["scream"] == "Investigate & help" and r["hour"] == "Tree")]
+ facts["shadow_routes"] = {"runs": len(S1), "routes": len({tuple(r[k] for k in ROUTE) for r in S1}), "off_gate": len(outside)}
L += ["", f"Shadows reported without both gates: {len(outside)} (likely mis-entered).", ""]
# 5. after the shadow
@@ -190,6 +200,9 @@ def build():
ans[a][0] += r["outcome"] == "Bonded"
ans[a][1] += 1
blue_dead = [r for r in SH if r["enc_Blue"] == "Incinerated"]
+ facts["after_shadow"] = {"reached_black": len(black), "bonded_black": sum(r["outcome"] == "Bonded" for r in black),
+ "died_at_blue": len(blue_dead),
+ "answers": {k: [y, n] for k, (y, n) in sorted(ans.items(), key=lambda kv: -kv[1][1])}}
mis = collections.Counter(blue_mistake((r["bond_note"] or "") + " " + (r["death_note"] or "")) for r in blue_dead)
L += ["## 5. After the shadow: the Blue, then the Black", "",
"The riders' notes describe one sequence: follow the shadow, a Blue lands and burns another cadet, the Blue "
@@ -224,6 +237,9 @@ def build():
cur = cur + 1 if s is not None and s == prev else (1 if s is not None else 0)
prev, streak = s, max(streak, cur)
botg = [r for r in G if group(r) == "bot"]
+ facts["bot"] = {"attempts": len(seen), "accounts": len(acc), "gated_tree": len(botg),
+ "shadows": sum(bool(r["saw_shadow"]) for r in botg),
+ "earliest_attempt": min((min(v) for v in acc.values() if v), default=0)}
routes = collections.Counter(tuple(r[k] for k in ROUTE) for r in botg)
L += [f"{len(seen)} attempts on {len(acc)} accounts; the earliest attempt logged on any account is number "
f"{min((min(v) for v in acc.values() if v), default=0)}. Gated tree runs: {len(botg)}, shadows "
@@ -231,21 +247,24 @@ def build():
f"(the commonest {routes.most_common(1)[0][1] if routes else 0} times). The bot has not played a first attempt, "
"so it has not yet tested the one situation where riders report the shadow. The most times any account has "
f"repeated one route in a row is {streak}.", ""]
- return "\n".join(L) + "\n"
+ return "\n".join(L) + "\n", facts
def main(argv=None):
ap = argparse.ArgumentParser(description=__doc__)
ap.add_argument("--check", action="store_true")
a = ap.parse_args(argv)
- text = build()
+ text, facts = build()
+ data = json.dumps(facts, ensure_ascii=False, indent=1) + "\n"
if a.check:
- if not OUT.exists() or OUT.read_text(encoding="utf-8") != text:
- print(f"{OUT} is out of date (run python analysis/black/evidence.py)", file=sys.stderr)
- return 1
+ for path, want in ((OUT, text), (OUT_JSON, data)):
+ if not path.exists() or path.read_text(encoding="utf-8") != want:
+ print(f"{path} is out of date (run python analysis/black/evidence.py)", file=sys.stderr)
+ return 1
return 0
OUT.write_text(text, encoding="utf-8")
- print(f"wrote {OUT.relative_to(ROOT)}")
+ OUT_JSON.write_text(data, encoding="utf-8")
+ print(f"wrote {OUT.relative_to(ROOT)} and {OUT_JSON.relative_to(ROOT)}")
return 0
diff --git a/data/public/black.json b/data/public/black.json
new file mode 100644
index 0000000..ca390ba
--- /dev/null
+++ b/data/public/black.json
@@ -0,0 +1,147 @@
+{
+ "schema": 1,
+ "by_attempt": {
+ "form": {
+ "1": [
+ 89,
+ 879
+ ],
+ "2": [
+ 0,
+ 288
+ ],
+ "3": [
+ 0,
+ 184
+ ],
+ "4-10": [
+ 0,
+ 506
+ ],
+ "11-30": [
+ 0,
+ 573
+ ],
+ "31 or more": [
+ 1,
+ 610
+ ]
+ },
+ "bulk logs": {
+ "1": [
+ 0,
+ 28
+ ],
+ "2": [
+ 0,
+ 21
+ ],
+ "3": [
+ 0,
+ 14
+ ],
+ "4-10": [
+ 0,
+ 102
+ ],
+ "11-30": [
+ 0,
+ 57
+ ],
+ "31 or more": [
+ 0,
+ 0
+ ]
+ },
+ "bot": {
+ "1": [
+ 0,
+ 0
+ ],
+ "2": [
+ 0,
+ 4
+ ],
+ "3": [
+ 0,
+ 5
+ ],
+ "4-10": [
+ 0,
+ 36
+ ],
+ "11-30": [
+ 0,
+ 137
+ ],
+ "31 or more": [
+ 0,
+ 54
+ ]
+ }
+ },
+ "same_route": {
+ "routes": 321,
+ "first_shadows": 85,
+ "expected": 36.4,
+ "odds_ratio": 626.3,
+ "z": 11.9
+ },
+ "form_first": [
+ 89,
+ 879
+ ],
+ "form_later": [
+ 1,
+ 2161
+ ],
+ "best_route": {
+ "route": [
+ "Alone",
+ "West",
+ "Assess the situation",
+ "Engage the smaller cadet",
+ "Squadmate's revenge",
+ "West"
+ ],
+ "first": [
+ 22,
+ 88
+ ],
+ "later": [
+ 0,
+ 89
+ ]
+ },
+ "shadow_routes": {
+ "runs": 93,
+ "routes": 46,
+ "off_gate": 3
+ },
+ "after_shadow": {
+ "reached_black": 76,
+ "bonded_black": 55,
+ "died_at_blue": 15,
+ "answers": {
+ "held its gaze": [
+ 30,
+ 42
+ ],
+ "lowered eyes": [
+ 0,
+ 7
+ ],
+ "ignored the sound": [
+ 0,
+ 1
+ ]
+ }
+ },
+ "bot": {
+ "attempts": 415,
+ "accounts": 14,
+ "gated_tree": 236,
+ "shadows": 0,
+ "earliest_attempt": 2
+ }
+}
diff --git a/site/atlas/app.js b/site/atlas/app.js
index b494c3c..5794df8 100644
--- a/site/atlas/app.js
+++ b/site/atlas/app.js
@@ -588,7 +588,7 @@
L.push("");
L.push(`Interactive route map, full methods, and code to reproduce every number: [Threshing Route Atlas](LINK)`);
L.push("");
- L.push(`*Caveats: self-reported data, no player IDs (so runs from one person aren't independent), and the form doesn't record every in-game choice. The author has said there's a ~10% chaos roll, so nothing is guaranteed.*`);
+ L.push(`*Caveats: self-reported data, no player IDs (so runs from one person aren't independent), and the form doesn't record every in-game choice. The game's author has said no single roll is worse than 1 in 20 and that the Black is not luck, but no route guarantees a bond.*`);
return L.join("\n");
}
$("#cp-reddit").addEventListener("click", () => copyText(redditPost(), "Reddit post"));
diff --git a/site/atlas/index.html b/site/atlas/index.html
index 6ab0587..5d59a5e 100644
--- a/site/atlas/index.html
+++ b/site/atlas/index.html
@@ -461,11 +461,12 @@ a { color: var(--accent); text-underline-offset: 2px; }
In the books, first-years who survive to Threshing walk into a valley of unbonded dragons, and the dragons do the choosing. The Dragonkind site recreates that: every choice can end with you incinerated, and the author has said there is a 10% chance of that no matter what you pick. In the books, first-years who survive to Threshing walk into a valley of unbonded dragons, and the dragons do the choosing. The Dragonkind site recreates that: every choice can end with you incinerated, and its author has said no single roll is worse than 1 in 20 and that the Black is not luck.How a run unfolds
Every run anyone logs ends up in the Atlas's open data, runs_clean.csv, which anyone can download and reuse. Deaths are as useful as bonds: the odds on this page are only as good as the runs behind them. Please report each run in one place only.
A short form with the game's own choices: an issue on the Atlas's repository at {{host}}, so you need an account there. Reports show up in the data the next day with the source reported. Everyone who can see the repository can read reports: please leave out your account name.
- -The r/fourthwing megathreads collect runs with u/ClumsyBadger's Google Form, and its answers go into a public spreadsheet. The Atlas reads that spreadsheet every day (source reddit spreadsheet), so a run logged there is counted here too.
+The easiest way, no account needed. The r/fourthwing megathreads collect runs with u/ClumsyBadger's Google Form, and its answers go into a public spreadsheet. The Atlas reads that spreadsheet every day (source reddit spreadsheet), so a run logged there is counted here.
Threshing Routes form The responses spreadsheet The megathread
The form is anonymous and can be filled in once per attempt. Its author asks for random runs too (just pick the top option each time): they show which choices matter without the bias of everyone copying the same "best" route.
A short form with the game's own choices: an issue on the Atlas's repository at {{host}}, so you need an account there. Reports show up in the data the next day with the source reported. Everyone who can see the repository can read reports: please leave out your account name.
+ +| Source | What it is |
|---|---|
| reddit spreadsheet | The community form and spreadsheet linked from the r/fourthwing megathreads. |
| reported | Runs reported here, with "Report a run". |
| register | The Unofficial Dragon Register: which dragon each rider bonded (no route). |
| reddit thread | Dragonkind result pages posted in the megathreads (the dragon is known, the route is not). |
| bot | Runs logged by the DragonKind bot. |
| reddit pdf | The community route PDF: a map of the choices, used to check the game's routes (it holds no runs). |