54 Commits
Author SHA1 Message Date
ekcSchianoandClaude Opus 5.5 ee07ee143e docs: project context for picking the project up in a new conversation
CI / test (push) Canceled after 0s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UCzTd31GphpMXDhQqWrCMQ
2026-11-12 02:56:00 +00:00
ekcSchianoandClaude Opus 5.5 4837332a7d Refresh to 8,132 spreadsheet runs; rebuild generated files for the Gitea links
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UCzTd31GphpMXDhQqWrCMQ
2026-11-12 02:46:31 +00:00
ekcSchianoandClaude Opus 5.5 614bfcda7c Host on Gitea: forge.yaml, Gitea workflows, host-neutral links
- forge.yaml: the repository's host (Gitea at git.kenschiano.net, limited visibility);
  the "Report a run" collector, the page's links (data/public/links.json, filled in by
  site/build.js) and the dataset metadata read it
- collection/etl/forge.py: issues, pull requests (merge when checks succeed) and labels
  for Gitea and GitHub; `python -m collection forge ...`
- .gitea/workflows: CI and the daily update (pushes a branch, opens a pull request that
  merges itself, opens an issue when a source breaks); .github/workflows kept for GitHub
- docs: Gitea setup (REPO_SETTINGS), the bot reading atlas files from the repository

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UCzTd31GphpMXDhQqWrCMQ
2026-11-12 02:46:17 +00:00
ekcSchianoandClaude Opus 5.5 8713ccff1a Refresh to 7,775 spreadsheet runs; route model learns from the bot and corrects for reporting bias
- spreadsheet 5,988 -> 7,775 runs; new route PDF (Black Dragon Gates); register unchanged
- form.yaml: 'Protect / Help Squadmate' -> Protect squadmate
- policy, statistics, graph, metadata rebuilt

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UCzTd31GphpMXDhQqWrCMQ
2026-11-12 01:31:11 +00:00
ekcSchianoandClaude Opus 5.5 8f1f0383fe Game: which dragons each encounter can give; impossible bonds are not counted
A form row recording a Green bonded at the shadow Blue let the "eventually" objective
find a route whose only possible bond was that Green (ratio 1, near-zero chance).
game.yaml now lists the possible bonds per encounter (own colour; the two Greens also
Orange and Brown); anything else is a data-entry error and is not counted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UCzTd31GphpMXDhQqWrCMQ
2026-11-10 02:36:49 +00:00
ekcSchianoandClaude Opus 5.5 64fd3af235 Game: the shadow is gated on investigating the scream and helping
- game.yaml: chance events can have `requires` (a gate) and `otherwise`; the shadow
  requires "Investigate the scream" and "Help your squadmate" (the route PDF's Black
  Dragon Gates; spreadsheet: 78 shadows in 4199 gated tree runs, 2 in 646 others)
- model and advisor: a closed gate fixes the roll; runs off the gate are not counted
- form.yaml: "Protect / Help Squadmate" (new answer) -> Protect squadmate

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UCzTd31GphpMXDhQqWrCMQ
2026-11-10 02:33:07 +00:00
ekcSchianoandClaude Opus 5.5 2271fe0976 Route model: correct for reporting bias
- core/atlas/bias.py: for each rare roll (shadow, meadow Blue) and each source group,
  the factor by which the group over-reports the rare outcome relative to complete
  logging (bot, bulk logs), with a 90% range; rare outcomes from biased groups count
  1/rho; a roll the complete logs have (almost) never shown is learned from them only
- planner/policy.yaml: groups, rolls and thresholds; estimates published in
  policy.json under model.reportingBias
- fit_alpha: a roll seen only one way is pooled fully
- docs: goal accounts follow the best route, research accounts use Thompson sampling
  (decisionMode atlas_thompson)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UCzTd31GphpMXDhQqWrCMQ
2026-11-10 02:29:09 +00:00
ekcSchianoandClaude Opus 5.5 c0355616b6 Route model learns from bot runs; Thompson sampling in the advisor (work in progress)
- planner/policy.yaml: which sources the route model learns from (spreadsheet,
  reported, bot) and the low-bias sample
- bot runs: deaths coded by stage, Malek intent for runs with a target
- model: survival of the first dragon is not counted when nothing after it is
  known; the meadow dragon falls back to what the bot saw
- solver.js: advisor(..., {sampling: "thompson", seed, draws}) follows one
  posterior draw per attempt and reports each pick's propensity

Not shipped yet: mixing sources lowers the fitted shrinkage for the shadow roll
(alpha 500 -> 50 in the low-bias sample), see the conversation of 2026-11-09.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UCzTd31GphpMXDhQqWrCMQ
2026-11-10 02:29:09 +00:00
ekcSchianoandClaude Opus 5.5 d37eaa3378 Import Ken's bot runs (13 accounts, 415 attempts, to 2026-11-10)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UCzTd31GphpMXDhQqWrCMQ
2026-11-10 02:09:26 +00:00
ekcSchianoandClaude Opus 5.5 43066ad67f Bot import: one folder per account, run records with steps
- the importer reads data/accounts/*/runs.jsonl and logs/accounts/*/encounters.jsonl;
  with account folders, the top-level files (a mirror of the first account) are skipped
- run records that carry their steps (schema 2) become trajectories directly, keeping
  what the bot saw (shadow, meadow dragons), propensities, decision mode and policy id;
  older runs are still rebuilt from the decision log; bonded runs without steps are kept
- account names become salted hashes (DK_ACCOUNT_SALT, or a private salt in data/raw)
- runs_clean.csv: new bot_mode column; saw_shadow and saw_blue_meadow from what the bot
  saw; deliberate burns say why
- crosswalk: the valley Red, leaving squadmates, squad direction, hold your ground,
  hide/approach reactions, the wounded cadet's other two choices

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UCzTd31GphpMXDhQqWrCMQ
2026-11-10 02:08:57 +00:00
ekcSchianoandClaude Opus 5.5 dd25dfaa32 Record the local bot data as imported (same 6 runs as the sample)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UCzTd31GphpMXDhQqWrCMQ
2026-11-10 01:52:46 +00:00
ekcSchianoandClaude Opus 5.5 5c49591dae Hand-offs without GitHub: bot kit zip, bot zip import, local refresh
- python -m collection export-bot-kit: policy.json, solver.js, graph.js and a
  README with checksums, zipped for the bot
- the bot import takes a folder or a zip (files may sit under any top folder)
- python -m collection refresh: the daily workflow, run locally
- trajectories files are named by date and raw checksum, so two imports on
  one day never overwrite each other

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UCzTd31GphpMXDhQqWrCMQ
2026-11-10 01:50:12 +00:00
ekcSchianoandClaude Opus 5.5 19209a2ad6 Report a run: link the Threshing Routes Google Form
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UCzTd31GphpMXDhQqWrCMQ
2026-11-04 02:57:19 +00:00
ekcSchianoandGitHub 9f1bb3d3b5 Merge pull request #15 from ekcSchiano/collection/etl
Data collection as an ETL pipeline; every source in runs_clean.csv; Report a run
2026-11-03 21:47:59 -05:00
ekcSchianoandClaude Opus 5.5 3b24a11f5a Collection as an ETL pipeline; runs_clean.csv from every source; Report a run
- collection/pipeline.yaml declares every source (extract kind, transform,
  privacy rules, load target, run source); `python -m collection update|build`
- extract keeps data/raw/<source>/current + previous only (git-ignored);
  data/manifest.json records the current raw checksum and change date
- transforms are pure; validate checks runs against data/dictionary.yaml
  before load; load writes byte-stable files only when they change
- data/public/runs_clean.csv: every run from every source with a new
  `source` column (reddit spreadsheet, reddit thread, reported, bot,
  reddit pdf); the sheet's own row label moves to `entry`; run_id is text
- bot importer ported to Python (same output as bot.js on the fixture);
  labels and crosswalk in collection/specs/bot.yaml, written into graph.js
- Reddit through the official API (result links to add by hand); the 12
  result pages move to collection/manual/reddit_results.yaml
- "Report a run": a GitHub issue form generated from
  collection/specs/report_form.yaml, collected as source "reported", plus a
  site tab pointing to it, the community spreadsheet and the megathread
- analysis and the route model read runs_clean.csv (sources in
  measures.yaml); stats.json and policy.json unchanged apart from the
  factor's new name
- daily workflow runs the pipeline; the raw store is kept between runs in
  the Actions cache, encrypted with RAW_ARCHIVE_KEY

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UCzTd31GphpMXDhQqWrCMQ
2026-11-04 02:46:48 +00:00
ekcSchianoandGitHub 61bc50583c Merge pull request #14 from ekcSchiano/data/dictionary
Step 5: data dictionary and Croissant metadata
2026-11-03 20:38:21 -05:00
ekcSchianoandClaude Opus 5.5 63b5d40e54 Step 5: data dictionary and Croissant metadata
- data/dictionary.yaml: every published file, and every column of runs_clean.csv
  with its type, meaning and allowed values
- collection/publish_metadata.py writes data/croissant.json (Croissant 1.0) from
  it, with a sha256 per file; `npm run metadata`, run by the daily update
- tests/core/test_dictionary.py: every column and value described, types hold,
  croissant.json up to date and checksums match
- attempt is now written as a whole number (was 1.0, 2.0); no statistic changes
- the site ships both files and the Methods text links them

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UCzTd31GphpMXDhQqWrCMQ
2026-11-04 01:37:10 +00:00
11b4a0398e Core: a small JS advisor reads the game from policy.json; engine.js is gone (#13)
Step 4b of the Python-first core.

- core/solver.js is now a 250-line advisor (was 900 lines): it reads the game (core/spec/game.yaml,
  published inside policy.json as model.game) and the count tables, and re-solves from any point in
  a run with the same interpreter as the Python model. Same API for the site and Ken's bot
  (advisor, recommendOption, solverHistory). The bot's on-screen text for each option moves to
  game.yaml (bot_text); the deadly rolls carry their risk labels there too.
- tests/core/advisor.test.js: the advisor gives exactly the Python model's values and choices for
  every colour and goal (to 1e-12, every decision on every published route), walks a run in the
  game's order, and maps advice onto the bot's screen.
- Removed core/engine.js and everything that only compared it with Python (tests/parity/run_engine,
  compare_runs, compare_results, compare_routes, compare_solver, compare_stats, analysis/stats/
  analyze.py). In their place: tests/core/test_stats.py checks the statistics against known answers,
  test_solver.py checks the route model on a synthetic world (tests/fixtures/synthetic_policy.py).
- analysis/network/build-graph.js reads the Python-coded runs; graph.json is byte-identical.
- docs/BOT_INTEGRATION.md: what changed for the bot (history keys, new choices, re-sync all three files).


Claude-Session: https://claude.ai/code/session_01UCzTd31GphpMXDhQqWrCMQ

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-03 22:01:32 +00:00
d04b88e7b4 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>
2026-11-03 21:37:10 +00:00
963b08c522 Core: fix three coding bugs from the core review, with rule tests (#11)
1. Letting the Red pass. Only climbing down quickly puts you above the Red, so a tree run that
   passed on the Red and then met the Greens let it pass. Those 16 runs were coded as slow
   descents; they are now "Descend quickly: let the Red pass" and count for the Greens'
   encounter, so the route model's "let it pass" option rests on its own runs. A tree run with
   both the Red and the Greens attempted (impossible in one run) is now flagged.
2. Leaving your squadmates. The form only offered "> Left them" from 2026-10-27 (0 of 504 squad
   runs before chose it, 40 of 144 after). Earlier and undated squad runs are now unknown rather
   than "stayed together" (form.yaml: left_squadmates_asked_from).
3. Bot text. The wounded cadet's other two choices map onto the form; a test checks every choice
   the bot has logged maps onto a form variable (encounter answers excepted, not modelled yet).

Each rule has a test in tests/core/test_coding.py. Data rebuilt (runs, graph, policy, report);
the headline odds move by at most 0.02 points. The Methods tab describes both rules.


Claude-Session: https://claude.ai/code/session_01UCzTd31GphpMXDhQqWrCMQ

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-03 21:12:34 +00:00
cc86343668 Core: the route model in Python, built from a declarative game.yaml (#10)
Step 2 of the Python-first, declarative core.

- core/spec/game.yaml: the game as data: every decision and its options, every roll and the
  earlier steps its odds may depend on, every bonding encounter, and the flow of a run from the
  entrance to the dragons (set / keep / drop / go / end / encounter). Also how the form's coded
  answers map onto the game.
- core/atlas/model.py: what each coded run reveals about each step, count tables, empirical-Bayes
  shrinkage, and the posterior draws (same random numbers as before, reproducible from the seed).
- core/atlas/solver.py: one interpreter of game.yaml used three ways (solve, evaluate a fixed
  policy, export the published tree) instead of the tree written out five times. Vectorised
  over the 200 posterior draws: the build takes about 2 minutes instead of 4, with no memory flag.
- planner/build_policy.py and policy_report.py replace the JS build and report.

Checked against the JavaScript model: every number in policy.json agrees to within 4e-12
(last-digit differences in log/cos). Three "still best" shares differ by one draw in 200, at
near-ties under the "eventually" objective. POLICY.md is otherwise identical.
tests/parity/compare_solver.py keeps checking JS against Python in CI until the site's JS advisor
replaces solver.js; tests/core/test_game.py checks game.yaml is complete and consistent.


Claude-Session: https://claude.ai/code/session_01UCzTd31GphpMXDhQqWrCMQ

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-03 21:04:21 +00:00
3536007ade Core: coding rules as declarative form.yaml + Python package (atlas.coding) (#9)
Step 1 of moving the repo to Python with declarative rules.

- core/spec/form.yaml: every question (how it is found in an export), every answer and what it
  is coded as, missing answers, email redaction, burn order, first-dragon pools.
- core/atlas/coding.py reads it and replaces core/python/clean.py (python -m atlas.coding).
- tests/core/test_coding.py: 16 rule tests, one hand-written row per rule, checking the rules
  are right rather than only that JS and Python agree.
- analysis/stats/analyze.py takes the colours and missing answers from the spec instead of its
  own copy; the daily update job codes rows through the package.
- pyproject.toml for the package; pyyaml and pytest added to requirements.

The coded runs are byte-identical to before (5,988 runs); all parity checks still match.


Claude-Session: https://claude.ai/code/session_01UCzTd31GphpMXDhQqWrCMQ

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-03 15:27:13 -05:00
432e04c2c7 Refactor: lay the repo out by section (core, collection, analysis, planner, site) (#8)
Moves only; no behaviour changes. Every file now lives under the part of the project it
belongs to, each section has a README, and docs/PRIVACY.md collects the rules all parts follow.

  core/        engine.js, graph.js, solver.js, python/clean.py
  collection/  sources/ (form, register, PDF check, daily update), bot/ (importer)
  analysis/    stats/ (Python statistics), network/ (build-graph.js), reports/ (POLICY.md)
  planner/     build-policy.js, policy-report.js
  site/        atlas/ (the page), build.js, qa/
  tests/       core/ (unit), parity/ (JS vs Python), fixtures/

Checked against the previous layout: tests pass; coded runs, test outputs, graph.json and
policy.json are byte-identical; the built site differs only in comments that name file paths.
The published file names Ken's bot downloads (solver.js, graph.js, data/policy.json) are unchanged.

Also removes the undefined/ folder of QA screenshots committed by mistake (the QA scripts now
default to a temp folder) and test.txt, and drops the unused npm workspaces.


Claude-Session: https://claude.ai/code/session_01UCzTd31GphpMXDhQqWrCMQ

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-03 19:46:33 +00:00
dcd5117373 Data updates: open the PR with ATLAS_BOT_TOKEN and auto-merge it once CI passes (#7)
Changes made with GITHUB_TOKEN do not start other workflows, so a merged data PR would not
redeploy the site. With the ATLAS_BOT_TOKEN secret the workflow opens the PR with it and turns
on auto-merge; without it, it falls back to GITHUB_TOKEN and a manual merge. docs/REPO_SETTINGS.md
lists the settings only the owner can change (auto-merge, the ruleset for main, the token).

Refs #4, #5, #6


Claude-Session: https://claude.ai/code/session_01UCzTd31GphpMXDhQqWrCMQ

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-03 19:20:30 +00:00
kschiano 2b905b4a84 getting on contributor list 2026-11-03 12:40:37 -05:00
w4iteyandGitHub cfcbe54486 Merge pull request #3 from ekcSchiano/data/source-update
New data from the community sources
2026-11-03 11:49:17 -05:00
ekcSchianoandgithub-actions[bot] df103ae1fa data: update from community sources 2026-11-03 11:21:28 +00:00
ekcSchianoandClaude Opus 5.5 0b025af0f0 Valley map: progressive disclosure of choices
The idle map shows only the key moments (the entrance, the three directions, the scream, the
bully fight, the wounded cadet, the hour's walk, the tree, the valley centre, the meadow and the
shadow). Clicking one reveals the choices made there as places on the map and as chips in the
panel (each a further place to start from, with a way back), plus the best route to every
dragon. A picked dragon shows only the places on its routes; opening a choice adds the others.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UCzTd31GphpMXDhQqWrCMQ
2026-11-02 21:02:42 +00:00
ekcSchianoandClaude Opus 5.5 83bc19521e Route model: every logged choice; map keeps your choices on every route
Solver: adds leaving your squadmates, your reaction to the first dragon (options offered per
dragon, from the form's categories) and, below the tree, jumping onto the Red or letting it pass
to the two Greens. Bot crosswalk and option patterns map the game's text for each.

Map: a choice you make now holds for every route to that dragon, together with the earlier steps
of the path you were looking at, so a later choice never sends the route back through another
place. Routes your choices rule out are hidden; choosing an option closes its card.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UCzTd31GphpMXDhQqWrCMQ
2026-11-02 20:50:59 +00:00
ekcSchianoandClaude Opus 5.5 c2dcaee16f Valley map: show every choice's place from the start
Company (alone, one or two squadmates), walking away from the fight, all six cadet
resolutions and the three forks are now on the map before any route is drawn, and each can
be clicked as a starting point. The hint moves to the top so it no longer covers the start.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UCzTd31GphpMXDhQqWrCMQ
2026-11-02 20:28:10 +00:00
ekcSchianoandClaude Opus 5.5 5f66b9647a Bully fight: add the first move and the dagger choice to the solver and the map
After helping your squadmate the game asks your first move (pause to assess, charge the
smaller cadet, or get between your squadmate and the bigger one) and, after pausing, what to
do about the smaller cadet's dagger. Both are now decisions in the solver, and the chance of
dying in the fight depends on them (about 3 in 10 riders who charged in died; almost none who
paused). With that split, helping now beats walking away.

On the map, several choices made at one place share one diamond, which opens a card listing
each choice in the game's order. Policy rebuilt; the policy build gets a larger heap.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UCzTd31GphpMXDhQqWrCMQ
2026-11-02 20:09:13 +00:00
ekcSchianoandClaude Opus 5.5 1646844fa6 Valley map: bully fight starts at the fight's outcomes; figures moved off the place
Clicking the bully fight now assumes you stepped in, so every dragon's route fans out
through the bullies' fate and the forks (like the wounded cadet), counting the risk of
dying in the fight. The three fighters sit beside the clearing instead of on its marker.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UCzTd31GphpMXDhQqWrCMQ
2026-11-02 19:32:13 +00:00
ekcSchianoandClaude Opus 5.5 68587a55f0 Valley map: start from any place and see every dragon's best route from there
Click a place name before choosing a dragon to see your chance of each dragon
from that point on, one coloured route per dragon, with a panel that ranks them
and links into each route kept through that place. Deep link: #valley/at/<place>.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UCzTd31GphpMXDhQqWrCMQ
2026-11-02 19:24:27 +00:00
ekcSchianoandClaude Opus 5.5 e8c177fc15 Cadet encounter in the game's real order
The solver treated the cadet encounter as one seven-way choice made at the
first dragon, so the map put a diamond there with no matching choices. It is
now a sequence, as in the game: at the scream, investigate or keep walking;
in the clearing, help your squadmate or walk away; then the bullies' fate
(after surviving the fight) or what to do for the wounded cadet. Each
choice point sits at its own place on the map and opens only its own
options; an option that stays in the same place (helping, in the clearing)
appears as a clickable label there. Bot histories that only know the final
resolution still resolve correctly; the bot advisor maps each step onto the
screen text. Policy rebuilt; tests added.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UCzTd31GphpMXDhQqWrCMQ
2026-11-02 19:07:39 +00:00
ekcSchianoandClaude Opus 5.5 99f60282ed Polish: full-width text, links and bold, methods tabs, readable map choices
- Prose no longer stops at ~70 characters; it uses its column's full width.
- Sources linked (responses sheet, route PDF, register, megathreads, Reddit
  users, Dragonkind, the repo) and statistical methods linked to their
  references; key terms and numbers in bold.
- Data & Methods: the seven method sections are now tabs (arrow keys work).
- Valley map: when a choice point is opened, each option's chance sits under
  its own labelled place and overlapping labels are pushed apart; small
  choice points can label above themselves. Checked: no overlapping text for
  any dragon and any opened choice.
- Register cards: the age sits inside the arch; all-caps names shown normally.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UCzTd31GphpMXDhQqWrCMQ
2026-11-02 18:26:05 +00:00
ekcSchianoandClaude Opus 5.5 7366af2f7d Release pass: wording, colour-blind-safe colours, map visibility, phone layout
Walked every tab on desktop and phone, clicked every link and button:
- Colours: new map inks and page colours, checked with simulated
  protanopia/deuteranopia/tritanopia (worst pair ~12 CIEDE2000, was 1.4 for
  Red/Green on the map and 9.7 for Orange/Brown on the page). Map label text
  is always dark ink; dragon colour goes on borders. docs/COLOURS.md and
  research/python/check_colours.py.
- Valley map: dragons get a paper halo and a visibility floor (faded ones never
  drop below 0.3; bonding dragons start at 0.5); "no shadow" roll labelled
  correctly.
- Wording: methods updated (strata, the newer form's questions, missing
  answers, a new section on the solver, The Odds cards and genuine attempts);
  findings use readable factor names and no longer claim a date adjustment;
  'Load a newer route export above'; code links include solver.js and
  explorer.js; The Odds shows 93% instead of '1 in 1'.
- Deep Dive route map treats all six dragons alike ('Bond a dragon' row,
  default 'Bond any dragon'; rare sightings separate).
- Phone: Deep Dive no longer overflows (sections and selects can shrink).
- scripts/qa/crawl.js and mapcheck.js for future release checks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UCzTd31GphpMXDhQqWrCMQ
2026-11-02 17:57:51 +00:00
ekcSchianoandClaude Opus 5.5 0ac5dfd971 The Odds: drop the easiest-to-hardest ladder (repeats the dragon cards)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UCzTd31GphpMXDhQqWrCMQ
2026-11-02 16:52:27 +00:00
ekcSchianoandClaude Opus 5.5 f0d9b80da8 Move 'Three things worth knowing' to Data & Methods
The three findings now open the Data & Methods tab; The Odds keeps its
cards, the run walkthrough and the buttons.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UCzTd31GphpMXDhQqWrCMQ
2026-11-02 16:48:58 +00:00
ekcSchianoandClaude Opus 5.5 efb54f3d7a The Odds: summary cards count cadets, not deliberate deaths
'Become a rider' and 'riders sent to Malek' now leave out runs where the rider
died on purpose (burned at an encounter they did not genuinely attempt, the
solver's genuineAttempt rule) and runs with no recorded outcome.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UCzTd31GphpMXDhQqWrCMQ
2026-11-02 16:39:07 +00:00
ekcSchianoandClaude Opus 5.5 3d1c09138d The Odds: shorten the 'become a rider' note
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UCzTd31GphpMXDhQqWrCMQ
2026-11-02 16:37:17 +00:00
ekcSchianoandClaude Opus 5.5 3b3622a08a The Odds: summary cards first, 'become a rider' card
Remove the 'Your odds, honestly' heading and intro. The two summary cards now
lead the page: 'become a rider' (runs that ended bonded to a dragon) and the
unchanged 'riders sent to Malek'. The reach-the-hour figure moves into the
first card's note.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UCzTd31GphpMXDhQqWrCMQ
2026-11-02 16:35:44 +00:00
ekcSchianoandClaude Opus 5.5 754e4f1eb8 Move the per-dragon statistics to Deep Dive
Bond rates for every dragon, the two Greens and the first-sighting table now
sit in Deep Dive next to the rare-dragon analysis; The Dragons tab is the
register only. The first-sighting table also drops rows whose company was
not recorded.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UCzTd31GphpMXDhQqWrCMQ
2026-11-02 16:26:08 +00:00
ekcSchianoandClaude Opus 5.5 790b7e6f5e See the route: open the valley on that dragon's most probable route
In-page links now keep their sub-path (#valley/blue) when switching tabs, and
a link to a dragon opens it fresh on its most probable route (earlier detours
cleared). Clicking the Valley tab itself keeps the current selection.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UCzTd31GphpMXDhQqWrCMQ
2026-11-02 16:22:34 +00:00
ekcSchianoandClaude Opus 5.5 2eace69d7d Valley map: cadets at the bully fight, the wounded cadet, and the thorn bush
Original silhouettes built from the same parts as the dragons: your squadmate
with a raised sword facing the two bullies (sword and dagger), the wounded
cadet on the ground, and a thorny bush at the hour's walk. Each has a short
hover note and fades when a chosen route does not pass it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UCzTd31GphpMXDhQqWrCMQ
2026-11-02 16:19:58 +00:00
ekcSchianoandClaude Opus 5.5 1b0ef9a2c1 Treat unsure and blank answers as missing information, not choices
- engine.js / analyze.py: one MISSING set ("Unknown", "Unsure",
  "Unsure/unknown", "Multiple", "(not recorded)", "(not asked)", ...).
  Factor tables compare only runs that answered each question and report how
  many were left out; models are complete-case for every choice variable;
  route rankings group only fully known routes; the route flow skips
  missing steps.
- "I've lost count" now counts as a later attempt.
- The chase goal keeps its "not asked" stratum as an adjustment only; it is
  no longer displayed as a finding.
- Page: no unknown levels in charts, tables or filters; factor explorer notes
  how many runs were left out; Methods explains the rule.
JS/Python parity still exact.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UCzTd31GphpMXDhQqWrCMQ
2026-11-02 16:14:08 +00:00
ekcSchianoandClaude Opus 5.5 de80e99c74 The Valley as the landing page: dragons first, routes on demand
- New tab order: The Valley, The Odds, The Dragons, Deep Dive, Data & Methods
  (Route Flow and Blue & Black fold into Deep Dive; methods into Data &
  Methods; old #links redirect).
- explorer.js replaces the trails map and the route planner, with progressive
  disclosure: the painted valley shows landmarks and the dragons where riders
  meet them (faint = rarely met), no routes and no deaths; hover for a note;
  choose a dragon to draw every route to every place it can be bonded, with
  width = chance of still being on the route, and solid / dashed / dotted and
  opacity for how a route compares with the best; click a choice point to
  branch off and re-plan; "Why this route?" holds intervals and risks; a
  toggle shows the community's actual traffic; #valley/blue/meadow-Blue links.
- dragons.js: original dragon silhouettes in six poses, built from simple
  parts.
- Solver: route to one specific encounter (only: [...]); ENCOUNTERS per
  colour, including the Greens rescue for Orange and Brown.
- The Odds rewritten for all six dragons, ranked easiest to hardest.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UCzTd31GphpMXDhQqWrCMQ
2026-11-02 14:24:47 +00:00
ekcSchianoandClaude Opus 5.5 bdf66afabc Route planner: the solver's options and odds drawn on the valley map
- New "Route Planner" tab: pick a dragon colour, a goal (only this dragon /
  best odds this run) and a data sample. The solver runs in the browser from
  policy.json and walks the valley: every decision shows each option's
  chance of bonding the colour (with the best play afterwards) and of
  reaching an encounter alive; every roll shows its probabilities; deaths
  show where they happen; "stays best in N% of re-runs" and "no clear
  winner" flag noisy recommendations. Click any option on the map or in the
  list to explore another branch.
- solver.js: values now carry P(reaching an encounter alive); advisor.step()
  gives the planner the next decision, roll or outcome at any history.
- valley.js shares its painting with the planner.
- Fix: route-map target chips no longer capture clicks on other chip rows.
- Pages build gets a doctype and charset.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UCzTd31GphpMXDhQqWrCMQ
2026-11-01 22:50:23 +00:00
ekcSchianoandClaude Opus 5.5 d2ffb84b5e Solver: best decisions per dragon colour, and the bot advisor
- packages/core/src/solver.js: decision tree with perfect recall over the
  community form's choices; chance events (first dragon, deaths, shadow,
  meadow dragon, encounter outcome) depend on earlier choices through
  hierarchical Dirichlet back-off with empirical-Bayes concentration per
  event; backward induction for P(colour this attempt) and Dinkelbach for
  P(colour) / (P(colour) + P(other colour)); 200 posterior draws for
  credible intervals and "still best" rates; cross-fitted held-out check.
- Only genuine attempts inform encounter outcomes (goal / Malek intent).
- data/public/policy.json (all runs and a low-bias sample) and the readable
  docs/POLICY.md; published on Pages with solver.js for the bot.
- Bot advisor: re-solves from any history, maps advice onto screen text,
  reports margins so ties can be randomised. docs/BOT_INTEGRATION.md.
- Tests on a synthetic world with known answers; daily source update now
  rebuilds the policy.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UCzTd31GphpMXDhQqWrCMQ
2026-11-01 22:34:38 +00:00
ekcSchianoandClaude Opus 5.5 46ee08a56b Coding rules for the redesigned community form; import the new data
The Threshing Routes form was redesigned (5,651 responses). Both implementations
(engine.js and clean.py) now read either version:
- one direction question + one colour question, with the older per-direction
  columns used only to fill gaps and cross-check
- cadet encounter as an action path (scream, first and second combat move)
  plus a separate outcome
- new fields: sighting_action, combat_second, rare_reported, malek_intent,
  left_squadmates, tail; "Why are you doing this run?" mapped onto the goal
  ("Blue or Black" for rare chasers)
- the rare-dragon question feeds saw_blue_meadow / saw_shadow and the branch
The old export still codes identically. JS/Python parity: all match.

Data: form 2,573 -> 5,651 rows, Dragon Register 216 -> 273, new route PDF
fingerprint. Supersedes the automated pull request #2.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UCzTd31GphpMXDhQqWrCMQ
2026-11-01 22:10:51 +00:00
ekcSchianoandGitHub 9c0e35423a Merge pull request #2 from ekcSchiano/data/source-update
New data from the community sources
2026-11-01 17:03:31 -05:00
ekcSchianoandgithub-actions[bot] 21f3c8fd84 data: update from community sources 2026-11-01 22:02:16 +00:00
ekcSchianoandClaude Opus 5.5 78baf9cec4 Fix source check: create the local raw folder; allow the workflow to open issues
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UCzTd31GphpMXDhQqWrCMQ
2026-11-01 22:01:22 +00:00
ekcSchianoandClaude Opus 5.5 c3d067b88c Threshing Atlas: monorepo, route graph, bot importer, daily source checks
- apps/atlas: the web page (valley map, route flow, Dragon Register)
- packages/core: coding rules and statistics (engine.js) and the shared route
  graph (graph.js): scene graph, decision-variable graph, bot-to-form crosswalk,
  Beta credible intervals
- packages/ingest: DragonKind bot importer to anonymised trajectories (no prose,
  no account identifiers); data/bot holds Ken's sample
- research/python: independent reference implementation + update_sources.py
- tests: JS/Python parity checks and graph/importer unit tests
- CI, GitHub Pages deploy, daily check of the community sheets and route PDF
- Email addresses in free-text form answers are redacted; the raw spreadsheet
  is not committed
- MIT code licence, CC BY 4.0 data licence

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UCzTd31GphpMXDhQqWrCMQ
2026-11-01 21:54:54 +00:00
ekcSchianoandGitHub 0052d1a5fd Initial commit 2026-11-01 16:17:21 -05:00
124 changed files with 19203 additions and 17389 deletions
+24
View File
@@ -0,0 +1,24 @@
# Tests on every push and pull request (Gitea Actions; GitHub's copy is .github/workflows/ci.yml).
# The branch rule for main (docs/REPO_SETTINGS.md) requires this check, named "CI / test".
name: CI
on:
push:
branches: [main]
pull_request:
jobs:
test:
runs-on: ubuntu-latest # a runner label on the server (act_runner); change it if the server uses another
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- run: pip install -r requirements.txt
- run: npm test
- name: graph.json is up to date
run: node analysis/network/build-graph.js && git diff --exit-code data/public/graph.json
- name: the page builds
run: node site/build.js
+92
View File
@@ -0,0 +1,92 @@
# Every day: check every source (collection/pipeline.yaml), and when something changed, rebuild the runs, the
# graph, the route model and the statistics, run the tests and open a pull request that merges itself once CI
# passes. A source that cannot be reached, or new answers the coding rules do not know, open an issue instead.
# Gitea Actions; GitHub's copy (with GitHub Pages) is .github/workflows/update-sources.yml.
#
# Secrets (repository Settings -> Actions -> Secrets; docs/REPO_SETTINGS.md):
# ATLAS_BOT_TOKEN a Gitea access token (repository: read and write; issue: read and write). Needed to push the
# update branch and open the pull request; the built-in token cannot start the CI it needs.
# RAW_ARCHIVE_KEY optional: encrypts the private raw store kept in the Actions cache between runs
# REDDIT_CLIENT_ID, REDDIT_CLIENT_SECRET optional: read the megathreads through the Reddit API
name: Check sources for new data
on:
schedule:
- cron: "23 10 * * *" # daily
workflow_dispatch:
jobs:
check:
runs-on: ubuntu-latest # a runner label on the server (act_runner)
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.ATLAS_BOT_TOKEN }}
- uses: actions/setup-node@v4
with:
node-version: 20
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- run: pip install -r requirements.txt
- name: Restore the private raw archive
uses: actions/cache/restore@v4
with:
path: ${{ runner.temp }}/raw-archive
key: raw-archive-none
restore-keys: raw-archive-
- name: Decrypt it
env:
RAW_ARCHIVE_KEY: ${{ secrets.RAW_ARCHIVE_KEY }}
run: |
f="$RUNNER_TEMP/raw-archive/raw.tgz.enc"
if [ -n "$RAW_ARCHIVE_KEY" ] && [ -f "$f" ]; then
openssl enc -d -aes-256-cbc -pbkdf2 -pass env:RAW_ARCHIVE_KEY -in "$f" | tar -xz -C data
fi
- id: check
env:
ATLAS_BOT_TOKEN: ${{ secrets.ATLAS_BOT_TOKEN }}
REDDIT_CLIENT_ID: ${{ secrets.REDDIT_CLIENT_ID }}
REDDIT_CLIENT_SECRET: ${{ secrets.REDDIT_CLIENT_SECRET }}
run: python -m collection update --report "$RUNNER_TEMP/report.md"
- name: Rebuild the analysis and run tests
if: steps.check.outputs.changed == 'true'
run: |
node analysis/network/build-graph.js
npm run policy
npm run stats
python -m collection build
npm test
- name: Encrypt the raw store
id: archive
env:
RAW_ARCHIVE_KEY: ${{ secrets.RAW_ARCHIVE_KEY }}
run: |
if [ -n "$RAW_ARCHIVE_KEY" ] && [ -d data/raw ]; then
mkdir -p "$RUNNER_TEMP/raw-archive"
tar -czf - -C data raw | openssl enc -aes-256-cbc -pbkdf2 -salt -pass env:RAW_ARCHIVE_KEY -out "$RUNNER_TEMP/raw-archive/raw.tgz.enc"
echo "save=true" >> "$GITHUB_OUTPUT"
fi
- name: Save it (a new copy only when a raw file changed)
if: steps.archive.outputs.save == 'true'
uses: actions/cache/save@v4
with:
path: ${{ runner.temp }}/raw-archive
key: raw-archive-${{ hashFiles('data/manifest.json') }}
- name: Open a pull request with the new data (it merges itself once CI passes)
if: steps.check.outputs.changed == 'true'
env:
ATLAS_BOT_TOKEN: ${{ secrets.ATLAS_BOT_TOKEN }}
run: |
branch="data/source-update-$(date -u +%Y%m%d)"
git config user.name "Atlas data bot"
git config user.email "atlas-bot@noreply.localhost"
git checkout -b "$branch"
git add -A data analysis/reports core/graph.js .github/ISSUE_TEMPLATE
git commit -m "data: update from community sources"
git push origin "$branch"
python -m collection forge open-pr --head "$branch" --title "New data from the community sources" --body-file "$RUNNER_TEMP/report.md" --automerge
- name: Report a broken source or new answers
if: steps.check.outputs.failed != ''
env:
ATLAS_BOT_TOKEN: ${{ secrets.ATLAS_BOT_TOKEN }}
run: |
python -m collection forge open-issue --title "Source check failed: ${{ steps.check.outputs.failed }}" --body-file "$RUNNER_TEMP/report.md"
+217
View File
@@ -0,0 +1,217 @@
# Written by collection/etl/report_form.py from collection/specs/report_form.yaml: edit that file, then run `python -m collection build`.
name: Report a run
description: Log one threshing run for the Threshing Atlas. Reports are public and become rows of runs_clean.csv.
title: Run report
labels:
- run report
body:
- type: markdown
attributes:
value: |
Thanks for reporting a run! Answer what you remember; leave anything you're unsure of on "Not sure".
Every answer here is visible to everyone who can see this repository (it is an issue) and goes into the Atlas's
open data as source "reported".
Please don't include your DragonKind account name or anything personal.
You can also use the community [Threshing Routes form](https://forms.gle/DRpj9tG8gb5E4Hcu7) linked from the r/fourthwing megathread; please report each run only once.
- type: dropdown
id: goal
attributes:
label: Which dragon were you trying to bond?
options:
- Red
- Green
- Orange
- Brown
- Blue
- Black
- Any, just for fun
- Not sure
validations:
required: false
- type: input
id: attempt
attributes:
label: Which attempt was this for your account? (a number; 1 = your first)
placeholder: e.g. 3
validations:
required: false
- type: dropdown
id: company
attributes:
label: Who entered the valley with you?
options:
- Alone
- One squadmate
- Two squadmates
validations:
required: true
- type: dropdown
id: left_squadmates
attributes:
label: If you went with squadmates, did you leave them?
options:
- Yes, I left them
- No, we stayed together
- I went alone
- Not sure
validations:
required: false
- type: dropdown
id: direction
attributes:
label: Which way did you go first?
options:
- East (toward the roar)
- West (toward the scent)
- Toward the forest centre
validations:
required: true
- type: dropdown
id: first_sighting
attributes:
label: Which dragon found you first?
options:
- Red
- Brown
- Green
- Orange
- Not sure
validations:
required: false
- type: dropdown
id: sighting_action
attributes:
label: What did you do when it found you?
options:
- Hold still
- Lower your eyes in respect / turn to face it
- Run
- Hide
- Draw a weapon
- Meet its gaze
- Protect your squadmate
- Not sure
validations:
required: false
- type: dropdown
id: scream
attributes:
label: The scream
options:
- I died at the first dragon
- Investigated, and helped my squadmate
- Investigated, and walked away
- Kept walking (ignored it)
validations:
required: true
- type: dropdown
id: combat_first
attributes:
label: 'If you helped: your first move in the fight'
options:
- Pause to assess
- Charge the smaller cadet
- Charge between the bigger cadet and your squadmate
- Not sure
validations:
required: false
- type: dropdown
id: combat_second
attributes:
label: 'If you paused to assess: the smaller cadet''s dagger'
options:
- Engage the smaller cadet
- Charge the bigger cadet anyway
- Not sure
validations:
required: false
- type: dropdown
id: resolution
attributes:
label: How did the cadet encounter end?
options:
- I died in the fight
- 'Bullies: killed them myself'
- 'Bullies: my squadmate''s revenge'
- 'Bullies: left them to the dragons'
- 'Wounded cadet: tourniquet'
- 'Wounded cadet: left them'
- 'Wounded cadet: took their weapons'
- I walked away from the clearing
- Not sure
validations:
required: false
- type: dropdown
id: post_path
attributes:
label: 'After the fight: which way did you walk?'
options:
- Deeper into the forest
- West
- East
- There was no fork
- Not sure
validations:
required: false
- type: dropdown
id: hour
attributes:
label: After an hour's walk
options:
- Climbed the tallest tree
- Went to the valley centre
- I died before the hour
- Not sure
validations:
required: false
- type: dropdown
id: branch
attributes:
label: Which bonding encounter did you reach?
options:
- 'Tree: the shadow (Blue or Black)'
- 'Tree: climbed down quickly, jumped on the Red'
- 'Tree: climbed down quickly, let the Red pass'
- 'Tree: climbed down slowly to the two Greens'
- 'Valley: faced the Red'
- 'Valley: passed the Red, the meadow'
- Not sure
validations:
required: false
- type: dropdown
id: outcome
attributes:
label: How did the run end?
options:
- Bonded
- Incinerated at a bonding encounter
- Died before the hour
validations:
required: true
- type: dropdown
id: outcome_color
attributes:
label: Which dragon bonded you (or incinerated you)?
options:
- Red
- Green
- Orange
- Brown
- Blue
- Black
- Not sure
validations:
required: false
- type: dropdown
id: tail
attributes:
label: 'If you bonded: the dragon''s tail'
options:
- Clubtail
- Daggertail
- Morningstartail
- Scorpiontail
- Swordtail
- Not sure
validations:
required: false
+21
View File
@@ -0,0 +1,21 @@
name: CI
on:
push:
branches: [main]
pull_request:
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- run: pip install -r requirements.txt
- run: npm test
- name: graph.json is up to date
run: node analysis/network/build-graph.js && git diff --exit-code data/public/graph.json
- run: npm run build
+30
View File
@@ -0,0 +1,30 @@
name: Deploy Atlas to GitHub Pages
on:
push:
branches: [main]
workflow_dispatch:
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: pages
cancel-in-progress: true
jobs:
deploy:
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm run build
- uses: actions/configure-pages@v5
- uses: actions/upload-pages-artifact@v3
with:
path: dist
- id: deployment
uses: actions/deploy-pages@v4
+102
View File
@@ -0,0 +1,102 @@
name: Check sources for new data
on:
schedule:
- cron: "23 10 * * *" # daily
workflow_dispatch:
permissions:
contents: write
pull-requests: write
issues: write
jobs:
check:
runs-on: ubuntu-latest
env:
# secrets cannot be tested in `if:` directly
HAS_BOT_TOKEN: ${{ secrets.ATLAS_BOT_TOKEN != '' }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- run: pip install -r requirements.txt
# The raw store (data/raw: the current and previous raw file of each source) is never committed. Between runs
# it lives in the Actions cache, encrypted with the RAW_ARCHIVE_KEY secret, so only the previous version is
# kept and nobody without the key can read it (the register has rider names). Without the secret there is no
# archive: each run starts from the manifest alone.
- name: Restore the private raw archive
uses: actions/cache/restore@v4
with:
path: ${{ runner.temp }}/raw-archive
key: raw-archive-none
restore-keys: raw-archive-
- name: Decrypt it
env:
RAW_ARCHIVE_KEY: ${{ secrets.RAW_ARCHIVE_KEY }}
run: |
f="$RUNNER_TEMP/raw-archive/raw.tgz.enc"
if [ -n "$RAW_ARCHIVE_KEY" ] && [ -f "$f" ]; then
openssl enc -d -aes-256-cbc -pbkdf2 -pass env:RAW_ARCHIVE_KEY -in "$f" | tar -xz -C data
fi
# extract -> transform -> load for every source, then the combined runs (collection/pipeline.yaml)
- id: check
env:
GITHUB_TOKEN: ${{ github.token }}
REDDIT_CLIENT_ID: ${{ secrets.REDDIT_CLIENT_ID }}
REDDIT_CLIENT_SECRET: ${{ secrets.REDDIT_CLIENT_SECRET }}
run: python -m collection update --report "$RUNNER_TEMP/report.md"
- name: Rebuild the analysis and run tests
if: steps.check.outputs.changed == 'true'
run: |
node analysis/network/build-graph.js
npm run policy
npm run stats
python -m collection build
npm test
- name: Encrypt the raw store
id: archive
env:
RAW_ARCHIVE_KEY: ${{ secrets.RAW_ARCHIVE_KEY }}
run: |
if [ -n "$RAW_ARCHIVE_KEY" ] && [ -d data/raw ]; then
mkdir -p "$RUNNER_TEMP/raw-archive"
tar -czf - -C data raw | openssl enc -aes-256-cbc -pbkdf2 -salt -pass env:RAW_ARCHIVE_KEY -out "$RUNNER_TEMP/raw-archive/raw.tgz.enc"
echo "save=true" >> "$GITHUB_OUTPUT"
fi
- name: Save it (a new copy only when a raw file changed)
if: steps.archive.outputs.save == 'true'
uses: actions/cache/save@v4
with:
path: ${{ runner.temp }}/raw-archive
key: raw-archive-${{ hashFiles('data/manifest.json') }}
# The PR is opened with ATLAS_BOT_TOKEN (a fine-grained token, see docs/REPO_SETTINGS.md) when it is set:
# changes made with the built-in GITHUB_TOKEN do not start other workflows, so its merge would not
# redeploy the site. Without the secret it falls back to GITHUB_TOKEN and the PR waits for a manual merge.
- name: Open a pull request with the new data
id: pr
if: steps.check.outputs.changed == 'true'
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.ATLAS_BOT_TOKEN || github.token }}
branch: data/source-update
delete-branch: true
commit-message: "data: update from community sources"
title: "New data from the community sources"
body-path: ${{ runner.temp }}/report.md
labels: data
- name: Merge it automatically once CI passes
if: steps.pr.outputs.pull-request-number != '' && env.HAS_BOT_TOKEN == 'true'
env:
GH_TOKEN: ${{ secrets.ATLAS_BOT_TOKEN }}
run: gh pr merge "${{ steps.pr.outputs.pull-request-number }}" --auto --squash
- name: Report a broken source link
if: steps.check.outputs.failed != ''
env:
GH_TOKEN: ${{ github.token }}
run: |
title="Source check failed: ${{ steps.check.outputs.failed }}"
if ! gh issue list --state open --search "$title in:title" --json number --jq '.[0].number' | grep -q .; then
gh issue create --title "$title" --body-file "$RUNNER_TEMP/report.md"
fi
+243
View File
@@ -0,0 +1,243 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[codz]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py.cover
*.lcov
.hypothesis/
.pytest_cache/
cover/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
.pybuilder/
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version
# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
# Pipfile.lock
# uv
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# uv.lock
# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
# poetry.lock
# poetry.toml
# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
# pdm.lock
# pdm.toml
.pdm-python
.pdm-build/
# pixi
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
# pixi.lock
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
# in the .venv directory. It is recommended not to include this directory in version control.
.pixi/*
!.pixi/config.toml
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/
# Celery stuff
celerybeat-schedule*
celerybeat.pid
# Redis
*.rdb
*.aof
*.pid
# RabbitMQ
mnesia/
rabbitmq/
rabbitmq-data/
# ActiveMQ
activemq-data/
# SageMath parsed files
*.sage.py
# Environments
.env
.envrc
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs/Zensical documentation
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/
# pytype static type analyzer
.pytype/
# Cython debug symbols
cython_debug/
# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
# .idea/
# Abstra
# Abstra is an AI-powered process automation framework.
# Ignore directories containing user credentials, local state, and settings.
# Learn more at https://abstra.io/docs
.abstra/
# Visual Studio Code
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore that
# can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
# and can be added to the global gitignore or merged into this file. However, if you prefer, you
# could uncomment the following to ignore the entire vscode folder
# .vscode/
# Temporary file for partial code execution
tempCodeRunnerFile.py
# Ruff stuff:
.ruff_cache/
# PyPI configuration file
.pypirc
# Marimo
marimo/_static/
marimo/_lsp/
__marimo__/
# Streamlit
.streamlit/secrets.toml
# --- Threshing Atlas ---
node_modules/
dist/
tests/out/
__pycache__/
*.pyc
.env
.DS_Store
# The raw store (collection/pipeline.yaml): current and previous raw files of every source. Never published: the
# register has rider names, the bot's data has game prose and account ids, the PDF is not ours to redistribute.
data/raw/
# Third-party guide PDF: link to it, do not redistribute
*.pdf
# QA screenshots
undefined/
# hand-off zips and local reports (python -m collection export-bot-kit / refresh)
exports/
inbox/
# PyCharm
.idea/
+21
View File
@@ -0,0 +1,21 @@
# Data licence
The data this project produces (coded runs in `data/derived/`, the route graph, `policy.json`,
`experiments.json`, and bot exports in `data/bot/`) are licensed under
**Creative Commons Attribution 4.0 International (CC BY 4.0)**:
https://creativecommons.org/licenses/by/4.0/
Credit: "Threshing Atlas contributors", with a link to this repository.
## Third-party sources
Some inputs belong to others. They keep their own terms, and CC BY 4.0 does not apply to them:
- `data/raw/form/` and `data/public/form_responses.json`: responses to the community
"Threshing Routes" Google Form compiled by u/ClumsyBadger. Included unmodified so results can be
reproduced. Credit the form and its respondents.
- `data/public/register.json`: derived from the community "Unofficial Dragon Register". Rider names
and photos are removed. The raw export is not committed.
- The community route PDF is not redistributed. See `data/SOURCES.md` for where to find it.
Dragonkind and Fourth Wing belong to their respective owners. This is an unofficial fan project.
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2026 ekcSchiano
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+1 -1
View File
@@ -76,7 +76,7 @@ See `docs/BOT_DATA_PROTOCOL.md` for what the bot should log.
## Running everything locally
`python -m collection refresh` does what the daily workflow does (`python -m collection rebuild` alone redoes everything built from the runs): checks every source, rebuilds the runs,
`python -m collection refresh` does what the daily workflow does: checks every source, rebuilds the runs,
the graph, the route model and the statistics. Add `--bot <folder or zip>` to import bot runs, and
`python -m collection export-bot-kit` zips the files the bot uses (see `docs/BOT_INTEGRATION.md`).
+11
View File
@@ -0,0 +1,11 @@
# analysis
Making sense of the data.
| Folder | What it does |
|---|---|
| `stats/measures.yaml` | **Declarative.** What the site measures: outcomes and their denominators, route targets and comparison groups, the bonding-encounter contexts, the route map's stages, the filter presets and the route thresholds. |
| `stats/site_stats.py` | Computes every number the Atlas page shows for every preset and writes `data/public/stats.json`; the page computes nothing itself. |
| `stats/stats_core.py` | The statistics themselves: rates with Wilson intervals, odds ratios with Fisher's test and Benjamini–Hochberg, Mantel–Haenszel, ridge logistic models that adjust for data source and chase goal. Tested against known answers (`tests/core/test_stats.py`). |
| `network/` | `build-graph.js` combines every source into `data/public/graph.json` (the decision-variable graph and the bot's scene graph). CI fails if the committed graph is out of date. |
| `reports/` | Generated reports. `POLICY.md` is written by `planner/policy_report.py`; do not edit it by hand. |
+46
View File
@@ -0,0 +1,46 @@
// Build data/public/graph.json from every run in data/public/runs_clean.csv (every source), plus the bot's scene graph.
// node analysis/network/build-graph.js
const fs = require("fs");
const path = require("path");
const G = require("../../core/graph.js");
const root = path.resolve(__dirname, "../..");
const rel = (p) => path.join(root, p);
/** The coded runs of every source, written by `python -m collection build`. */
function readCSV(file) {
const text = fs.readFileSync(file, "utf8"), rows = [];
let row = [], cell = "", q = false;
for (let i = 0; i < text.length; i++) {
const ch = text[i];
if (q) {
if (ch === '"' && text[i + 1] === '"') { cell += '"'; i++; }
else if (ch === '"') q = false;
else cell += ch;
} else if (ch === '"') q = true;
else if (ch === ",") { row.push(cell); cell = ""; }
else if (ch === "\n") { row.push(cell); rows.push(row); row = []; cell = ""; }
else if (ch !== "\r") cell += ch;
}
if (cell || row.length) { row.push(cell); rows.push(row); }
const [head, ...body] = rows;
return body.map((r) => Object.fromEntries(head.map((h, i) => [h, r[i] === "" || r[i] === undefined ? null : r[i]])));
}
const runs = readCSV(rel("data/public/runs_clean.csv"));
// spreadsheet runs keep the split between form submissions and bulk logs
const sourceKey = (r) => (r.source === "reddit spreadsheet" ? (r.entry === "Form" ? "form" : "form-bulk") : r.source);
const records = runs.map((r) => ({ source: sourceKey(r), vars: G.formRunVariables(r) }));
const botDir = rel("data/bot");
const scenes = fs.existsSync(path.join(botDir, "scenes.json")) ? JSON.parse(fs.readFileSync(path.join(botDir, "scenes.json"), "utf8")) : {};
const trajs = [];
for (const f of fs.readdirSync(botDir).filter((f) => /^trajectories-.*\.jsonl$/.test(f)).sort()) {
for (const line of fs.readFileSync(path.join(botDir, f), "utf8").split("\n")) if (line.trim()) trajs.push(JSON.parse(line));
}
const graph = {
sources: records.reduce((m, r) => ((m[r.source] = (m[r.source] || 0) + 1), m), {}),
variables: G.buildVariableGraph(records),
scenes: G.buildSceneGraph(scenes, trajs)
};
fs.writeFileSync(rel("data/public/graph.json"), JSON.stringify(graph));
console.log(`graph.json: ${JSON.stringify(graph.sources)}, ${Object.keys(graph.variables.nodes).length} variable nodes, ${Object.keys(graph.scenes).length} scenes`);
File diff suppressed because it is too large Load Diff
@@ -6,12 +6,10 @@
# (not blank), {any: [condition, ...]} (at least one). Several fields in one condition must all hold.
version: 1
# Which runs of data/public/runs_clean.csv the statistics use (its `source` column): every source that records the
# route (the community form, "Report a run", the Reddit megathread comments, the DragonKind bot). The Reddit result
# pages and the register record only the end, so they stay out. The bot plays to a strategy and burns on purpose at
# encounters it is not chasing: like every rider's deliberate death (`_deliberate`, the route model's rule), those
# burns are left out of the bond rates, never counted as failed bonds.
sources: [reddit spreadsheet, reported, reddit comment, bot]
# Which runs of data/public/runs_clean.csv the statistics use (its `source` column). Runs from the other sources
# (reported, bot, Reddit result pages) are in the published file but not in these statistics yet: they are coded
# from different questions, and the bot follows a strategy, so pooling them needs its own review.
sources: [reddit spreadsheet]
colours: [Red, Green, Orange, Brown, Blue, Black]
@@ -27,7 +25,7 @@ outcomes:
event: { saw_shadow: true }
bond_blue_meadow:
label: Bond, given you approached the meadow Blue
denom: { branch: "Passed the Red: meadow", enc_Blue: { in: ["Bonded!", "Incinerated"] }, _deliberate: { not: true } }
denom: { branch: "Passed the Red: meadow", enc_Blue: { in: ["Bonded!", "Incinerated"] } }
event: { enc_Blue: "Bonded!" }
reach_hour:
label: Survive to the hour (tree/valley choice)
@@ -36,7 +34,7 @@ outcomes:
# one more outcome per colour: "Run ends bonded to <colour>", among runs that reached the hour
bonded_outcome:
label: Run ends bonded to {colour}
denom: { hour: { in: [Tree, Valley] }, _deliberate: { not: true } }
denom: { hour: { in: [Tree, Valley] } }
event: { outcome: Bonded, outcome_color: "{colour}" }
# Factors compared in the factor tables (each answer against the other answers to the same question)
@@ -45,15 +43,15 @@ factors: [company, direction, first_sighting, scream, resolution, combat_first,
# Route targets: the outcome (event) and which runs could have reached it at all (pool)
targets:
bond_Blue: { label: Bond Blue, colour: Blue, event: { outcome: Bonded, outcome_color: Blue }, pool: { hour: Valley, _deliberate: { not: true } } }
bond_Black: { label: Bond Black, colour: Black, event: { outcome: Bonded, outcome_color: Black }, pool: { hour: Tree, _deliberate: { not: true } } }
bond_Blue: { label: Bond Blue, colour: Blue, event: { outcome: Bonded, outcome_color: Blue }, pool: { hour: Valley } }
bond_Black: { label: Bond Black, colour: Black, event: { outcome: Bonded, outcome_color: Black }, pool: { hour: Tree } }
see_Blue: { label: Meet a Blue (meadow), colour: Blue, event: { saw_blue_meadow: true }, pool: { branch: "Passed the Red: meadow" } }
see_shadow: { label: Get the tree shadow, colour: Black, event: { saw_shadow: true }, pool: { hour: Tree, branch: { exists: true } } }
bond_Red: { label: Bond Red, colour: Red, event: { outcome: Bonded, outcome_color: Red }, pool: { hour: { in: [Tree, Valley] }, _deliberate: { not: true } } }
bond_Green: { label: Bond Green, colour: Green, event: { outcome: Bonded, outcome_color: Green }, pool: { hour: Tree, _deliberate: { not: true } } }
bond_Orange: { label: Bond Orange, colour: Orange, event: { outcome: Bonded, outcome_color: Orange }, pool: { hour: { in: [Tree, Valley] }, _deliberate: { not: true } } }
bond_Brown: { label: Bond Brown, colour: Brown, event: { outcome: Bonded, outcome_color: Brown }, pool: { hour: { in: [Tree, Valley] }, _deliberate: { not: true } } }
bond_any: { label: Bond any dragon, colour: null, event: { outcome: Bonded }, pool: { hour: { in: [Tree, Valley] }, _deliberate: { not: true } } }
bond_Red: { label: Bond Red, colour: Red, event: { outcome: Bonded, outcome_color: Red }, pool: { hour: { in: [Tree, Valley] } } }
bond_Green: { label: Bond Green, colour: Green, event: { outcome: Bonded, outcome_color: Green }, pool: { hour: Tree } }
bond_Orange: { label: Bond Orange, colour: Orange, event: { outcome: Bonded, outcome_color: Orange }, pool: { hour: { in: [Tree, Valley] } } }
bond_Brown: { label: Bond Brown, colour: Brown, event: { outcome: Bonded, outcome_color: Brown }, pool: { hour: { in: [Tree, Valley] } } }
bond_any: { label: Bond any dragon, colour: null, event: { outcome: Bonded }, pool: { hour: { in: [Tree, Valley] } } }
# Bonding encounters: which recorded attempt (column) belongs to which in-game encounter (where)
encounters:
@@ -82,8 +80,6 @@ presets:
all: { label: All runs, filters: { source: all, goal: all, excludeFlagged: false } }
form: { label: Form submissions only, filters: { source: form, goal: all, excludeFlagged: false } }
bulk: { label: Bulk logs only (imports), filters: { source: bulk, goal: all, excludeFlagged: false } }
reddit: { label: Reddit comments only, filters: { source: reddit, goal: all, excludeFlagged: false } }
bot: { label: DragonKind bot only, filters: { source: bot, goal: all, excludeFlagged: false } }
not_chasing: { label: Not chasing Blue/Black, filters: { source: all, goal: exclude_rare, excludeFlagged: false } }
chasing: { label: Chasing Blue/Black, filters: { source: all, goal: only_rare, excludeFlagged: false } }
unflagged: { label: Rows without data-quality flags, filters: { source: all, goal: all, excludeFlagged: true } }
@@ -92,17 +88,3 @@ presets:
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, 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]
@@ -95,18 +95,7 @@ def is_rare(goal):
return goal in M["rare_goals"]
# sources other than the community spreadsheet: their own group wherever runs are split by where they came from
SOURCE_LABEL = {"reddit comment": "Reddit comments", "bot": "DragonKind bot", "reported": "Reported on the Atlas"}
def entry_group(r):
"""Where a run came from: the spreadsheet's entry type (Form, Data Import, ...) or the source's own label."""
return SOURCE_LABEL.get(r["source"]) or r["entry"]
def stratum(r):
if r["source"] in SOURCE_LABEL:
return SOURCE_LABEL[r["source"]]
if r["entry"] != "Form":
return "Bulk logs (imports)"
g = r["goal"]
@@ -119,14 +108,9 @@ def goal2(r):
def apply_filters(runs, f):
def ok(r):
sheet = r["source"] == "reddit spreadsheet"
if f.get("source") == "form" and not (sheet and r["entry"] == "Form"):
if f.get("source") == "form" and r["entry"] != "Form":
return False
if f.get("source") == "bulk" and not (sheet and r["entry"] != "Form"):
return False
if f.get("source") == "reddit" and r["source"] != "reddit comment":
return False
if f.get("source") == "bot" and r["source"] != "bot":
if f.get("source") == "bulk" and r["entry"] == "Form":
return False
if f.get("goal") == "exclude_rare" and is_rare(r["goal"]):
return False
@@ -213,7 +197,7 @@ def analyse(all_runs, filters):
dates = sorted(r["date"] for r in runs if r.get("date"))
outs = group_by(runs, lambda r: r["outcome"] + (" " + r["outcome_color"] if r.get("outcome_color") else ""))
res["meta"] = {
"sources": {k: len(v) for k, v in group_by(runs, entry_group).items()},
"sources": {k: len(v) for k, v in group_by(runs, "entry").items()},
"date_min": dates[0] if dates else None, "date_max": dates[-1] if dates else None,
"n_flagged": sum(1 for r in runs if r["data_flags"]), "flag_counts": flag_counts,
"outcomes": {k: len(v) for k, v in outs.items()},
@@ -236,14 +220,13 @@ def analyse(all_runs, filters):
res["encounters"] = []
for e in M["encounters"]:
col, colour = e["column"], e["colour"]
# a rider who chose to burn here (chasing another colour) did not fail this encounter
A = [r for r in runs if match(r, e["where"]) and r.get(col) in ("Bonded!", "Incinerated") and not r.get("_deliberate")]
A = [r for r in runs if match(r, e["where"]) and r.get(col) in ("Bonded!", "Incinerated")]
win = lambda r, col=col: r.get(col) == "Bonded!" # noqa: E731
intent = [r for r in A if r["goal"] == colour or r["goal"].startswith("Any") or (r["goal"] == "Blue or Black" and colour in ("Blue", "Black"))]
res["encounters"].append({"context": e["context"], "color": colour, "overall": rate(A, win), "intent_matched": rate(intent, win),
"by_stratum": {s: rate(g, win) for s, g in sorted(group_by(A, stratum).items())}})
greens_where = next(e["where"] for e in M["encounters"] if e["colour"] == "Green")
greens = [r for r in runs if match(r, greens_where) and r.get("enc_Green") and not r.get("_deliberate")]
greens = [r for r in runs if match(r, greens_where) and r.get("enc_Green")]
g = {"green_encounters": len(greens),
"bonded_green": sum(1 for r in greens if r["enc_Green"] == "Bonded!"),
"rescued_orange": sum(1 for r in greens if r["rescued"] and r.get("outcome_color") == "Orange"),
@@ -257,7 +240,7 @@ def analyse(all_runs, filters):
first2 = lambda r: r["first_sighting"] if r["first_sighting"] in ("Red", "Brown", "Orange", "Green") else None # noqa: E731
known = lambda f: (lambda r: None if is_missing(r.get(f)) else r[f]) # noqa: E731
src2 = lambda r: SOURCE_LABEL.get(r["source"]) or ("Form submission" if r["entry"] == "Form" else "Bulk log (import)") # noqa: E731
src2 = lambda r: "Form submission" if r["entry"] == "Form" else "Bulk log (import)" # noqa: E731
res["models"] = {
"blue_meadow": fit_model(runs, "blue_meadow", {"source": src2, "goal": goal2, "direction": known("direction"),
"first_sighting": first2, "resolution": known("resolution"), "company": known("company")}),
@@ -274,7 +257,7 @@ def analyse(all_runs, filters):
"blue": W(bk, len(m)), "shadow": W(sk, len(t))})
res["source_rates"] = {key: {s: rate([r for r in g if match(r, OUTCOMES[key]["denom"])], lambda r, k=key: match(r, OUTCOMES[k]["event"]))
for s, g in group_by(runs, entry_group).items()} for key in ("blue_meadow", "shadow")}
for s, g in group_by(runs, "entry").items()} for key in ("blue_meadow", "shadow")}
return res
@@ -319,11 +302,9 @@ def route_map(runs):
"""The route map: nodes and links with run counts, and for every target the hits and their Wilson interval."""
nodes, links = {}, {}
hits = {t: {} for t in TARGETS}
tries = {t: {} for t in TARGETS} # runs that count for the target (no deliberate deaths for a bond)
for r in runs:
prev = None
hit = {t: match(r, T["event"]) for t, T in TARGETS.items()}
counts = {t: not (r.get("_deliberate") and t.startswith("bond_")) for t in TARGETS}
for si, s in enumerate(STAGES):
v = stage_value(r, s["key"])
if v is None:
@@ -333,18 +314,15 @@ def route_map(runs):
nd["n"] += 1
for t in TARGETS:
hits[t][nid] = hits[t].get(nid, 0) + hit[t]
tries[t][nid] = tries[t].get(nid, 0) + counts[t]
if prev:
lid = prev + "→" + nid
ln = links.setdefault(lid, {"id": lid, "source": prev, "target": nid, "n": 0, "chance": bool(s.get("chance"))})
ln["n"] += 1
for t in TARGETS:
hits[t][lid] = hits[t].get(lid, 0) + hit[t]
tries[t][lid] = tries[t].get(lid, 0) + counts[t]
prev = nid
nl, ll = list(nodes.values()), list(links.values())
by_target = {t: {"nodes": [W(hits[t][n["id"]], tries[t][n["id"]]) for n in nl],
"links": [W(hits[t][l["id"]], tries[t][l["id"]]) for l in ll]} for t in TARGETS}
by_target = {t: {"nodes": [W(hits[t][n["id"]], n["n"]) for n in nl], "links": [W(hits[t][l["id"]], l["n"]) for l in ll]} for t in TARGETS}
return {"nodes": nl, "links": ll, "by_target": by_target}
@@ -421,7 +399,7 @@ def place_path(r):
s.append("bully")
if "res:" + r["resolution"] in L:
s.append("res:" + r["resolution"])
if (r.get("resolution") or "").startswith("DIED"):
if r["resolution"].startswith("DIED"):
return s
if r.get("post_path") in ("Forest", "West", "East"):
s.append("fork:" + r["post_path"])
@@ -474,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])]}
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):
"""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."""
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)]
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),
@@ -539,7 +483,7 @@ def clean(o):
return o
def build(runs, rows, exported=None, every_run=None):
def build(runs, rows, exported=None):
global PLACES
PLACES = place_ids()
th = M["route_thresholds"]
@@ -562,8 +506,6 @@ def build(runs, rows, exported=None, every_run=None):
"routes": {t: rank_routes(sub, t, th) for t in TARGETS},
"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)
@@ -572,12 +514,8 @@ def main(argv=None):
ap.add_argument("--data", default=str(runs_io.PATH))
ap.add_argument("--out", default=str(ROOT / "data/public/stats.json"))
a = ap.parse_args(argv)
# a run that cannot have happened as recorded (core/spec/form.yaml impossible_flags) is left out, as in the model
runs = [r for r in runs_io.read(a.data, sources=M["sources"]) if not runs_io.impossible(r)]
for r in runs:
r["_deliberate"] = deliberate(r)
every = [r for r in runs_io.read(a.data) if not runs_io.impossible(r)]
out = build(runs, len(runs), exported(), every_run=every)
runs = runs_io.read(a.data, sources=M["sources"])
out = build(runs, len(runs), exported())
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")
+56
View File
@@ -0,0 +1,56 @@
# collection
Getting data in, as a strict **extract → transform → load** pipeline. Every source is declared in
[`pipeline.yaml`](pipeline.yaml); the code only carries those declarations out.
```
python -m collection update # every source: extract, then transform + load if it changed; then build
python -m collection update --source reported --source register
python -m collection update --file reddit_spreadsheet=~/Downloads/export.xlsx # a local file instead of the download
python -m collection build # code every public source file into data/public/runs_clean.csv
python -m collection build --check # nothing written; exit 1 if anything is out of date (CI runs this)
```
## The stages
| Stage | Does | Never does |
|---|---|---|
| **extract** (`etl/extract.py`) | Fetches the source as it is now into `data/raw/<source>/current.<ext>`. The version it replaces becomes `previous.<ext>`; nothing older is kept. `data/manifest.json` records the current raw file's sha256 and the day it last changed. | Change the data. |
| **transform** (`etl/transform/`) | Turns the raw file into the public source file, applying the source's privacy rules. A pure function of the raw file: no network, no clock. | Write files. |
| **validate** (`etl/validate.py`) | Checks the combined runs against `data/dictionary.yaml` (types, every value listed, unique ids). A failure stops the load and is reported. | Fix anything silently. |
| **load** (`etl/load.py`) | The only stage that writes public files. Byte-stable: the same input always gives the same bytes, and a file is only rewritten when its bytes change. | Publish anything raw. |
`build` then codes every public source file into one run per row (`etl/runs.py`, one coder per source) and writes
`data/public/runs_clean.csv`, plus the files generated from the specs: the "Report a run" issue form, the bot
crosswalk inside `core/graph.js`, and `data/croissant.json`. Every input to `build` is committed, so CI rebuilds
it exactly.
## The sources
| `source` in runs_clean.csv | Pipeline source | Extract | Public source file |
|---|---|---|---|
| reddit spreadsheet | `reddit_spreadsheet`: u/ClumsyBadger's Threshing Routes form and spreadsheet, linked from the megathreads | the sheet's .xlsx export | `data/public/form_responses.json` (emails redacted), coded by `core/spec/form.yaml` |
| reddit thread | `reddit_thread`: dragonkind.com result pages posted in the r/fourthwing megathreads | the threads, through the official Reddit API (needs `REDDIT_CLIENT_ID` / `REDDIT_CLIENT_SECRET`) | `manual/reddit_results.yaml`, checked by hand; the extract lists result links not in it yet |
| reported | `reported`: the Atlas's "Report a run" form (a GitHub issue form, `specs/report_form.yaml`) | issues labelled `run report`, through the GitHub API | `data/public/reports.json` (answers only, no usernames) |
| bot | `bot`: Ken's DragonKind bot | a local copy of the bot's private repo (`DRAGONKIND_BOT_DIR`) | `data/bot/scenes.json`, `data/bot/trajectories-<date>.jsonl` (no prose, accounts hashed with `DK_ACCOUNT_SALT`; `specs/bot.yaml`) |
| reddit pdf | `reddit_pdf`: the community route PDF | the PDF | `data/derived/pdf_fingerprint.json` only: hashes, never the text |
| — | `register`: the Unofficial Dragon Register | the sheet's .xlsx export | `data/public/register.json` (rider names and photos dropped) |
The route PDF is a flowchart of the choices, not a log of runs, so it adds no rows to `runs_clean.csv`; its
fingerprint tells us when the routes it documents change. The register lists bonded dragons without the route that
led there, so it adds no rows either.
## Raw files and privacy
`data/raw/` is git-ignored and never published. It holds the current raw file of each source and the one before
it; older versions are not kept. The daily workflow keeps that store between runs in the Actions cache, encrypted
with the `RAW_ARCHIVE_KEY` secret (see `docs/REPO_SETTINGS.md`). Privacy rules sit with each source in
`pipeline.yaml`: emails redacted, register names and photos dropped, the bot's fields refused if they look like
prose or account ids, GitHub and Reddit usernames never kept.
## Adding a source
1. Add a block to `pipeline.yaml` (extract kind, transform, privacy, load target, and `run_source` / `runs` if it
has runs).
2. If it needs a new transform or coder, add one module to `etl/transform/` and one function to `etl/runs.py`.
3. Add its `source` value to `data/dictionary.yaml`, then `python -m collection build` and `npm test`.
+3
View File
@@ -0,0 +1,3 @@
from collection.run import main
raise SystemExit(main())
View File
+42
View File
@@ -0,0 +1,42 @@
"""Files written from the declarative specs, so each rule has one source of truth:
.github/ISSUE_TEMPLATE/report-a-run.yml from collection/specs/report_form.yaml (report_form.render)
the CROSSWALK block of core/graph.js from collection/specs/bot.yaml (Ken's bot uses it at run time)
"""
import json
from . import forge
from .common import path, read_yaml
LINKS = "data/public/links.json"
def links():
"""The links the page shows, from forge.yaml and pipeline.yaml (site/build.js fills them into the page)."""
f = forge.config()
src = read_yaml("collection/pipeline.yaml")["sources"]
host = f["url"].split("://", 1)[-1].rstrip("/")
return {
"repo": forge.repo_url(f), "repo_label": f"{host}/{f['repo']}", "host": host, "kind": f["kind"],
"visibility": f.get("visibility", "public"),
"report": forge.new_issue_url(".github/ISSUE_TEMPLATE/report-a-run.yml", f),
"form": src["reddit_spreadsheet"]["links"]["form"], "sheet": src["reddit_spreadsheet"]["links"]["sheet"],
}
GRAPH_JS = "core/graph.js"
BEGIN = " // BEGIN CROSSWALK"
END = " // END CROSSWALK\n"
def graph_js():
"""core/graph.js with its CROSSWALK block rewritten from the bot spec."""
text = path(GRAPH_JS).read_text(encoding="utf-8")
a = text.index(BEGIN)
a = text.index("\n", a) + 1
b = text.index(END, a)
rules = read_yaml("collection/specs/bot.yaml")["crosswalk"]
lines = [" const CROSSWALK = ["]
for i, (rx, col, val) in enumerate(rules):
sep = "," if i < len(rules) - 1 else ""
lines.append(f" [/{rx.replace('/', chr(92) + '/')}/, {json.dumps(col)}, {json.dumps(val, ensure_ascii=False)}]{sep}")
lines.append(" ];")
return text[:a] + "\n".join(lines) + "\n" + text[b:]
+76
View File
@@ -0,0 +1,76 @@
"""Paths, the pipeline spec, and byte-stable writers shared by every stage."""
import hashlib
import json
import sys
from pathlib import Path
import yaml
ROOT = Path(__file__).resolve().parents[2]
if str(ROOT / "core") not in sys.path:
sys.path.insert(0, str(ROOT / "core"))
def path(p):
return ROOT / p
def read_yaml(p):
with open(path(p), encoding="utf-8") as f:
return yaml.safe_load(f)
def pipeline():
return read_yaml("collection/pipeline.yaml")
def sha256_bytes(data):
return hashlib.sha256(data).hexdigest()
def sha256_file(p):
h = hashlib.sha256()
with open(p, "rb") as f:
for block in iter(lambda: f.read(1 << 20), b""):
h.update(block)
return h.hexdigest()
def json_bytes(obj, compact=True):
if compact:
return (json.dumps(obj, ensure_ascii=False, separators=(",", ":"))).encode("utf-8")
return (json.dumps(obj, ensure_ascii=False, indent=1) + "\n").encode("utf-8")
def jsonl_bytes(rows):
return "".join(json.dumps(r, ensure_ascii=False, separators=(",", ":")) + "\n" for r in rows).encode("utf-8")
def read_jsonl(p):
p = Path(p)
if not p.exists():
return []
out = []
for line in p.read_text(encoding="utf-8").splitlines():
if line.strip():
try:
out.append(json.loads(line))
except json.JSONDecodeError:
pass
return out
class Report:
"""What a pipeline run did, as Markdown lines (the daily pull request's body)."""
def __init__(self):
self.lines = []
self.changed = False
self.failed = []
def add(self, line):
self.lines.append(line)
print(line)
def text(self, title):
return "\n".join([f"## {title}", ""] + self.lines) + "\n"
+153
View File
@@ -0,0 +1,153 @@
"""Extract: fetch each source as it is now into the raw store. No transformation happens here.
The raw store is data/raw/<source>/ (git-ignored, never published):
current.<ext> the latest version
previous.<ext> the version before it (kept only in case it is needed; the daily workflow keeps it in an
encrypted, private cache). Nothing older is kept and old versions are not hashed.
data/manifest.json records, for each source, the sha256 of the current raw file and the date it last changed.
Each extractor returns the raw bytes, or raises Skip when the source cannot be reached from here (a missing
secret, the bot's private repo not on this machine).
"""
import base64
import fnmatch
import glob
import json
import os
import shutil
import tempfile
import urllib.parse
import urllib.request
import zipfile
from datetime import datetime, timezone
from pathlib import Path
from .common import path, sha256_bytes
USER_AGENT = "threshing-atlas-collector/1.0 (+https://github.com/ekcSchiano/threshing-atlas)"
RAW_DIR = path("data/raw")
class Skip(Exception):
"""The source cannot be extracted here; not an error."""
def _get(url, headers=None, data=None, timeout=60):
req = urllib.request.Request(url, data=data, headers={"User-Agent": USER_AGENT, **(headers or {})})
with urllib.request.urlopen(req, timeout=timeout) as r:
return r.read()
# ---------------------------------------------------------------- extractors, by `kind`
def http(spec, env):
data = _get(spec["url"])
head = data[:15].lower()
if head.startswith(b"<!doctype html") or head.startswith(b"<html"):
raise RuntimeError(f"{spec['url']} returned a web page, not a file (is the link still shared publicly?)")
return data
def reddit(spec, env):
"""The threads' comments through the official Reddit API (app-only OAuth: a "script" app's id and secret)."""
cid, secret = (env.get(k) for k in spec["secrets"])
if not (cid and secret):
raise Skip(f"set the {' and '.join(spec['secrets'])} secrets to read the threads through the Reddit API")
auth = base64.b64encode(f"{cid}:{secret}".encode()).decode()
token = json.loads(_get("https://www.reddit.com/api/v1/access_token",
headers={"Authorization": f"Basic {auth}"},
data=b"grant_type=client_credentials"))["access_token"]
threads = {}
for tid in spec["threads"]:
threads[tid] = json.loads(_get(f"https://oauth.reddit.com/comments/{tid}?limit=500&depth=10&raw_json=1",
headers={"Authorization": f"Bearer {token}"}))
return json.dumps(threads, ensure_ascii=False, sort_keys=True).encode("utf-8")
def forge_issues(spec, env):
"""Every issue with the label (open and closed), from the repository's host (forge.yaml: Gitea or GitHub)."""
from . import forge
issues = forge.list_issues(spec["label"], env)
return json.dumps(issues, ensure_ascii=False, sort_keys=True).encode("utf-8")
def local_dir(spec, env):
"""The bot's files, from a local copy of its private repo (DRAGONKIND_BOT_DIR), packed as one JSON."""
root = env.get(spec["env"])
if not root:
raise Skip(f"the bot's repo is private: set {spec['env']} to a local copy to import it")
files = {}
for pattern in spec["files"]: # a pattern may have * for one folder level (one folder per bot account)
hits = sorted(glob.glob(os.path.join(root, pattern)))
for p in hits:
files[os.path.relpath(p, root).replace(os.sep, "/")] = Path(p).read_text(encoding="utf-8")
if not hits and "*" not in pattern:
files[pattern] = None
return json.dumps(files, ensure_ascii=False, sort_keys=True).encode("utf-8")
def pack_local(spec, src):
"""The bot's files from a folder (a copy of the bot repo) or a .zip someone sent (the files may sit under any
top folder inside it), packed as one JSON like local_dir."""
src = Path(src).expanduser()
if src.is_dir():
return local_dir(spec, {spec["env"]: str(src)})
files = {rel: None for rel in spec["files"] if "*" not in rel}
with zipfile.ZipFile(src) as z:
names = [n for n in z.namelist() if not n.endswith("/") and "__MACOSX" not in n]
for pattern in spec["files"]:
for n in names:
# the files may sit under a top folder (a zipped repo): match the pattern on the end of the name
parts = n.split("/")
rel = next(("/".join(parts[i:]) for i in range(len(parts)) if fnmatch.fnmatchcase("/".join(parts[i:]), pattern)), None)
if rel and files.get(rel) is None:
files[rel] = z.read(n).decode("utf-8")
if not any(files.values()):
raise RuntimeError(f"{src.name}: none of {', '.join(spec['files'])} found inside")
return json.dumps(files, ensure_ascii=False, sort_keys=True).encode("utf-8")
EXTRACTORS = {"http": http, "reddit": reddit, "forge_issues": forge_issues, "local_dir": local_dir}
# ---------------------------------------------------------------- the raw store
def raw_paths(name, ext):
d = RAW_DIR / name
return d / f"current.{ext}", d / f"previous.{ext}"
def store(name, ext, data, manifest, today=None):
"""Keep `data` as the current raw file. Returns True when it differs from the last one seen."""
current, previous = raw_paths(name, ext)
digest = sha256_bytes(data)
entry = manifest.get(name) or {}
changed = entry.get("sha256") != digest
current.parent.mkdir(parents=True, exist_ok=True)
on_disk = sha256_bytes(current.read_bytes()) if current.exists() else None
if on_disk and on_disk != digest:
shutil.copyfile(current, previous) # keep one previous version; anything older is gone
if on_disk != digest:
fd, tmp = tempfile.mkstemp(dir=current.parent)
with os.fdopen(fd, "wb") as f:
f.write(data)
os.replace(tmp, current)
if changed:
manifest[name] = {"sha256": digest, "bytes": len(data),
"changed": today or datetime.now(timezone.utc).strftime("%Y-%m-%d")}
return changed
def extract(name, spec, manifest, env=None, local_file=None):
"""Fetch one source (or take a local file) into the raw store. Returns (raw path, changed)."""
env = os.environ if env is None else env
ext = spec["extract"].get("ext") or "json"
kind = spec["extract"]["kind"]
if local_file and kind == "local_dir":
data = pack_local(spec["extract"], local_file) # a bot folder or a .zip someone sent
elif local_file:
data = Path(local_file).expanduser().read_bytes()
else:
data = EXTRACTORS[kind](spec["extract"], env)
changed = store(name, ext, data, manifest)
return raw_paths(name, ext)[0], changed
+163
View File
@@ -0,0 +1,163 @@
"""The repository host (forge.yaml): links, and the few API calls the pipeline makes, for Gitea and GitHub.
python -m collection forge open-pr --head BRANCH --title T --body-file F [--automerge]
python -m collection forge open-issue --title T --body-file F (skipped if an open issue has that title)
python -m collection forge ensure-label --name N --color HEX
The token comes from ATLAS_BOT_TOKEN, then GITEA_TOKEN / GITHUB_TOKEN / GH_TOKEN.
"""
import json
import os
import sys
import urllib.parse
import urllib.request
from .common import read_yaml
USER_AGENT = "threshing-atlas-collector/1.0"
def config():
return read_yaml("forge.yaml")
def repo_url(f=None):
f = f or config()
return f"{f['url'].rstrip('/')}/{f['repo']}"
def file_url(path, f=None, raw=True):
"""A file in the repository on its main branch (raw content, or the page that shows it)."""
f = f or config()
if f["kind"] == "github":
if raw:
return f"https://raw.githubusercontent.com/{f['repo']}/{f['branch']}/{path}"
return f"{repo_url(f)}/blob/{f['branch']}/{path}"
return f"{repo_url(f)}/{'raw' if raw else 'src'}/branch/{f['branch']}/{path}"
def new_issue_url(template, f=None):
"""The "new issue" page for an issue form in .github/ISSUE_TEMPLATE/."""
f = f or config()
if f["kind"] == "github":
return f"{repo_url(f)}/issues/new?template={os.path.basename(template)}"
return f"{repo_url(f)}/issues/new?template={urllib.parse.quote(template)}"
def api_base(f=None):
f = f or config()
if f["kind"] == "github":
return f"https://api.github.com/repos/{f['repo']}"
return f"{f['url'].rstrip('/')}/api/v1/repos/{f['repo']}"
def token(env=None):
env = os.environ if env is None else env
for k in ("ATLAS_BOT_TOKEN", "GITEA_TOKEN", "GITHUB_TOKEN", "GH_TOKEN"):
if env.get(k):
return env[k]
return None
def _call(method, url, body=None, tok=None, f=None):
f = f or config()
headers = {"User-Agent": USER_AGENT, "Accept": "application/json"}
if tok:
headers["Authorization"] = f"{'Bearer' if f['kind'] == 'github' else 'token'} {tok}"
data = None
if body is not None:
data = json.dumps(body).encode("utf-8")
headers["Content-Type"] = "application/json"
req = urllib.request.Request(url, data=data, method=method, headers=headers)
with urllib.request.urlopen(req, timeout=60) as r:
text = r.read().decode("utf-8")
return json.loads(text) if text.strip() else None
def list_issues(label, env=None, f=None):
"""Every issue (open and closed, no pull requests) with the label, oldest first, in GitHub's field names
(number, body, labels, state, state_reason, created_at), which both hosts share."""
f = f or config()
tok = token(env)
lab = urllib.parse.quote(label)
out, page = [], 1
while True:
if f["kind"] == "github":
url = f"{api_base(f)}/issues?labels={lab}&state=all&per_page=100&page={page}"
else:
url = f"{api_base(f)}/issues?labels={lab}&state=all&type=issues&limit=50&page={page}"
batch = _call("GET", url, tok=tok, f=f) or []
out += [i for i in batch if "pull_request" not in i or not i["pull_request"]]
if len(batch) < (100 if f["kind"] == "github" else 50):
break
page += 1
for i in out:
i.setdefault("state_reason", None) # Gitea has no close reason: reports are rejected with labels
return sorted(out, key=lambda i: i["number"])
def open_pr(head, title, body, automerge=False, env=None, f=None):
f = f or config()
tok = token(env)
pr = _call("POST", f"{api_base(f)}/pulls", {"head": head, "base": f["branch"], "title": title, "body": body}, tok, f)
n = pr["number"]
if automerge:
if f["kind"] == "github":
# GitHub's auto-merge needs GraphQL; the repo's auto-merge setting merges it when checks pass
print(f"opened #{n}; turn on auto-merge in the pull request page if it is not on by default")
else:
_call("POST", f"{api_base(f)}/pulls/{n}/merge",
{"Do": "squash", "merge_when_checks_succeed": True, "delete_branch_after_merge": True}, tok, f)
return n
def open_issue(title, body, env=None, f=None):
f = f or config()
tok = token(env)
q = urllib.parse.quote(title)
found = _call("GET", f"{api_base(f)}/issues?state=open&type=issues&q={q}" if f["kind"] == "gitea"
else f"{api_base(f)}/issues?state=open&per_page=100", tok=tok, f=f) or []
if any(i.get("title") == title for i in found):
return None
return _call("POST", f"{api_base(f)}/issues", {"title": title, "body": body}, tok, f)["number"]
def ensure_label(name, color, env=None, f=None):
f = f or config()
tok = token(env)
labels = _call("GET", f"{api_base(f)}/labels?limit=50&per_page=100", tok=tok, f=f) or []
if any(lb["name"] == name for lb in labels):
return False
_call("POST", f"{api_base(f)}/labels", {"name": name, "color": ("#" if f["kind"] == "gitea" else "") + color.lstrip("#")}, tok, f)
return True
def main(argv):
import argparse
ap = argparse.ArgumentParser(prog="python -m collection forge")
sub = ap.add_subparsers(dest="cmd", required=True)
p = sub.add_parser("open-pr")
p.add_argument("--head", required=True)
p.add_argument("--title", required=True)
p.add_argument("--body-file", required=True)
p.add_argument("--automerge", action="store_true")
i = sub.add_parser("open-issue")
i.add_argument("--title", required=True)
i.add_argument("--body-file", required=True)
lb = sub.add_parser("ensure-label")
lb.add_argument("--name", required=True)
lb.add_argument("--color", default="e8b07e")
a = ap.parse_args(argv)
if a.cmd == "open-pr":
body = open(a.body_file, encoding="utf-8").read()
print(f"pull request #{open_pr(a.head, a.title, body, a.automerge)}")
elif a.cmd == "open-issue":
n = open_issue(a.title, open(a.body_file, encoding="utf-8").read())
print(f"issue #{n}" if n else "an open issue with that title exists already")
elif a.cmd == "ensure-label":
print("created" if ensure_label(a.name, a.color) else "exists")
return 0
if __name__ == "__main__":
sys.exit(main(sys.argv[1:]))
+82
View File
@@ -0,0 +1,82 @@
"""Hand-offs without GitHub: the zip of atlas files for the bot, and the local equivalent of the daily workflow.
python -m collection export-bot-kit -> exports/atlas-for-bot-<date>-<policy id>.zip
policy.json, solver.js and graph.js (what the bot vendors into vendor/threshing-atlas/), plus a README and
checksums. Send it to the bot's maintainer; they unzip it into vendor/threshing-atlas/.
python -m collection refresh [--bot PATH ...]
Every source (and any bot folders or zips given), then the graph, the route model, the statistics and the
build: what .github/workflows/update-sources.yml does every day.
"""
import hashlib
import json
import shutil
import subprocess
import sys
import zipfile
from datetime import datetime, timezone
from .common import ROOT, path
KIT = {"policy.json": "data/public/policy.json", "solver.js": "core/solver.js", "graph.js": "core/graph.js"}
README = """Threshing Atlas files for the DragonKind bot
============================================
Policy id: {policy}
Made: {made}
Unzip these three files into the bot's vendor/threshing-atlas/ folder, replacing the old ones, and keep them
together: solver.js reads the game from this policy.json.
policy.json the route model (the game, the counts behind every roll, the best routes per colour)
solver.js the advisor: advisor(), recommendOption(), solverHistory()
graph.js trajectoryVariables(): the bot's steps -> the community form's variables
How the bot uses them: docs/BOT_INTEGRATION.md in the atlas repo. Log the policy id above as policyId on each run.
Checksums (sha256):
{sums}
To send runs back: zip the bot's data/runs.jsonl, data/knowledge.json and logs/encounters.jsonl (keep the folder
names) and send the zip. It is imported with `python -m collection refresh --bot <the zip>`; only anonymised
steps and outcomes are kept (no game prose, no account names).
"""
def export_bot_kit(out_dir="exports"):
policy = json.loads(path(KIT["policy.json"]).read_text(encoding="utf-8"))
pid = str(policy.get("id", "unknown"))[:12]
made = datetime.now(timezone.utc).strftime("%Y-%m-%d")
sums = "\n".join(f" {hashlib.sha256(path(src).read_bytes()).hexdigest()} {name}" for name, src in KIT.items())
out = path(out_dir)
out.mkdir(parents=True, exist_ok=True)
zpath = out / f"atlas-for-bot-{made}-{pid}.zip"
with zipfile.ZipFile(zpath, "w", zipfile.ZIP_DEFLATED) as z:
for name, src in KIT.items():
z.writestr(zipfile.ZipInfo(name, (2026, 1, 1, 0, 0, 0)), path(src).read_bytes(), zipfile.ZIP_DEFLATED)
z.writestr(zipfile.ZipInfo("README.txt", (2026, 1, 1, 0, 0, 0)), README.format(policy=pid, made=made, sums=sums))
return zpath
def _step(label, cmd):
print(f"\n== {label}: {' '.join(cmd)}", flush=True)
subprocess.run(cmd, cwd=ROOT, check=True)
def refresh(update_main, bots=()):
"""update -> (graph, policy, stats, build) when something changed. Returns 0 on success."""
py = sys.executable
args = ["update", "--report", str(path("exports/last-report.md"))]
path("exports").mkdir(exist_ok=True)
rc = update_main(args)
for i, b in enumerate(bots):
rc |= update_main(["update", "--source", "bot", "--file", f"bot={b}", "--report", str(path(f"exports/last-report-bot{i + 1}.md"))])
if shutil.which("node"):
_step("route graph", ["node", "analysis/network/build-graph.js"])
else:
print("\n(node is not installed: data/public/graph.json is not rebuilt; everything else is)")
_step("route model (about 2 minutes)", [py, "planner/build_policy.py"])
_step("statistics", [py, "analysis/stats/site_stats.py"])
_step("runs, generated files and metadata", [py, "-m", "collection", "build"])
print(f"\nDone. What changed: exports/last-report.md. Send the bot its files with: {py} -m collection export-bot-kit")
return rc
+54
View File
@@ -0,0 +1,54 @@
"""Load: the only stage that writes public files. Writes are byte-stable (the same table gives the same bytes)
and only happen when the bytes change, so git shows exactly what changed."""
import csv
import io
import json
from .common import json_bytes, jsonl_bytes, path
def public(obj):
"""Drop transient keys (those starting with "_"), which are for the report only."""
if isinstance(obj, dict):
return {k: public(v) for k, v in obj.items() if not str(k).startswith("_")}
if isinstance(obj, list):
return [public(v) for v in obj]
return obj
def read_json(rel):
p = path(rel)
return json.loads(p.read_text(encoding="utf-8")) if p.exists() else None
def write_bytes(rel, data, check=False):
"""Write when different. Returns True when the file changed (or, with check, would change)."""
p = path(rel)
if p.exists() and p.read_bytes() == data:
return False
if not check:
p.parent.mkdir(parents=True, exist_ok=True)
p.write_bytes(data)
return True
def json_file(rel, obj, check=False, compact=True):
return write_bytes(rel, json_bytes(public(obj), compact), check)
def jsonl_file(rel, rows, check=False):
return write_bytes(rel, jsonl_bytes(rows), check)
def csv_bytes(rows, columns):
"""True/False for booleans, empty for missing, everything else as text."""
buf = io.StringIO()
w = csv.writer(buf, lineterminator="\n")
w.writerow(columns)
for r in rows:
w.writerow(["" if r.get(c) is None else r[c] for c in columns])
return buf.getvalue().encode("utf-8")
def csv_file(rel, rows, columns, check=False):
return write_bytes(rel, csv_bytes(rows, columns), check)
+135
View File
@@ -0,0 +1,135 @@
"""Write data/croissant.json (Croissant 1.0 JSON-LD) from data/dictionary.yaml.
Croissant is the MLCommons metadata format for datasets: it says what each file is, its checksum, and what each
column means, so tools (and people) can load and cite the data without reading this repo's code.
Written by `python -m collection build` (a test checks it is up to date).
"""
import json
from . import forge
from .common import ROOT, pipeline, read_yaml, sha256_file
OUT = "data/croissant.json"
CONTEXT = {
"@language": "en",
"@vocab": "https://schema.org/",
"citeAs": "cr:citeAs",
"column": "cr:column",
"conformsTo": "dct:conformsTo",
"cr": "http://mlcommons.org/croissant/",
"data": {"@id": "cr:data", "@type": "@json"},
"dataType": {"@id": "cr:dataType", "@type": "@vocab"},
"dct": "http://purl.org/dc/terms/",
"examples": {"@id": "cr:examples", "@type": "@json"},
"extract": "cr:extract",
"field": "cr:field",
"fileObject": "cr:fileObject",
"fileProperty": "cr:fileProperty",
"format": "cr:format",
"includes": "cr:includes",
"isLiveDataset": "cr:isLiveDataset",
"jsonPath": "cr:jsonPath",
"key": "cr:key",
"md5": "cr:md5",
"parentField": "cr:parentField",
"path": "cr:path",
"recordSet": "cr:recordSet",
"references": "cr:references",
"regex": "cr:regex",
"repeated": "cr:repeated",
"replace": "cr:replace",
"sc": "https://schema.org/",
"separator": "cr:separator",
"source": "cr:source",
"subField": "cr:subField",
"transform": "cr:transform",
}
# Croissant has no boolean-as-text type; the CSV writes True/False, which sc:Boolean parses.
DATA_TYPES = {"text": "sc:Text", "integer": "sc:Integer", "boolean": "sc:Boolean", "date": "sc:Date"}
sha256 = sha256_file
def load_dictionary():
return read_yaml("data/dictionary.yaml")
def field_description(spec):
text = " ".join(spec["description"].split())
if spec.get("values"):
text += " Values: " + "; ".join(str(v) for v in spec["values"]) + "."
return text
def build(dictionary=None):
d = dictionary or load_dictionary()
ds = d["dataset"]
fg = forge.config()
sources = pipeline()["sources"]
distribution = []
for key, spec in d["files"].items():
path = ROOT / spec["path"]
entry = {
"@type": "cr:FileObject",
"@id": key,
"name": key,
"description": " ".join(spec["description"].split()),
"contentUrl": forge.file_url(spec["path"], fg),
"encodingFormat": spec["format"],
"sha256": sha256(path),
"contentSize": f"{path.stat().st_size} B",
}
distribution.append(entry)
fields = [
{
"@type": "cr:Field",
"@id": f"runs/{name}",
"name": name,
"description": field_description(spec),
"dataType": DATA_TYPES[spec["type"]],
"source": {"fileObject": {"@id": "runs_clean"}, "extract": {"column": name}},
}
for name, spec in d["columns"].items()
]
return {
"@context": CONTEXT,
"@type": "sc:Dataset",
"conformsTo": "http://mlcommons.org/croissant/1.0",
"name": ds["name"],
"description": " ".join(ds["description"].split()),
"url": fg.get("site") or forge.repo_url(fg),
"sameAs": forge.repo_url(fg),
"license": ds["license"],
"creator": {"@type": "sc:Person", "name": ds["creator"]},
"keywords": ds["keywords"],
"citeAs": ds["citation"].format(repository=forge.repo_url(fg)),
"isLiveDataset": True,
"isBasedOn": [
{"@type": "sc:CreativeWork", "name": s["label"], "url": next(iter(s["links"].values()))}
for s in sources.values()
# the route PDF is only fingerprinted, never redistributed; the bot's repo is private
if (s.get("privacy") or {}).get("redistribute", True) and s.get("links")
],
"distribution": distribution,
"recordSet": [
{
"@type": "cr:RecordSet",
"@id": "runs",
"name": "runs",
"description": "One coded threshing run per row, from every source (data/public/runs_clean.csv).",
"key": {"@id": "runs/run_id"},
"field": fields,
}
],
}
def render(doc):
return json.dumps(doc, indent=2, ensure_ascii=False) + "\n"
+60
View File
@@ -0,0 +1,60 @@
"""The "Report a run" GitHub issue form, written from collection/specs/report_form.yaml, and the parser for the
issues it creates (GitHub renders each answer as "### <question>" followed by the answer)."""
import re
import yaml
from .common import read_yaml
class _Dumper(yaml.SafeDumper):
pass
def _str(dumper, s):
# multi-line text (the intro) as a readable block
return dumper.represent_scalar("tag:yaml.org,2002:str", s, style="|" if "\n" in s else None)
_Dumper.add_representer(str, _str)
SPEC_PATH = "collection/specs/report_form.yaml"
TEMPLATE = ".github/ISSUE_TEMPLATE/report-a-run.yml"
NOT_SURE = "Not sure"
NO_RESPONSE = {"", "_No response_", "None", NOT_SURE}
def spec():
return read_yaml(SPEC_PATH)
def render(s=None):
s = s or spec()
body = [{"type": "markdown", "attributes": {"value": s["intro"]}}]
for f in s["fields"]:
if f.get("type") == "integer":
item = {"type": "input", "id": f["id"], "attributes": {"label": f["label"], "placeholder": "e.g. 3"}}
else:
opts = list(f["options"])
if not f.get("required"):
opts.append(NOT_SURE)
item = {"type": "dropdown", "id": f["id"], "attributes": {"label": f["label"], "options": opts}}
item["validations"] = {"required": bool(f.get("required"))}
body.append(item)
form = {"name": s["name"], "description": s["description"], "title": s["title"], "labels": [s["label"]], "body": body}
head = f"# Written by collection/etl/report_form.py from {SPEC_PATH}: edit that file, then run `python -m collection build`.\n"
return head + yaml.dump(form, Dumper=_Dumper, sort_keys=False, allow_unicode=True, width=1000)
def parse_body(body, s=None):
"""Issue body -> {field id: chosen option label or text}. Unanswered questions are left out."""
s = s or spec()
by_label = {f["label"].strip(): f["id"] for f in s["fields"]}
out = {}
for block in re.split(r"^### ", body or "", flags=re.M)[1:]:
q, _, a = block.partition("\n")
fid = by_label.get(q.strip())
a = a.strip()
if fid and a not in NO_RESPONSE:
out[fid] = a
return out
+233
View File
@@ -0,0 +1,233 @@
"""Build: every public source file -> one coded run per row, for data/public/runs_clean.csv.
One coder per source (pipeline.yaml `runs:`). Every coder returns rows keyed by the columns of data/dictionary.yaml;
missing answers get the same "not known" values the community form's coding uses, so every source can be filtered
the same way. The `source` column says where a run came from; `entry` keeps the spreadsheet's own row label.
"""
import json
import re
from pathlib import Path
from .common import path, read_jsonl, read_yaml
from . import report_form
DICT = read_yaml("data/dictionary.yaml")
COLUMNS = list(DICT["columns"])
COLOURS = ["Red", "Green", "Orange", "Brown", "Blue", "Black"]
# what "not known" is, per column, for sources that did not ask (the community form's coding uses the same)
NOT_KNOWN = {
"wing": "Unknown", "squad": "Unknown", "attempt_group": "Unknown", "goal": "(not asked/blank)",
"company": "Unknown", "direction": "Unknown", "first_sighting": "Unknown", "sighting_action": "Unknown",
"scream": "Unknown", "resolution": "Unknown", "combat_first": "(not recorded)", "combat_second": "(not recorded)",
"post_path": "Unknown", "hour": "Unknown", "rare_reported": "(not asked)", "malek_intent": "(not asked)",
"outcome": "No outcome recorded", "data_flags": "",
}
def blank_row(**values):
row = {c: None for c in COLUMNS}
row.update(values)
for c, v in NOT_KNOWN.items():
if row[c] is None:
row[c] = v
return row
def attempt_group(n):
return "First attempt" if n == 1 else "Later attempt" if n and n > 1 else "Unknown"
def encounter_columns(row, intentional=False):
"""The bonding-grid column of the dragon that ended the run."""
col = row["outcome_color"]
if col and not intentional:
if row["outcome"] == "Bonded":
row["enc_" + col] = "Bonded!"
elif row["outcome"] == "Incinerated":
row["enc_" + col] = "Incinerated"
# ---------------------------------------------------------------- coders, by pipeline.yaml `runs:`
def spreadsheet(name, spec):
"""The community form: core/spec/form.yaml + core/atlas/coding.py, unchanged."""
from atlas import coding
df, missing = coding.code_frame(coding.read_export(path(spec["load"])))
if missing:
print(f"WARNING: {name}: questions not found in the sheet: {missing}")
df["attempt"] = df["attempt"].astype("Int64")
rows = []
for rec in df.astype(object).where(df.notna(), None).to_dict("records"):
n = rec.pop("run_id")
entry = rec.pop("source")
rows.append({**{c: None for c in COLUMNS}, **rec, "run_id": f"sheet-{n}", "source": spec["run_source"], "entry": entry})
return rows
def reddit_results(name, spec):
"""Dragons read from result pages linked in the megathreads: bonded, colour and tail known, route unknown."""
rows = []
for r in read_yaml(spec["transform"]["manual"])["results"]:
row = blank_row(run_id=f"thread-{r['id']}", source=spec["run_source"], outcome="Bonded",
outcome_color=r["colour"], tail=r["tail"])
encounter_columns(row)
rows.append(row)
return rows
def reports(name, spec):
"""Runs reported through the "Report a run" issue form (collection/specs/report_form.yaml)."""
form = report_form.spec()
fields = {f["id"]: f for f in form["fields"]}
p = path(spec["load"])
data = json.loads(p.read_text(encoding="utf-8")) if p.exists() else {"reports": []}
rows = []
for rep in data["reports"]:
vals, flags = {}, []
for fid, answer in rep["answers"].items():
f = fields.get(fid)
if not f:
continue
if f.get("type") == "integer":
m = re.search(r"\d+", answer)
vals[f["column"]] = int(m.group()) if m else None
elif answer in f["options"]:
vals[f["column"]] = f["options"][answer]
else:
flags.append(f"unrecognised answer to {fid}")
row = blank_row(run_id=f"reported-{rep['number']}", source=spec["run_source"], date=rep.get("opened"), **vals)
row["attempt_group"] = attempt_group(row["attempt"])
if row["outcome"] == "Died before the hour" and row["hour"] == "Unknown":
row["hour"] = "DIED before the hour"
branch = row["branch"]
if branch:
tree = branch in ("Shadow (rare)", "Descend quickly: Red", "Descend quickly: let the Red pass", "Descend slowly: two Greens")
if row["hour"] == "Unknown":
row["hour"] = "Tree" if tree else "Valley"
elif row["hour"] != ("Tree" if tree else "Valley"):
flags.append("encounter does not match the tree/valley answer")
row["saw_shadow"] = branch == "Shadow (rare)" if tree else None
if branch == "Passed the Red: meadow" and row["outcome_color"] == "Blue":
row["saw_blue_meadow"] = True
if row["outcome"] == "Bonded" and not row["outcome_color"]:
flags.append("bonded, colour not given")
encounter_columns(row)
row["data_flags"] = "; ".join(flags)
rows.append(row)
return rows
def _norm(text):
from .transform.bot import normalize
return normalize(text)
def bot_trajectories(spec):
"""Every published trajectory (data/bot/trajectories-*.jsonl), each attempt once."""
seen, out = set(), []
for f in sorted(Path(path(spec["load"])).glob("trajectories-*.jsonl")):
for t in read_jsonl(f):
if t["id"] not in seen:
seen.add(t["id"])
out.append(t)
return out
def bot_variables(traj, crosswalk):
"""A bot attempt -> columns, through the crosswalk in collection/specs/bot.yaml. First match wins."""
v, unmapped = {}, []
for s in traj["steps"]:
t = _norm(s["optionText"])
hit = next((c for c in crosswalk if c[0].search(t)), None)
if hit:
v.setdefault(hit[1], hit[2])
else:
unmapped.append(s["optionText"])
# the first dragon is the first tinted scene once the direction is chosen
if v.get("direction") and not v.get("first_sighting") and s.get("tint"):
v["first_sighting"] = s["tint"].capitalize()
return v, unmapped
BURN_REASONS = { # why the bot chose to die, in words (the bot's own reason codes)
"TREE_NO_SHADOW_AUTO_BURN": "no shadow at the tree",
"MEADOW_NO_BLUE_AUTO_BURN": "no Blue in the meadow",
}
def _seen_after(steps, start, key):
"""Values the bot saw (step["seen"][key]) from step index `start` on."""
out = []
for st in steps[start:]:
v = (st.get("seen") or {}).get(key)
if v is not None:
out += v if isinstance(v, list) else [v]
return out
def bot(name, spec):
cw = [(re.compile(rx), col, val) for rx, col, val in read_yaml(spec["transform"]["spec"])["crosswalk"]]
rows = []
for traj in bot_trajectories(spec):
steps = traj["steps"]
v, _ = bot_variables(traj, cw)
red = v.pop("red", None)
v.pop("scream_investigate", None)
if red == "Let it pass (two Greens)":
v["branch"] = "Descend quickly: let the Red pass"
o = traj["outcome"]
meta = traj.get("meta") or {}
flags = []
if o["type"] == "BONDED":
outcome, colour = "Bonded", (o.get("colour") or "").capitalize() or None
elif o["type"] == "BURNED":
last_tint = steps[-1].get("tint") if steps else None
outcome = "Incinerated" if v.get("hour") else "Died before the hour"
colour = last_tint.capitalize() if last_tint and v.get("hour") else None
if o.get("intentional"):
why = BURN_REASONS.get(o.get("reason") or "", "")
flags.append("deliberate burn (the bot chose to die" + (f": {why}" if why else "") + ")")
else: # ABORTED, ENDED_NO_BOND: the run stopped without an ending the bot saw
outcome, colour = "No outcome recorded", None
if not steps:
flags.append("bonded dragon only (the bot logged no steps)")
target = (meta.get("target") or "").capitalize() or None
row = blank_row(run_id=traj["id"], source=spec["run_source"], bot_mode=meta.get("decisionMode"),
date=(meta.get("startedAt") or "")[:10] or None, attempt=meta.get("attempt"),
goal=target if target in COLOURS else None,
outcome=outcome, outcome_color=colour, data_flags="; ".join(flags), **v)
row["attempt_group"] = attempt_group(row["attempt"])
if target: # the bot never bonds a dragon it was not sent for: it dies on purpose instead (Malek)
row["malek_intent"] = "Yes"
if outcome == "Died before the hour" and not o.get("intentional"): # where the game killed it
if row["scream"] == "Unknown":
row["scream"] = "DIED at first sighting"
elif row["scream"] == "Investigate & help" and row["resolution"] == "Unknown":
row["resolution"] = "DIED in combat"
else:
row["hour"] = "DIED before the hour"
# what the bot saw: the shadow at the treetop, and which dragons waited in the meadow
shadow = _seen_after(steps, 0, "shadow")
if row["hour"] == "Tree" and shadow:
row["saw_shadow"] = any(shadow)
if row["branch"] == "Passed the Red: meadow":
i = next((k for k, st in enumerate(steps) if re.search(r"no way this is your dragon", _norm(st["optionText"]))), len(steps))
meadow = _seen_after(steps, i + 1, "dragons")
if meadow or o.get("reason") == "MEADOW_NO_BLUE_AUTO_BURN":
row["saw_blue_meadow"] = "blue" in meadow or colour == "Blue"
encounter_columns(row, intentional=bool(o.get("intentional")))
rows.append(row)
return rows
CODERS = {"spreadsheet": spreadsheet, "reddit_results": reddit_results, "reports": reports, "bot": bot}
def build_runs(pipe):
rows = []
for name in pipe["runs"]["order"]:
spec = pipe["sources"][name]
if spec.get("runs"):
rows += CODERS[spec["runs"]](name, spec)
return rows
+7
View File
@@ -0,0 +1,7 @@
"""Named transforms (pipeline.yaml `transform: {name: ...}`). Each module has
transform(raw_path, spec, ctx) -> the public source file's content (pure: no network, no clock)
describe(old, new) -> report lines comparing the previous public file with the new one
"""
from . import bot, pdf, reddit, reports, sheet
TRANSFORMS = {"sheet": sheet, "pdf_fingerprint": pdf, "bot": bot, "reddit_results": reddit, "reports": reports}
+367
View File
@@ -0,0 +1,367 @@
"""The DragonKind bot's private data -> anonymised trajectories and a scene catalogue (Python port of bot.js).
Raw input (from the private bot repo, packed by extract.local_dir): data/knowledge.json (scene atlas: prose,
choices, tint, backdrop), data/runs.jsonl (one record per attempt) and logs/encounters.jsonl (every decision the
bot made, with the options on screen). Nothing of the prose or the account ids leaves this module: the output
holds scene fingerprints, short labels (collection/specs/bot.yaml), choice text and outcomes, and check_public()
refuses anything else.
Output: {"scenes": {sceneId: {stage, tint, backdrop, label, options: [{id, text}]}},
"trajectories": [{id, source, meta, steps, outcome}], "unlabeled": [...]}
"""
import hashlib
import json
import re
from datetime import datetime
from ..common import read_yaml
SPEC = read_yaml("collection/specs/bot.yaml")
_NORMALIZE = [(re.compile(a), b) for a, b in SPEC["normalize"]]
CHOICE_EVENTS = set(SPEC["choice_events"])
def sha1(s, n=12):
return hashlib.sha1(str(s).encode("utf-8")).hexdigest()[:n]
def normalize(text):
"""Must match normalize() in the bot's src/strategy.js, so fingerprints line up."""
t = str(text or "").lower()
for rx, rep in _NORMALIZE:
t = rx.sub(rep, t)
return t.strip()
def scene_id(prose, choices):
"""Must match computeSceneFingerprint() in the bot's src/learner.js."""
prose_norm = normalize(prose)[:500]
opts = sorted(c for c in (normalize(c) for c in choices) if c)
return sha1(f"{prose_norm} ### {' || '.join(opts)}")
def option_id(text):
return sha1(normalize(text), 10)
def label_for(sid, node):
if sid in SPEC["labels"]:
return SPEC["labels"][sid]
bits = [node.get("stage") or "Scene"]
if node.get("tint"):
bits.append(node["tint"])
return " · ".join(bits)
def _jsonl(text):
out = []
for line in (text or "").splitlines():
if line.strip():
try:
out.append(json.loads(line))
except json.JSONDecodeError:
pass
return out
def build_scenes(knowledge, encounters):
scenes = {}
for sid, n in ((knowledge or {}).get("nodes") or {}).items():
scenes[sid] = {
"stage": n.get("stage") or "UNKNOWN", "tint": n.get("tint"), "backdrop": n.get("backdrop"),
"label": label_for(sid, n),
"options": [{"id": option_id(c.get("label") or c.get("choiceNorm")), "text": c.get("label") or c.get("choiceNorm")}
for c in (n.get("choices") or {}).values()],
}
for e in encounters:
if not isinstance(e.get("choices"), list) or not e.get("prose"):
continue
sid = e.get("nodeId") or scene_id(e["prose"], e["choices"])
if sid in scenes:
continue
stage = (e.get("decision") or {}).get("stage") or e.get("stage") or "UNKNOWN"
scenes[sid] = {"stage": stage, "tint": None, "backdrop": None, "label": label_for(sid, {"stage": stage}),
"options": [{"id": option_id(t), "text": t} for t in e["choices"]]}
return scenes
def trajectories_from_encounters(encounters, scenes):
"""Group the log by attempt, keep the decisions acted on, and close each attempt at its first BURNED or
DRAGON_BONDED event. Repeated BURNED events with no decision between them are ignored."""
by_attempt = {}
for e in encounters:
key = f"{e['account']}:{e.get('attempt')}" if e.get("account") else str(e.get("attempt"))
by_attempt.setdefault(key, []).append(e)
out = []
for key, events in by_attempt.items():
events = sorted(events, key=lambda e: str(e.get("ts")))
steps, outcome = [], None
for e in events:
if outcome:
break
if e.get("event") in CHOICE_EVENTS:
d = e.get("decision") or {}
text = d.get("choiceText") or e.get("choiceText")
if d.get("action") and d["action"] != "choose":
continue # paused, nothing happened
if not text or not isinstance(e.get("choices"), list):
continue
scene = e.get("nodeId") or scene_id(e.get("prose") or "", e["choices"])
manual = e["event"] != "DECISION"
sc = scenes.get(scene) or {}
steps.append({
"scene": scene, "stage": d.get("stage") or sc.get("stage") or "UNKNOWN", "tint": sc.get("tint"),
"option": option_id(text), "optionText": text, "offered": [option_id(c) for c in e["choices"]],
"rule": d.get("rule"), "decisionMode": "manual" if manual else d.get("source"),
"manual": manual, "at": e.get("ts"),
})
elif e.get("event") == "BURNED" and steps:
outcome = {"type": "BURNED", "colour": None, "intentional": bool(e.get("intentional"))}
elif e.get("event") == "DRAGON_BONDED" and steps:
outcome = {"type": "BONDED", "colour": str(e["dragon"]).lower() if e.get("dragon") else None, "intentional": False}
# a decision repeated on the same scene (the bot re-detecting the screen) counts once
dedup = [s for i, s in enumerate(steps)
if not (i > 0 and steps[i - 1]["scene"] == s["scene"] and steps[i - 1]["option"] == s["option"])]
for i, s in enumerate(dedup):
s["to"] = dedup[i + 1]["scene"] if i + 1 < len(dedup) else None
if not dedup:
continue
if outcome:
dedup[-1]["to"] = "BURNED" if outcome["type"] == "BURNED" else f"BONDED:{outcome['colour'] or 'unknown'}"
try:
attempt = int(float(key.split(":")[-1])) or None
except ValueError:
attempt = None
started = dedup[0]["at"]
out.append({
"id": "bot-" + sha1(f"{key}:{started}", 10),
"source": "bot",
"meta": {"attempt": attempt, "startedAt": dedup[0]["at"], "accountKey": None, "target": None, "decisionMode": None},
"steps": dedup,
"outcome": outcome or {"type": "ABORTED", "colour": None, "intentional": False},
})
return out
def _ms(ts):
try:
return datetime.fromisoformat(str(ts).replace("Z", "+00:00")).timestamp() * 1000
except ValueError:
return float("nan")
def attach_run_meta(trajs, runs, salt):
"""Run-level metadata (target colour, mode) from runs.jsonl, where an attempt is in both."""
window = SPEC["match_hours"] * 3600e3
for r in runs:
t = next((x for x in trajs if x["meta"]["attempt"] == r.get("attempt")
and abs(_ms(x["meta"]["startedAt"]) - _ms(r.get("startedAt"))) < window), None)
if not t:
continue
m = t["meta"]
m["target"] = r.get("targetDragon")
m["decisionMode"] = r.get("decisionMode")
m["policyId"] = r.get("policyId")
m["experimentId"] = r.get("experimentId")
m["arm"] = r.get("arm")
if r.get("accountKey"):
m["accountKey"] = r["accountKey"]
elif r.get("accountId") and salt:
m["accountKey"] = sha1(f"{salt}:{r['accountId']}", 10)
if r.get("outcome") == "BONDED" and r.get("dragonColor"):
t["outcome"] = {"type": "BONDED", "colour": str(r["dragonColor"]).lower(), "intentional": False}
if r.get("intentionalBurn"):
t["outcome"]["intentional"] = True
return trajs
def import_bot(knowledge, encounters, runs, salt=None):
scenes = build_scenes(knowledge, encounters)
trajectories = attach_run_meta(trajectories_from_encounters(encounters, scenes), runs, salt)
unlabeled = [f"{sid} ({s['stage']}{', ' + s['tint'] if s['tint'] else ''})" for sid, s in scenes.items() if sid not in SPEC["labels"]]
return scenes, trajectories, unlabeled
def check_public(obj, refuse, max_string):
"""Nothing that looks like game prose or an account identifier may leave this module."""
def walk(v, p):
if isinstance(v, list):
for i, x in enumerate(v):
walk(x, f"{p}[{i}]")
elif isinstance(v, dict):
for k, x in v.items():
if k in refuse:
raise ValueError(f'refusing to export field "{k}" at {p}')
walk(x, f"{p}.{k}")
elif isinstance(v, str) and len(v) > max_string:
raise ValueError(f"refusing to export a {len(v)}-character string at {p} (looks like prose)")
walk(obj, "$")
def merge_scenes(existing, scenes):
"""Add new scenes and new options to the published catalogue; never drop what is already there."""
out = json.loads(json.dumps(existing or {}))
for sid, s in scenes.items():
old = out.get(sid)
if not old:
out[sid] = s
continue
ids = {o["id"] for o in old["options"]}
old["options"] += [o for o in s["options"] if o["id"] not in ids]
old["tint"] = old.get("tint") or s["tint"]
old["backdrop"] = old.get("backdrop") or s["backdrop"]
if "·" in old["label"] and "·" not in s["label"]:
old["label"] = s["label"]
return dict(sorted(out.items()))
# ---------------------------------------------------------------- run records with steps (the bot's schema 2)
def _to(key):
"""The bot's toKey -> ours: a scene id, BURNED or BONDED:<colour>."""
key = str(key or "")
if key == "TERMINAL:BURNED":
return "BURNED"
if key.startswith("TERMINAL:BONDED"):
return "BONDED:" + (key.split("_", 1)[1].lower() if "_" in key else "unknown")
return key or None
def _seen(observed):
"""What the bot saw on a screen that the route model needs: the dragons (from the tint) and the shadow."""
o = observed or {}
out = {}
if o.get("dragons"):
out["dragons"] = [str(d).lower() for d in o["dragons"]]
if "shadow" in o:
out["shadow"] = bool(o["shadow"])
return out
def trajectory_from_run(r, account_key):
"""A run record that carries its own steps -> a trajectory. Nothing but choice text, ids and outcomes is kept."""
steps = []
for st in r.get("steps") or []:
text = st.get("choiceText") or st.get("choiceNorm")
if not text:
continue
steps.append({
"scene": st.get("nodeId"), "stage": st.get("stage") or "UNKNOWN", "tint": st.get("tint"),
"option": option_id(text), "optionText": text,
"offered": [option_id(o.get("text") or o.get("norm")) for o in st.get("offered") or [] if o.get("text") or o.get("norm")],
"rule": st.get("rule"), "decisionMode": "manual" if st.get("manual") else st.get("decisionMode"),
"manual": bool(st.get("manual")), "at": st.get("at"), "seen": _seen(st.get("observed")),
"propensity": st.get("propensity"), "to": _to(st.get("toKey")),
})
colour = str(r["dragonColor"]).lower() if r.get("dragonColor") else None
return {
"id": "bot-" + sha1(r["runId"], 10),
"source": "bot",
"meta": {"attempt": r.get("accountAttempt") or r.get("attempt"), "startedAt": r.get("startedAt"),
"accountKey": account_key, "accountRole": r.get("accountRole"), "target": r.get("targetDragon"),
"decisionMode": r.get("decisionMode"), "policyId": r.get("policyId"),
"experimentId": r.get("experimentId"), "arm": r.get("arm")},
"steps": steps,
"outcome": {"type": r.get("outcome") or "ABORTED", "colour": colour, "intentional": bool(r.get("intentionalBurn")),
"reason": (r.get("burn") or {}).get("reason")},
}
def _account_files(files):
"""{account: {"runs": [...], "encounters": [...]}} from the packed files. The top-level files are the bot's
original single account; data/accounts/<name>/ and logs/accounts/<name>/ hold one account each."""
out = {}
for rel, text in files.items():
if text is None:
continue
parts = rel.split("/")
acct = parts[2] if len(parts) == 4 and parts[1] == "accounts" else "(default)"
kind = "runs" if rel.endswith("runs.jsonl") else "encounters" if rel.endswith("encounters.jsonl") else None
if kind:
out.setdefault(acct, {"runs": [], "encounters": []})[kind] += _jsonl(text)
# since the bot keeps one folder per account, its top-level files mirror its first account (the same runs,
# logged a moment apart): counting both would count those runs twice
if len(out) > 1:
out.pop("(default)", None)
return out
def account_salt(env, privacy):
"""The salt that turns account names into anonymous keys: the environment variable if set, otherwise one made
once and kept in the private raw store (data/raw/bot/account-salt.txt, never committed)."""
salt = env.get(privacy.get("account_salt_env", ""))
if salt:
return salt
from ..common import path
import secrets
p = path("data/raw/bot/account-salt.txt")
if not p.exists():
p.parent.mkdir(parents=True, exist_ok=True)
p.write_text(secrets.token_hex(16), encoding="utf-8")
return p.read_text(encoding="utf-8").strip()
def transform(raw_path, spec, ctx):
with open(raw_path, encoding="utf-8") as f:
files = json.load(f)
k = files.get("data/knowledge.json")
knowledge = json.loads(k) if k else {"nodes": {}}
privacy = spec.get("privacy") or {}
salt = account_salt(ctx.get("env", {}), privacy)
accounts = _account_files(files)
all_encounters = [e for a in accounts.values() for e in a["encounters"]]
scenes = build_scenes(knowledge, all_encounters)
trajectories, seen_ids = [], set()
for acct, data in sorted(accounts.items()):
key = sha1(f"{salt}:{acct}", 10)
with_steps = [r for r in data["runs"] if r.get("steps") and r.get("runId")]
for r in with_steps:
t = trajectory_from_run(r, key)
if t["id"] not in seen_ids:
seen_ids.add(t["id"])
trajectories.append(t)
# older runs without steps: rebuild them from the decision log, as before
legacy = [r for r in data["runs"] if not r.get("steps")]
window = SPEC["match_hours"] * 3600e3
same_run = lambda t, r: (t["meta"]["attempt"] == (r.get("accountAttempt") or r.get("attempt")) # noqa: E731
and abs(_ms(t["meta"]["startedAt"]) - _ms(r.get("startedAt"))) < window)
old = attach_run_meta(trajectories_from_encounters(data["encounters"], scenes), legacy, salt)
kept = []
for t in old: # the decision log also holds the runs that have steps: keep only the others
if any(same_run(t, r) for r in with_steps) or t["id"] in seen_ids:
continue
t["meta"]["accountKey"] = key
seen_ids.add(t["id"])
trajectories.append(t)
kept.append(t)
# bonded runs logged without any steps still say which dragon was bonded
for r in legacy:
if r.get("outcome") == "BONDED" and r.get("runId") and not any(same_run(t, r) for t in kept):
t = trajectory_from_run({**r, "steps": []}, key)
if t["id"] not in seen_ids:
seen_ids.add(t["id"])
trajectories.append(t)
# scenes the run records show but the knowledge file does not have yet
for t in trajectories:
for st in t["steps"]:
if st["scene"] and st["scene"] not in scenes:
scenes[st["scene"]] = {"stage": st["stage"], "tint": st["tint"], "backdrop": None,
"label": label_for(st["scene"], {"stage": st["stage"], "tint": st["tint"]}), "options": []}
sc = scenes.get(st["scene"])
if sc is not None and st["option"] not in {o["id"] for o in sc["options"]}:
sc["options"].append({"id": st["option"], "text": st["optionText"]})
unlabeled = [f"{sid} ({s['stage']}{', ' + s['tint'] if s['tint'] else ''})" for sid, s in scenes.items() if sid not in SPEC["labels"]]
for obj in (scenes, trajectories):
check_public(obj, set(privacy.get("refuse_fields", [])), privacy.get("max_string", 200))
trajectories.sort(key=lambda t: (str(t["meta"].get("startedAt")), t["id"]))
return {"scenes": scenes, "trajectories": trajectories, "_unlabeled": unlabeled}
def describe(old, new):
outcomes = {}
for t in new["trajectories"]:
outcomes[t["outcome"]["type"]] = outcomes.get(t["outcome"]["type"], 0) + 1
lines = [f"{len(new['scenes'])} scenes, {len(new['trajectories'])} attempts {json.dumps(outcomes)}"]
if new.get("_unlabeled"):
lines.append(" - Scenes without a short label (add them to collection/specs/bot.yaml): " + ", ".join(new["_unlabeled"]))
return lines
+51
View File
@@ -0,0 +1,51 @@
"""The route PDF -> its fingerprint only. The PDF is never redistributed: the public file holds hashes of the file,
of each page's text and of each line, so a change can be detected and located without keeping the text."""
import hashlib
def _sha(text, n):
return hashlib.sha256(text.encode("utf-8")).hexdigest()[:n]
def pdf_lines(path):
from pypdf import PdfReader
pages = []
for page in PdfReader(str(path)).pages:
text = page.extract_text() or ""
pages.append([" ".join(line.split()) for line in text.splitlines() if line.strip()])
return pages
def transform(raw_path, spec, ctx):
with open(raw_path, "rb") as f:
data = f.read()
pages = pdf_lines(raw_path)
return {
"sha256": hashlib.sha256(data).hexdigest(),
"bytes": len(data),
"pages": len(pages),
"page_hashes": [_sha("\n".join(p), 16) for p in pages],
"line_hashes": sorted({_sha(line.lower(), 12) for p in pages for line in p}),
"checked": ctx.get("changed"),
# transient: the new lines' text, for the report only (load drops every key starting with "_")
"_lines": [line for p in pages for line in p],
}
def describe(old, new):
if old is None:
return [f"fingerprint recorded for the first time ({new['pages']} pages)"]
if old.get("page_hashes") == new["page_hashes"]:
return ["the file changed but its text did not (layout or images only). Worth a look."]
changed = [i + 1 for i, h in enumerate(new["page_hashes"])
if i >= len(old["page_hashes"]) or old["page_hashes"][i] != h]
old_lines = set(old["line_hashes"])
new_lines = [line for line in new.get("_lines", []) if _sha(line.lower(), 12) not in old_lines]
lines = [f"changed. {old['pages']} → {new['pages']} pages; pages with new text: {', '.join(map(str, changed)) or 'none'}; "
f"{len(new_lines)} new lines, {len(old_lines - set(new['line_hashes']))} lines gone."]
if new_lines:
lines.append(" - New lines (update core/spec/game.yaml or the crosswalks if they add options):")
lines += [f" - {line}" for line in new_lines[:60]]
if len(new_lines) > 60:
lines.append(f" - … and {len(new_lines) - 60} more")
return lines
+45
View File
@@ -0,0 +1,45 @@
"""Reddit megathreads (raw: the threads' comment trees from the official API) -> dragonkind.com result links that
are not yet in collection/manual/reddit_results.yaml. Usernames and comment text are never kept: only the result
ids and the comment permalinks, for the report, so a person can read the result page and add it by hand."""
import json
import re
from pathlib import Path
from ..common import read_yaml
RESULT_RE = re.compile(r"dragonkind\.com/results/(THRESH-[A-Z0-9]+)", re.I)
def _comments(node):
"""Every comment in a listing tree."""
if isinstance(node, list):
for x in node:
yield from _comments(x)
elif isinstance(node, dict):
data = node.get("data") or {}
if node.get("kind") in ("t1", "t3"):
yield data
for key in ("children", "replies"):
if isinstance(data.get(key), (dict, list)):
yield from _comments(data[key])
def transform(raw_path, spec, ctx):
threads = json.loads(Path(raw_path).read_text(encoding="utf-8"))
known = {r["id"].upper() for r in read_yaml(spec["transform"]["manual"])["results"]}
found = {}
for tid, tree in sorted(threads.items()):
for c in _comments(tree):
for m in RESULT_RE.finditer((c.get("body") or "") + " " + (c.get("selftext") or "") + " " + (c.get("url") or "")):
rid = m.group(1).upper()
if rid not in known and rid not in found:
found[rid] = "https://www.reddit.com" + (c.get("permalink") or f"/comments/{tid}/")
return {"new_results": [{"id": k, "comment": v} for k, v in sorted(found.items())]}
def describe(old, new):
rs = new["new_results"]
if not rs:
return ["no new result links in the threads"]
return [f"{len(rs)} result link(s) not yet in collection/manual/reddit_results.yaml (read each page, then add it):"] + \
[f" - https://dragonkind.com/results/{r['id']} (posted at {r['comment']})" for r in rs[:40]]
+31
View File
@@ -0,0 +1,31 @@
"""Run reports (raw: the "run report" issues from the GitHub API) -> data/public/reports.json.
Kept per report: the issue number, the date it was opened, and the answers (the option labels chosen). GitHub
usernames and any other text are dropped. Reports closed as "not planned" or carrying a reject label (e.g.
invalid, duplicate) are left out, so a maintainer removes a bad report by closing it that way."""
import json
from pathlib import Path
from .. import report_form
def transform(raw_path, spec, ctx):
issues = json.loads(Path(raw_path).read_text(encoding="utf-8"))
reject = set(spec["transform"].get("reject_labels", []))
form = report_form.spec()
reports = []
for i in sorted(issues, key=lambda i: i["number"]):
labels = {lb["name"] if isinstance(lb, dict) else lb for lb in i.get("labels") or []}
if labels & reject or i.get("state_reason") == "not_planned":
continue
answers = report_form.parse_body(i.get("body"), form)
if not answers:
continue
reports.append({"number": i["number"], "opened": (i.get("created_at") or "")[:10] or None, "answers": answers})
return {"source": spec["label"], "reports": reports}
def describe(old, new):
o = {r["number"] for r in (old or {}).get("reports", [])}
n = {r["number"] for r in new["reports"]}
return [f"{len(n)} report(s) ({len(n - o)} new, {len(o - n)} removed)"]
+75
View File
@@ -0,0 +1,75 @@
"""A Google Sheets export (.xlsx or .csv) -> the public source file: the sheet's own questions and answers, with the
source's privacy rules applied. No recoding happens here (that is core/atlas/coding.py, at build time)."""
import re
from datetime import datetime
import pandas as pd
from ..common import read_yaml
EMAIL_RE = re.compile(r"[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}")
def load_sheet(path, sheet_contains="form responses"):
if str(path).lower().endswith(".csv"):
return pd.read_csv(path)
xl = pd.ExcelFile(path)
sheet = next((n for n in xl.sheet_names if sheet_contains in n.lower()), xl.sheet_names[0])
return pd.read_excel(xl, sheet)
def cell(v, redact=True):
if v is None or v is pd.NaT or (not isinstance(v, str) and pd.isna(v)):
return None
if isinstance(v, (datetime, pd.Timestamp)):
return pd.Timestamp(v).strftime("%Y-%m-%d %H:%M:%S")
if isinstance(v, float) and v.is_integer():
return int(v)
if isinstance(v, str) and redact:
return EMAIL_RE.sub("[email removed]", v) # respondents sometimes leave an email in free text
return v
def extra_results(manual):
"""Dragons read from result pages linked on Reddit (collection/manual/reddit_results.yaml)."""
return [{"source": "dragonkind.com result page linked on Reddit", "url": f"https://dragonkind.com/results/{r['id']}",
"name": r["name"], "colour": r["colour"], "tail": r["tail"], "sex": r["sex"], "age": r["age"],
"lineage": r["lineage"]} for r in read_yaml(manual)["results"]]
def transform(raw_path, spec, ctx):
t, privacy = spec["transform"], spec.get("privacy") or {}
raw = load_sheet(raw_path, t.get("sheet_contains", "form responses"))
drop = [d.lower() for d in privacy.get("drop_columns_matching", [])]
raw = raw[[c for c in raw.columns if not any(d in str(c).lower() for d in drop)]]
redact = privacy.get("redact_emails", True)
rows = []
for _, r in raw.iterrows():
row = {}
for k, v in r.items():
c = cell(v, redact)
if c is not None:
row[str(k)] = c
rows.append(row)
out = {"source": spec["label"], "exported": ctx.get("changed"),
# every header, even one blank in every row, so the coding rules see every question
"headers": [str(c) for c in raw.columns], "rows": rows}
if t.get("extra"):
out["extra"] = extra_results(t["extra"])
return out
def describe(old, new):
"""One report line (plus details) comparing the previous public file with the new one."""
if old is None:
return [f"first export: {len(new['rows'])} rows"]
key = lambda r: repr(sorted(r.items())) # noqa: E731
o, n = {key(r) for r in old["rows"]}, {key(r) for r in new["rows"]}
lines = [f"{len(old['rows'])} → {len(new['rows'])} rows ({len(n - o)} new or edited, {len(o - n)} removed or edited)"]
new_q = [h for h in new["headers"] if h not in old["headers"]]
gone_q = [h for h in old["headers"] if h not in new["headers"]]
if new_q:
lines.append(f" - New questions (add them to `core/spec/form.yaml`): {', '.join(new_q)}")
if gone_q:
lines.append(f" - Questions no longer in the sheet: {', '.join(gone_q)}")
return lines
+44
View File
@@ -0,0 +1,44 @@
"""Validate: a table is checked against data/dictionary.yaml before it is loaded. A failure stops the load."""
import re
CHECKS = {
"integer": lambda v: isinstance(v, int) and not isinstance(v, bool) or bool(re.fullmatch(r"-?\d+", str(v))),
"boolean": lambda v: isinstance(v, bool) or v in ("True", "False"),
"date": lambda v: bool(re.fullmatch(r"\d{4}-\d{2}-\d{2}", str(v))),
"text": lambda v: isinstance(v, str),
}
class Invalid(Exception):
pass
def problems(rows, dictionary, header=None):
"""Every way the rows break the dictionary, as readable lines (empty when the table is valid)."""
cols = dictionary["columns"]
out = []
if header is not None and list(header) != list(cols):
out.append(f"columns differ from the dictionary: {list(header)} vs {list(cols)}")
ids = [r.get("run_id") for r in rows]
if len(set(ids)) != len(ids):
out.append("run_id is not unique")
for name, col in cols.items():
vals = [r.get(name) for r in rows]
present = [v for v in vals if v is not None and v != ""]
bad_type = sorted({str(v) for v in present if not CHECKS[col["type"]](v)})
if bad_type:
out.append(f"{name}: not {col['type']}: {bad_type[:5]}")
if "values" in col:
allowed = {str(v) for v in col["values"]}
bad = sorted({str(v) for v in present if str(v) not in allowed})
if bad:
out.append(f"{name}: values not in the dictionary: {bad[:10]}")
if col.get("required") and len(present) != len(vals):
out.append(f"{name}: required, but {len(vals) - len(present)} rows are empty")
return out
def check(rows, dictionary, what="table"):
errs = problems(rows, dictionary)
if errs:
raise Invalid(f"{what} does not match data/dictionary.yaml:\n " + "\n ".join(errs))
+19
View File
@@ -0,0 +1,19 @@
# Dragons from dragonkind.com result pages that riders linked in the r/fourthwing megathreads, read by hand.
# Each is one run in runs_clean.csv (source "reddit thread": bonded, colour and tail known, route not recorded) and
# appears under "extra" in data/public/register.json. The reddit_thread source lists result links found in the
# threads that are not here yet; add them after reading the result page. No usernames are kept.
version: 1
read: "2026-10-19"
results:
- { id: THRESH-VFRQVM5K3B0CP, name: Thiduach, colour: Blue, tail: Swordtail, sex: Female, age: 51, lineage: Gormfaileas }
- { id: THRESH-3M4P9MNFQGBS8, name: Caenuis, colour: Blue, tail: Swordtail, sex: Female, age: 38, lineage: Gormfaileas }
- { id: THRESH-5JQDJ21G1BYKR, name: Oavuagh, colour: Green, tail: Morningstartail, sex: Female, age: 43, lineage: Uaineloidsig }
- { id: THRESH-5KRAAVFB3D1MG, name: Geagios, colour: Blue, tail: Clubtail, sex: Male, age: 99, lineage: Gormfaileas }
- { id: THRESH-B5HSM00J4A2Z4, name: Fiedheil, colour: Black, tail: Clubtail, sex: Male, age: 32, lineage: Moerlaighen }
- { id: THRESH-BMPM2GAPK58JT, name: Teirfua, colour: Green, tail: Morningstartail, sex: Female, age: 68, lineage: Eifyrielle }
- { id: THRESH-MCQ8D6GAGF4K8, name: Caollo, colour: Blue, tail: Morningstartail, sex: Female, age: 93, lineage: Nyghmuiron }
- { id: THRESH-Q0XDBFMNBEB86, name: Aenminn, colour: Red, tail: Swordtail, sex: Male, age: 59, lineage: Berradhyr }
- { id: THRESH-W99DB29MG16QA, name: Meinso, colour: Green, tail: Clubtail, sex: Female, age: 63, lineage: Eifyrielle }
- { id: THRESH-XCJCY7HW7QSSP, name: Einmial, colour: Blue, tail: Clubtail, sex: Male, age: 58, lineage: Gormfaileas }
- { id: THRESH-XR6G68VPGT48M, name: Recuagh, colour: Brown, tail: Morningstartail, sex: Female, age: 55, lineage: Vormalgh }
- { id: THRESH-YQC97TK34214E, name: Dannidh, colour: Orange, tail: Clubtail, sex: Male, age: 61, lineage: Cariaslog }
+95
View File
@@ -0,0 +1,95 @@
# Data collection as extract -> transform -> load, one block per source. collection/run.py reads this file.
#
# extract fetches the source as it is now. The raw file goes to data/raw/<source>/current.<ext> (git-ignored,
# never published); the version it replaces is kept as previous.<ext>, and the daily workflow keeps
# that previous copy in an encrypted, private cache. Nothing older is kept.
# transform turns the raw file into the public source file: a pure function of the raw file (no network, no
# clock), with the source's privacy rules applied. Named transforms live in collection/etl/transform/.
# load writes the public source file (byte-stable: same input, same bytes) and reports what changed.
#
# Then `build` codes every public source file into one run per row (runs: the coder) and writes
# data/public/runs_clean.csv: every run from every source, with a `source` column. Each table is checked against
# data/dictionary.yaml before it is written. Every input to `build` is committed, so CI can rebuild it exactly.
version: 1
raw_dir: data/raw
manifest: data/manifest.json # for each source: the sha256 of the current raw file and when it last changed
runs:
path: data/public/runs_clean.csv
# sources in this order; within a source, the order the coder returns
order: [reddit_spreadsheet, reddit_thread, reported, bot, reddit_pdf]
sources:
reddit_spreadsheet:
label: Threshing Routes form and spreadsheet (u/ClumsyBadger, linked from the r/fourthwing megathreads)
run_source: reddit spreadsheet
links:
sheet: https://docs.google.com/spreadsheets/d/1gnw1AdRg1XT4JsOfRM6QTA0jSaS3n9ZF-rPWnYewzv0
form: https://forms.gle/DRpj9tG8gb5E4Hcu7 # the Threshing Routes Google Form the megathreads link to
extract: { kind: http, url: "https://docs.google.com/spreadsheets/d/1gnw1AdRg1XT4JsOfRM6QTA0jSaS3n9ZF-rPWnYewzv0/export?format=xlsx", ext: xlsx }
transform: { name: sheet, sheet_contains: form responses }
privacy: { redact_emails: true }
load: data/public/form_responses.json
runs: spreadsheet # core/spec/form.yaml + core/atlas/coding.py
register:
label: Unofficial Dragon Register (which dragon each rider bonded)
links: { sheet: https://docs.google.com/spreadsheets/d/1KMiE9sec0l597Pzue1OhGYf07NF4howtQ_lPeqx7jXQ }
extract: { kind: http, url: "https://docs.google.com/spreadsheets/d/1KMiE9sec0l597Pzue1OhGYf07NF4howtQ_lPeqx7jXQ/export?format=xlsx", ext: xlsx }
transform: { name: sheet, sheet_contains: form responses, extra: collection/manual/reddit_results.yaml }
privacy: { redact_emails: true, drop_columns_matching: [photo, cadet name] } # no rider names, no photos
load: data/public/register.json
runs: null # bonded dragons without the route that led there
reddit_pdf:
label: Community route PDF (u/ClumsyBadger)
run_source: reddit pdf
links: { view: https://drive.google.com/file/d/17o72ehHsSPW4UdsKF-sXTxMLEuinWeEg/view }
extract: { kind: http, url: "https://drive.google.com/uc?export=download&id=17o72ehHsSPW4UdsKF-sXTxMLEuinWeEg", ext: pdf }
transform: { name: pdf_fingerprint }
privacy: { redistribute: false } # only hashes of the file, its pages and its lines are kept
load: data/derived/pdf_fingerprint.json
runs: null # a flowchart of the routes, not a log of runs (see collection/README.md)
reddit_thread:
label: Runs posted in the r/fourthwing Dragonkind megathreads
run_source: reddit thread
links:
part3: https://www.reddit.com/r/fourthwing/comments/1wvwfp9/
part4: https://www.reddit.com/r/fourthwing/comments/1wz5cnj/
# the official Reddit API (app-only OAuth); skipped with a note when the secrets are not set
extract: { kind: reddit, threads: [1wvwfp9, 1wz5cnj], secrets: [REDDIT_CLIENT_ID, REDDIT_CLIENT_SECRET], ext: json }
# lists dragonkind.com result links that are not in the manual file yet; usernames are never kept
transform: { name: reddit_results, manual: collection/manual/reddit_results.yaml }
load: null # the public source file is the hand-checked collection/manual/reddit_results.yaml
runs: reddit_results
reported:
label: Runs reported on the Atlas ("Report a run", an issue form on the Atlas's repository)
run_source: reported
# the repository's host is forge.yaml (Gitea or GitHub); its "new issue" link is made from it
extract: { kind: forge_issues, label: run report, ext: json }
# usernames are dropped; issues closed as "not planned" (GitHub) or labelled invalid/duplicate are left out
transform: { name: reports, form: collection/specs/report_form.yaml, reject_labels: [invalid, duplicate] }
load: data/public/reports.json
runs: reports
bot:
label: DragonKind bot runs (Ken's private bot, imported locally)
run_source: bot
# the bot's repo is private: this step runs only on a machine with a copy of it
# data/accounts/<account>/ and logs/accounts/<account>/: one folder per game account (account names are
# replaced by salted hashes); the top-level files are the bot's original single account
extract:
kind: local_dir
env: DRAGONKIND_BOT_DIR
files: [data/knowledge.json, data/runs.jsonl, logs/encounters.jsonl, data/accounts/*/runs.jsonl, logs/accounts/*/encounters.jsonl]
transform: { name: bot, spec: collection/specs/bot.yaml }
privacy:
account_salt_env: DK_ACCOUNT_SALT # account names are hashed with this salt (or, if unset, one kept in
# data/raw/bot/account-salt.txt); never committed
refuse_fields: [prose, proseNorm, proseExcerpt, email, password, accountId, accountName]
max_string: 200 # anything longer looks like game prose
load: data/bot # scenes.json (merged) + trajectories-<date>.jsonl
runs: bot
+153
View File
@@ -0,0 +1,153 @@
"""Data collection: extract -> transform -> load for every source, then build the combined runs.
python -m collection update [--source NAME ...] [--file NAME=PATH ...] [--report FILE]
For each source (all by default): extract it (or take a local file), and when the raw file changed,
transform it and load the public source file. Then build. Exit code 0 even when a source could not be
reached: the report says what happened (and the daily workflow opens an issue).
python -m collection refresh [--bot PATH ...]
Locally, what the daily workflow does: update every source (plus bot folders or zips someone sent), then
rebuild the graph, the route model, the statistics and the build.
python -m collection export-bot-kit
exports/atlas-for-bot-<date>-<policy id>.zip: policy.json, solver.js and graph.js for the bot.
python -m collection build [--check]
Code every public source file into data/public/runs_clean.csv (validated against data/dictionary.yaml),
and write the files generated from the specs: the "Report a run" issue form, the bot crosswalk in
core/graph.js, and data/croissant.json. With --check nothing is written; exit 1
if any of them is out of date (CI runs this).
Sources and their rules: collection/pipeline.yaml. What each column means: data/dictionary.yaml.
"""
import argparse
import os
import sys
from datetime import datetime, timezone
from .etl import extract as E
from .etl import load as L
from .etl import codegen, metadata, report_form, runs, validate
from .etl.common import Report, path, pipeline
from .etl.transform import TRANSFORMS
def update_source(name, spec, manifest, report, local_file=None, env=None):
env = os.environ if env is None else env
try:
raw, changed = E.extract(name, spec, manifest, env, local_file)
except E.Skip as e:
report.add(f"- **{spec['label']}:** skipped ({e}).")
return False
except Exception as e: # one broken source must not block the others
report.failed.append(name)
report.add(f"- **{spec['label']}:** could not extract ({type(e).__name__}: {e}).")
return False
if not changed:
report.add(f"- **{spec['label']}:** no change.")
return False
mod = TRANSFORMS[spec["transform"]["name"]]
ctx = {"changed": manifest[name]["changed"], "env": env}
new = mod.transform(raw, spec, ctx)
target = spec.get("load")
if name == "bot":
old = {"scenes": L.read_json(f"{target}/scenes.json") or {}}
lines = mod.describe(old, new)
wrote = L.json_file(f"{target}/scenes.json", mod.merge_scenes(old["scenes"], new["scenes"]), compact=False)
# one file per import (date + raw checksum), so two imports on the same day (yours, Ken's) never overwrite
tag = f"{ctx['changed']}-{manifest[name]['sha256'][:8]}"
wrote |= L.jsonl_file(f"{target}/trajectories-{tag}.jsonl", new["trajectories"])
elif target:
old = L.read_json(target)
lines = mod.describe(old, new)
wrote = L.json_file(target, new, compact=not target.startswith("data/derived"))
else: # nothing to load: the report is the output (e.g. Reddit result links to add by hand)
lines, wrote = mod.describe(None, new), False
report.add(f"- **{spec['label']}:** {lines[0]}")
for line in lines[1:]:
report.add(line)
return wrote
def build(check=False, report=None):
"""Combined runs, issue form and metadata. Returns the list of files that changed (or would change)."""
pipe = pipeline()
rows = runs.build_runs(pipe)
validate.check(rows, runs.DICT, "runs_clean.csv")
out = []
if L.csv_file(pipe["runs"]["path"], rows, runs.COLUMNS, check):
out.append(pipe["runs"]["path"])
if L.write_bytes(report_form.TEMPLATE, report_form.render().encode("utf-8"), check):
out.append(report_form.TEMPLATE)
if L.write_bytes(codegen.GRAPH_JS, codegen.graph_js().encode("utf-8"), check):
out.append(codegen.GRAPH_JS)
if L.json_file(codegen.LINKS, codegen.links(), check, compact=False):
out.append(codegen.LINKS)
# the metadata hashes the files above, so it is built from what is (or would be) on disk
if not check or not out:
if L.write_bytes(metadata.OUT, metadata.render(metadata.build()).encode("utf-8"), check):
out.append(metadata.OUT)
counts = {}
for r in rows:
counts[r["source"]] = counts.get(r["source"], 0) + 1
msg = f"runs_clean.csv: {len(rows)} runs ({', '.join(f'{k} {v}' for k, v in counts.items())})"
(report.add if report else print)(f"- **Combined runs:** {msg}")
return out
def main(argv=None):
ap = argparse.ArgumentParser(prog="python -m collection", description=__doc__,
formatter_class=argparse.RawDescriptionHelpFormatter)
sub = ap.add_subparsers(dest="cmd", required=True)
up = sub.add_parser("update")
up.add_argument("--source", action="append", help="only these sources (repeatable)")
up.add_argument("--file", action="append", default=[], help="NAME=PATH: use a local file instead of extracting")
up.add_argument("--report")
b = sub.add_parser("build")
b.add_argument("--check", action="store_true")
fg = sub.add_parser("forge", help="pull requests, issues and labels on the repository's host (forge.yaml)")
fg.add_argument("args", nargs=argparse.REMAINDER)
k = sub.add_parser("export-bot-kit", help="zip policy.json, solver.js and graph.js for the bot")
k.add_argument("--out", default="exports")
r = sub.add_parser("refresh", help="update every source, then rebuild everything (the daily workflow, locally)")
r.add_argument("--bot", action="append", default=[], help="a bot folder or a .zip of its data (repeatable)")
a = ap.parse_args(argv)
if a.cmd == "forge":
from .etl import forge
return forge.main(a.args)
if a.cmd == "export-bot-kit":
from .etl.handoff import export_bot_kit
print(f"wrote {export_bot_kit(a.out)}")
return 0
if a.cmd == "refresh":
from .etl.handoff import refresh
return refresh(main, a.bot)
if a.cmd == "build":
changed = build(check=a.check)
if a.check and changed:
print("out of date (run `python -m collection build`): " + ", ".join(changed), file=sys.stderr)
return 1
return 0
pipe = pipeline()
manifest = L.read_json(pipe["manifest"]) or {}
files = dict(f.split("=", 1) for f in a.file)
report = Report()
for name, spec in pipe["sources"].items():
if a.source and name not in a.source:
continue
report.changed |= update_source(name, spec, manifest, report, files.get(name))
L.json_file(pipe["manifest"], dict(sorted(manifest.items())), compact=False)
try:
report.changed |= bool(build(report=report))
except validate.Invalid as e: # new answers the coding rules do not know yet: report them, load nothing
report.failed.append("build")
report.add(f"- **Combined runs not rebuilt:** {e}")
report.add(" - Add the new answers to `core/spec/form.yaml` (or `data/dictionary.yaml`), then run `python -m collection build`.")
text = report.text(f"Source check {datetime.now(timezone.utc).strftime('%Y-%m-%d %H:%M UTC')}")
if a.report:
with open(a.report, "w", encoding="utf-8") as f:
f.write(text)
if os.environ.get("GITHUB_OUTPUT"):
with open(os.environ["GITHUB_OUTPUT"], "a") as f:
f.write(f"changed={'true' if report.changed else 'false'}\nfailed={','.join(report.failed)}\n")
return 0
+94
View File
@@ -0,0 +1,94 @@
# The DragonKind bot: how its screens and choices become public data and runs. collection/etl/transform/bot.py.
#
# The bot's raw data (game prose, account ids) stays on the machine that runs it. What is published:
# scene fingerprints, the short labels below (our own paraphrases, not game prose), choice text and outcomes.
version: 1
# Must match normalize() in the bot's src/strategy.js, so fingerprints line up (applied in this order).
normalize:
- ["[\u2018\u2019\u201b`']", "'"]
- ["[\u201c\u201d\"]", "\""]
- ["[\u2013\u2014-]", " "]
- ["\u2026", " "]
- ["[^a-z0-9'\\s]", " "]
- ["\\s+", " "]
# Events in the bot's log that record a choice it acted on
choice_events: [DECISION, MANUAL_DECISION, MANUAL_EDGE_PICK]
# runs.jsonl and the log are matched when the same attempt starts within this many hours
match_hours: 6
# Short public labels, by scene fingerprint. A scene without one is labelled "<stage> · <tint>" and listed by the
# importer so a label can be added here.
labels:
"db7786392626": "Start: choose company"
"a68f681076c6": "Valley edge: choose direction"
"bc4ee4754b9c": "First sighting: Red (forest centre)"
"abe3011378ac": "First sighting: Brown (forest centre)"
"84780dab01e3": "Survived the first sighting"
"d25f2759ace0": "Deeper in the forest: a scream"
"f72199f24b91": "Clearing: squadmate vs two bullies"
"b209bacacec3": "Bully fight: first move"
"fbe0f0bea700": "Bully fight: smaller cadet has a dagger"
"a2368b0dc212": "Blocked the bigger cadet: bullies’ fate"
"f4b4944d3f3b": "Beat the smaller cadet: bullies’ fate"
"0cfd06cf8939": "After the fight: choose a direction"
"0a561d53ad19": "An hour later: valley or tree"
"96b68612eaf4": "Top of the tree (shadow check)"
"10bc7353b8eb": "Descended quickly: a Red below"
"c62f1f1a2b3a": "Let the Red pass: two Greens in the clearing"
"07e24681e3b3": "Descended slowly: two Greens in the clearing"
# Crosswalk: a bot choice (option text, normalised as in core/graph.js norm()) -> a column of the coded runs.
# First match wins; a column keeps its first value. Unmatched choices are listed, never guessed.
# Two keys are not columns: scream_investigate (the scream step on its own) and red (the Red below the tree).
crosswalk:
- ["^enter the valley alone", company, "Alone"]
- ["^enter the valley with one of your squadmates", company, "1 Squadmate"]
- ["^enter the valley with two of your squadmates", company, "2 Squadmates"]
- ["^leave your squadmates?$", left_squadmates, true]
- ["^head east toward the roar", direction, "East"]
- ["^head west toward the scent", direction, "West"]
- ["^head toward the center of the forest", direction, "Center"]
# with squadmates, the direction is agreed with them
- ["^go east with your squad|^convince them to head east", direction, "East"]
- ["^go west with your squad|^convince them to head west", direction, "West"]
- ["^keep walking the cadets are just as dangerous", scream, "Ignore the scream"]
- ["^run and hope", sighting_action, "Retreat / run"]
- ["hold still|hold your ground", sighting_action, "Hold still"]
- ["lower your eyes in respect|lower your eyes and turn to face it", sighting_action, "Respect / face it"]
- ["meeting its gaze", sighting_action, "Meet its gaze"]
- ["^hide behind a tree|^duck behind a boulder", sighting_action, "Hide"]
- ["^approach with confidence|^approach from the left", sighting_action, "Approach"]
- ["^investigate the scream", scream_investigate, true]
- ["^help your squadmate", scream, "Investigate & help"]
- ["^play it safe and leave them", scream, "Investigate & leave"]
- ["^pause to assess the situation", combat_first, "Assess the situation"]
- ["^charge the other cadet", combat_first, "Even the numbers (smaller cadet)"]
- ["^unsheathe your weapon and charge between", combat_first, "Put yourself in the middle (bigger cadet)"]
- ["^engage the smaller cadet", combat_second, "Engage the smaller cadet"]
- ["^daggers or not", combat_second, "Daggers or not (protect squadmate)"]
- ["^end the lives of the bullies", resolution, "Killed the bullies yourself"]
- ["^allow your squadmate to exact", resolution, "Squadmate's revenge"]
- ["^leave the bullies alive", resolution, "Left bullies to the dragons"]
- ["tourniquet", resolution, "Tourniquet"]
# the wounded cadet's other two choices (the bot has not logged this screen yet, so these are kept loose)
- ["leave (them|him|her) to die|^keep going clearly they've been found lacking", resolution, "Left injured cadet"]
- ["take (their|his|her|the cadet's) weapons?", resolution, "Took their weapons"]
- ["^walk toward the east", post_path, "East"]
- ["^walk toward the west", post_path, "West"]
- ["^walk farther into the forest", post_path, "Forest"]
- ["^continue toward the center of the valley", hour, "Valley"]
- ["^find the tallest tree", hour, "Tree"]
# the Red in the valley centre
- ["^there's no way this is your dragon", branch, "Passed the Red: meadow"]
- ["^this is your dragon and it's time to start bonding", branch, "Valley Red"]
- ["^descend quickly", branch, "Descend quickly: Red"]
- ["^climb down slowly to pursue the green", branch, "Descend slowly: two Greens"]
- ["^reds are too hot tempered", red, "Let it pass (two Greens)"]
- ["^jump (now|in a few seconds)", red, "Jump onto the Red"]
# Route choices (before the hour) that no column of the coded runs has a value for; they are coded as unknown.
# tests/collection/test_collection.py fails on any other unmapped route choice.
not_coded:
- "^stare at the ground and drop the weapon" # a first-sighting reaction with no form category
+119
View File
@@ -0,0 +1,119 @@
# "Report a run": the questions of the issue form (on the Atlas's repository: forge.yaml), and how each answer becomes a column of runs_clean.csv.
#
# collection/etl/report_form.py writes .github/ISSUE_TEMPLATE/report-a-run.yml from this file (a test checks it is
# up to date), and collection/etl/runs.py codes every report with it. Each option is "label shown: column value";
# an option with value null (or no answer) means "not known". Values must be listed in data/dictionary.yaml.
version: 1
name: Report a run
description: Log one threshing run for the Threshing Atlas. Reports are public and become rows of runs_clean.csv.
title: "Run report"
label: run report
intro: |
Thanks for reporting a run! Answer what you remember; leave anything you're unsure of on "Not sure".
Every answer here is visible to everyone who can see this repository (it is an issue) and goes into the Atlas's
open data as source "reported".
Please don't include your DragonKind account name or anything personal.
You can also use the community [Threshing Routes form](https://forms.gle/DRpj9tG8gb5E4Hcu7) linked from the r/fourthwing megathread; please report each run only once.
fields:
- id: goal
label: Which dragon were you trying to bond?
column: goal
options: { Red: Red, Green: Green, Orange: Orange, Brown: Brown, Blue: Blue, Black: Black, "Any, just for fun": Any (for fun) }
- id: attempt
label: Which attempt was this for your account? (a number; 1 = your first)
column: attempt
type: integer
- id: company
label: Who entered the valley with you?
column: company
required: true
options: { Alone: Alone, One squadmate: 1 Squadmate, Two squadmates: 2 Squadmates }
- id: left_squadmates
label: If you went with squadmates, did you leave them?
column: left_squadmates
options: { "Yes, I left them": true, "No, we stayed together": false, "I went alone": null }
- id: direction
label: Which way did you go first?
column: direction
required: true
options: { East (toward the roar): East, West (toward the scent): West, Toward the forest centre: Center }
- id: first_sighting
label: Which dragon found you first?
column: first_sighting
options: { Red: Red, Brown: Brown, Green: Green, Orange: Orange }
- id: sighting_action
label: What did you do when it found you?
column: sighting_action
options:
Hold still: Hold still
Lower your eyes in respect / turn to face it: Respect / face it
Run: Retreat / run
Hide: Hide
Draw a weapon: Weapon
Meet its gaze: Meet its gaze
Protect your squadmate: Protect squadmate
- id: scream
label: The scream
column: scream
required: true
options:
I died at the first dragon: DIED at first sighting
Investigated, and helped my squadmate: Investigate & help
Investigated, and walked away: Investigate & leave
Kept walking (ignored it): Ignore the scream
- id: combat_first
label: "If you helped: your first move in the fight"
column: combat_first
options:
Pause to assess: Assess the situation
Charge the smaller cadet: Even the numbers (smaller cadet)
Charge between the bigger cadet and your squadmate: Put yourself in the middle (bigger cadet)
- id: combat_second
label: "If you paused to assess: the smaller cadet's dagger"
column: combat_second
options: { Engage the smaller cadet: Engage the smaller cadet, Charge the bigger cadet anyway: Daggers or not (protect squadmate) }
- id: resolution
label: How did the cadet encounter end?
column: resolution
options:
I died in the fight: DIED in combat
"Bullies: killed them myself": Killed the bullies yourself
"Bullies: my squadmate's revenge": Squadmate's revenge
"Bullies: left them to the dragons": Left bullies to the dragons
"Wounded cadet: tourniquet": Tourniquet
"Wounded cadet: left them": Left injured cadet
"Wounded cadet: took their weapons": Took their weapons
"I walked away from the clearing": Left them to it
- id: post_path
label: "After the fight: which way did you walk?"
column: post_path
options: { Deeper into the forest: Forest, West: West, East: East, There was no fork: (no fork) }
- id: hour
label: After an hour's walk
column: hour
options: { Climbed the tallest tree: Tree, Went to the valley centre: Valley, I died before the hour: DIED before the hour }
- id: branch
label: Which bonding encounter did you reach?
column: branch
options:
"Tree: the shadow (Blue or Black)": Shadow (rare)
"Tree: climbed down quickly, jumped on the Red": "Descend quickly: Red"
"Tree: climbed down quickly, let the Red pass": "Descend quickly: let the Red pass"
"Tree: climbed down slowly to the two Greens": "Descend slowly: two Greens"
"Valley: faced the Red": Valley Red
"Valley: passed the Red, the meadow": "Passed the Red: meadow"
- id: outcome
label: How did the run end?
column: outcome
required: true
options: { Bonded: Bonded, Incinerated at a bonding encounter: Incinerated, Died before the hour: Died before the hour }
- id: outcome_color
label: Which dragon bonded you (or incinerated you)?
column: outcome_color
options: { Red: Red, Green: Green, Orange: Orange, Brown: Brown, Blue: Blue, Black: Black }
- id: tail
label: "If you bonded: the dragon's tail"
column: tail
options: { Clubtail: Clubtail, Daggertail: Daggertail, Morningstartail: Morningstartail, Scorpiontail: Scorpiontail, Swordtail: Swordtail }
+21
View File
@@ -0,0 +1,21 @@
# core
The shared model. Every other part uses it, so run `npm test` after any change.
The rules and the game are **declarative** files in `spec/`; the Python package `atlas/` reads them. JavaScript is
used only where it has to run in a browser or in Ken's bot.
| File | What it does |
|---|---|
| `spec/form.yaml` | Every question of the community form (how to find it in an export) and every answer (what it is coded as), the answers that count as missing, email redaction, when "left your squadmates" was first asked. |
| `spec/game.yaml` | The game: every decision and its options in order, every roll and what its odds may depend on, every bonding encounter, the flow of a run from the entrance to the dragons, how form answers map onto it, and the text the bot sees for each option. |
| `atlas/coding.py` | Codes every form row into a run (`python -m atlas.coding`). Rule tests: `tests/core/test_coding.py`. |
| `atlas/model.py`, `atlas/solver.py` | The route model: what each coded run reveals about each step, the count tables and shrinkage, the posterior draws, and one interpreter of `game.yaml` used to solve, evaluate and export the best routes (`planner/build_policy.py`). Tests: `tests/core/test_solver.py`, `test_game.py`. |
| `solver.js` | **JavaScript, for the site and the bot.** The route advisor: reads the game and the count tables from `data/policy.json` and re-solves from any point in a run. `tests/core/advisor.test.js` checks it gives exactly the Python model's values and choices. |
| `graph.js` | **JavaScript, for the bot.** Turns the bot's on-screen choices into form answers, and builds the route graph (`analysis/network/build-graph.js`). Moves to Python with the collection review. |
The site and Ken's bot load the published copies (`https://ekcschiano.github.io/threshing-atlas/solver.js`,
`graph.js`, `data/policy.json`), so those names on the site must not change.
To support a new form answer, add it to `spec/form.yaml`. To change a rule, edit `atlas/coding.py` and add a test case.
To add a choice to the game, add it to `spec/game.yaml` (and, if the form records it, to `atlas/model.py`).
+8
View File
@@ -0,0 +1,8 @@
"""threshing-atlas core: the shared model every part of the project uses.
The rules and the game live in declarative files under core/spec/ (form.yaml, game.yaml, crosswalk.yaml);
the modules here read them:
atlas.spec load the spec files
atlas.coding community form rows -> coded runs
"""
+109
View File
@@ -0,0 +1,109 @@
"""Reporting bias: some sources report a rare sighting more readily than a miss.
The bot logs every run, and bulk-pasted logs record every run of the players who kept them ("complete" groups).
Form submissions and reports are chosen by the rider, and a run with a shadow or a meadow Blue is more likely to be
written up than one without. For each rare roll and each selective group, the bias is the factor by which the
group's odds of the rare outcome exceed the complete groups' odds:
rho = odds(rare | group) / odds(rare | complete groups)
Each rare outcome a group reports then counts 1/rho in the route model's tables. That keeps the group's pattern
across routes and moves its overall level to what complete logging shows. The assumption: the bias is the same on
every route (planner/policy.yaml says which groups, rolls and settings are used).
"""
import random
from . import model
def group_of(r, groups, rare_goals):
"""The first group in planner/policy.yaml whose condition the run meets."""
for g in groups:
w = g.get("when", {})
if "source" in w and r.get("source") != w["source"]:
continue
if "entry_not" in w and r.get("entry") in (None, w["entry_not"]):
continue
if w.get("goal") == "rare" and r.get("goal") not in rare_goals:
continue
return g["name"]
return None
def _odds(y, n):
p = (y + 0.5) / (n + 1) # Jeffreys
return p / (1 - p)
def estimate(runs, prepared, cfg, rare_goals, seed=20261109, sims=4000):
"""{group: {roll: {rare, n, rho, lo, hi, used}}} and the group of every run."""
groups = cfg["groups"]
names = [group_of(r, groups, rare_goals) for r in runs]
complete = {g["name"] for g in groups if g.get("complete")}
rolls = cfg["rolls"]
tally = {}
for name, v in zip(names, prepared):
for node, rare in rolls.items():
y = model.OBSERVE[node](v)
if y is None:
continue
t = tally.setdefault(name, {}).setdefault(node, [0, 0])
t[0] += y == rare
t[1] += 1
ref = {node: [sum(tally.get(g, {}).get(node, [0, 0])[i] for g in complete) for i in (0, 1)] for node in rolls}
rnd = random.Random(seed)
out = {}
for g in groups:
name = g["name"]
out[name] = {}
for node in rolls:
y, n = tally.get(name, {}).get(node, [0, 0])
ry, rn = ref[node]
e = {"rare": y, "n": n, "completeRare": ry, "completeN": rn}
if g.get("complete"):
e.update(rho=1.0, lo=1.0, hi=1.0, used="complete: counted as reported")
elif ry < cfg.get("min_complete_rare", 5):
# complete logging has (almost) never seen it: the bias cannot be estimated, so this roll is learned
# from complete logging only (its range then shows how little is known)
e.update(rho=None, lo=None, hi=None, exclude=True,
used=f"left out: complete logs have only {ry} rare outcomes, too few to estimate the bias")
elif n < cfg.get("min_runs", 30) or rn < cfg.get("min_runs", 30):
e.update(rho=None, used=f"too few runs: uses {g.get('same_as') or 'no correction'}")
else:
rho = _odds(y, n) / _odds(ry, rn)
sim = [] # a 90% range for rho from the two rates' posteriors
for _ in range(sims):
a = rnd.betavariate(y + 0.5, n - y + 0.5)
b = rnd.betavariate(ry + 0.5, rn - ry + 0.5)
sim.append((a / (1 - a)) / (b / (1 - b)))
sim.sort()
e.update(rho=rho, lo=sim[int(0.05 * sims)], hi=sim[int(0.95 * sims) - 1], used="estimated")
out[name][node] = e
# groups with too little data borrow another group's estimate
for g in groups:
for node in rolls:
e = out[g["name"]][node]
if e.get("rho") is None and not e.get("exclude"):
src = out.get(g.get("same_as") or "", {}).get(node, {})
e["rho"] = src.get("rho") or 1.0
e["lo"], e["hi"] = src.get("lo", e["rho"]), src.get("hi", e["rho"])
return out, names
def weights(names, prepared, est, rolls):
"""Per run: {roll: weight of the outcome it observed}: 1/rho for a rare outcome from a biased group, 0 for any
outcome of a roll its group is left out of. Only where it differs from 1."""
out = []
for name, v in zip(names, prepared):
w = {}
for node, rare in rolls.items():
e = (est.get(name) or {}).get(node, {})
y = model.OBSERVE[node](v)
if y is None:
continue
if e.get("exclude"):
w[node] = 0.0
elif y == rare and (e.get("rho") or 1.0) != 1.0:
w[node] = 1.0 / e["rho"]
out.append(w)
return out
+1 -5
View File
@@ -150,10 +150,6 @@ def code_row(r, C):
company = company_raw[: -len(suffix)] if left_squad else company_raw
if not left_squad and company in ("1 Squadmate", "2 Squadmates") and not (date and date >= F["left_squadmates_asked_from"]):
left_squad = None # the form did not offer "left them" yet: unknown, not "stayed together"
alias = F.get("first_sighting_alias") or {}
if first in alias:
flags.append(f"first sighting answered as {first!r}")
first = alias[first]
pools = F["sighting_pool"]
pool = list(pools.get(company, {}).get(direction, [])) + (list(pools["Alone"].get(direction, [])) if left_squad else [])
if first and first != "Unsure" and pool and first not in pool:
@@ -254,7 +250,7 @@ def code_row(r, C):
goal = g("goal") or (A["goal_v2"].get(goal_raw, goal_raw) if goal_raw and goal_raw != "Unknown" else None) or "(not asked/blank)"
return {
"source": source, "date": date, "wing": wing, "section": section,
"squad": A["squad_any_case"].get((g("squad") or "").strip().lower(), g("squad") or "Unknown"), "attempt": attempt,
"squad": g("squad") or "Unknown", "attempt": attempt,
# "I've lost count" means many attempts, so it is a later attempt, not missing
"attempt_group": "First attempt" if attempt == 1 else ("Later attempt" if (attempt and attempt > 1) or "lost count" in (g("attempt") or "").lower() else "Unknown"),
"goal": goal, "company": company, "left_squadmates": left_squad,
+439
View File
@@ -0,0 +1,439 @@
"""From coded runs to the route model's numbers: what each run says about each step of the game (prepare_run),
how often each roll came out in each context (count_tables), how strongly to shrink toward shorter contexts
(fit_alpha), the probability source the solver uses (Params), and which options have enough data (support_from).
The game itself (steps, options, chance contexts) is core/spec/game.yaml.
The random numbers (xorshift32, Marsaglia-Tsang gamma) are the same as the route model has always used, so the
posterior draws are reproducible from the seed.
"""
import math
import numpy as np
from . import spec
G = spec.game()
DECISIONS = {k: v["options"] for k, v in G["decisions"].items()}
CHANCE = G["chance"]
COLOURS = G["colours"]
FROM_FORM = G["from_form"]
HELP = set(FROM_FORM["helped"])
IGNORE = set(FROM_FORM["ignored"])
FIGHT_OF = FROM_FORM["fight"]
DAGGER_OF = FROM_FORM["dagger"]
RARE_GOALS = FROM_FORM["rare_goals"]
NO_DAGGER = "(no dagger choice)"
ALONE = "(alone)"
ALPHA = 20
ALPHA_GRID = [1, 2, 5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 20000, 100000]
ENC_CATS = G["encounter_outcomes"]
def enc_colour(ctx):
return "Green" if ctx == "tree-Greens" else ctx.split("-")[1]
def dagger_after(fight, dagger):
"""The fight moves in a history: a run that charged straight in never faces the dagger."""
return None if fight is None else (dagger or None) if fight == "Pause to assess" else NO_DAGGER
# ---------------------------------------------------------------- 1. coded run -> what it says about each step
def genuine_attempt(r, ctx):
"""Whether a run's bonding attempt counts for this encounter, given the rider's stated goal and Malek intent."""
c = enc_colour(ctx)
g = r.get("goal") or ""
matches = g == c or g.startswith("Any") or (g == "Blue or Black" and c in ("Blue", "Black")) or \
(g == "Red (tree)" and ctx == "tree-Red")
if matches:
return True
if r.get("malek_intent") == "No":
return True
if r.get("malek_intent") == "Yes":
return False
specific_other = (g in COLOURS and g != c) or g == "Blue or Black" or g == "Red (tree)"
return not specific_other
def prepare_run(r):
"""One coded run (atlas.coding) as the steps of the game it reveals."""
v = {"company": r["company"] if r["company"] in DECISIONS["company"] else None,
"direction": r["direction"] if r["direction"] in DECISIONS["direction"] else None,
"fs": r["first_sighting"] if r["first_sighting"] in ("Red", "Brown", "Green", "Orange") else None}
lf = r.get("left_squadmates")
known = lf is not None and not (isinstance(lf, float) and lf != lf) and lf != ""
v["left"] = ALONE if v["company"] == "Alone" else (("Leave them" if lf is True or str(lf).lower() == "true" else "Stay together") if v["company"] and known else None)
v["react"] = r["sighting_action"] if r.get("sighting_action") in DECISIONS["react"] else None
v["diedSight"] = r["scream"] == "DIED at first sighting"
if v["diedSight"]:
return v
if r["scream"] not in ("Investigate & help", "Ignore the scream", "Investigate & leave"):
v["sightUnknown"] = True # no answer after the first dragon: whether the rider survived it is not known
return v
res = r["resolution"]
# the choices at the scream, by their names in game.yaml (gates are written with these)
v["scream"] = "Keep walking" if r["scream"] == "Ignore the scream" else "Investigate the scream"
if r["scream"] in ("Investigate & help", "Investigate & leave"):
v["clearing"] = "Help your squadmate" if r["scream"] == "Investigate & help" else "Walk away"
if r["scream"] == "Investigate & help":
v["help"] = True
v["fight"] = FIGHT_OF.get(r.get("combat_first"))
v["dagger"] = dagger_after(v["fight"], DAGGER_OF.get(r.get("combat_second")))
v["diedCombat"] = res == "DIED in combat"
v["cadet"] = res if res in HELP else None
if v["diedCombat"]:
return v
v["post"] = r["post_path"] if r.get("post_path") in DECISIONS["post"] else None
elif r["scream"] == "Ignore the scream":
v["cadet"] = res if res in IGNORE else None
v["post"] = "(no fork)"
elif r["scream"] == "Investigate & leave":
v["cadet"] = "Left them to it"
v["post"] = "(no fork)"
else:
return v
v["survivedCadets"] = True
v["diedHour"] = r["hour"] == "DIED before the hour"
if v["diedHour"]:
return v
v["hour"] = r["hour"] if r.get("hour") in DECISIONS["hour"] else None
b = r.get("branch")
if v["hour"] == "Tree" and b:
v["shadow"] = b == "Shadow (rare)"
if v["shadow"]:
v["shadowColour"] = "Black" if r.get("enc_Black") else "Blue"
v["encCtx"] = "shadow-" + v["shadowColour"]
elif b == "Descend quickly: Red":
v["descend"], v["red"], v["encCtx"] = "Quickly (Red)", "Jump onto the Red", "tree-Red"
elif b == "Descend quickly: let the Red pass":
v["descend"], v["red"], v["encCtx"] = "Quickly (Red)", "Let it pass (two Greens)", "tree-Greens"
elif b == "Descend slowly: two Greens":
v["descend"], v["encCtx"] = "Slowly (two Greens)", "tree-Greens"
elif v["hour"] == "Valley" and b:
if b == "Valley Red":
v["valley"], v["encCtx"] = "Face the Red", "valley-Red"
elif b == "Passed the Red: meadow":
v["valley"] = "Pass the Red (meadow)"
# the meadow dragon: Blue if one appeared, otherwise the one the rider ended the run with
ended = lambda c: r.get("enc_" + c) and r.get("enc_" + c) != "Changed my mind" # noqa: E731
v["meadow"] = "Blue" if (r.get("enc_Blue") or r.get("rare_reported") == "Blue (valley)") else \
"Orange" if ended("Orange") else "Brown" if ended("Brown") else \
"Orange" if r.get("enc_Orange") else "Brown" if r.get("enc_Brown") else \
"Blue" if r.get("saw_blue_meadow") is True else \
r["outcome_color"] if r.get("saw_blue_meadow") is False and r.get("outcome_color") in ("Orange", "Brown") else None
if v["meadow"]:
v["encCtx"] = "meadow-" + v["meadow"]
if v.get("encCtx"):
v["encOutcome"] = r["outcome_color"] if (r["outcome"] == "Bonded" and r.get("outcome_color")) else \
"burn" if r["outcome"] == "Incinerated" else None
if v["encOutcome"] and not genuine_attempt(r, v["encCtx"]):
v["encOutcome"] = None
return v
def gate_open(node, state):
"""Whether a gated roll (game.yaml `requires`) can come out any other way than `otherwise`."""
req = CHANCE[node].get("requires") or {}
return all(state.get(k) == v for k, v in req.items())
# what each chance event observed in a prepared run (a gated roll only where its gate was open)
OBSERVE = {
"fs": lambda v: v.get("fs"),
"dieSight": lambda v: ("die" if v.get("diedSight") else "live") if v.get("fs") and not v.get("sightUnknown") else None,
"dieCombat": lambda v: ("die" if v.get("diedCombat") else "live") if v.get("help") else None,
"dieHour": lambda v: ("die" if v.get("diedHour") else "live") if v.get("survivedCadets") else None,
"shadow": lambda v: None if "shadow" not in v or not gate_open("shadow", v) else ("yes" if v["shadow"] else "no"),
"shadowColour": lambda v: v.get("shadowColour"),
"meadow": lambda v: v.get("meadow"),
}
assert set(OBSERVE) == set(CHANCE), "every chance event in game.yaml needs an OBSERVE rule"
def ctx_key(v, names):
return "|".join("?" if v.get(k) is None else str(v[k]) for k in names)
# ---------------------------------------------------------------- 2. counts
def can_bond(ctx, colour):
"""Whether a bond with this colour is possible at this encounter (game.yaml `encounters`)."""
e = G["encounters"][ctx]
return colour == "burn" or colour == e["colour"] or colour in (e.get("also") or [])
def count_tables(prepared, weights=None):
"""Counts for every chance event at every back-off level, plus each encounter's outcomes. weights: per run,
{chance event: weight of the outcome it observed} (reporting-bias corrections, core/atlas/bias.py)."""
T = {}
for node, sp in CHANCE.items():
t = T[node] = {}
for i, v in enumerate(prepared):
y = OBSERVE[node](v)
if not y:
continue
w = weights[i].get(node, 1) if weights else 1
if w == 0:
continue
for L in range(len(sp["context"]) + 1):
names = sp["context"][:L]
if any(v.get(k) is None for k in names):
break
c = t.setdefault(f"{L}:{ctx_key(v, names)}", {})
c[y] = c.get(y, 0) + w
for t in T.values(): # weighted counts are fractions: keep them short and stable
for c in t.values():
for k, x in c.items():
if isinstance(x, float):
c[k] = round(x, 4)
enc = T["encounter"] = {}
for v in prepared:
if not v.get("encCtx"):
continue
c = enc.setdefault(v["encCtx"], {"outcomes": {}, "seen": {}})
if v.get("encOutcome") and can_bond(v["encCtx"], v["encOutcome"]):
c["outcomes"][v["encOutcome"]] = c["outcomes"].get(v["encOutcome"], 0) + 1
# which colours can ever end a run in this context (from all runs, genuine or not)
for v in prepared:
if v.get("encCtx") and v.get("encOutcome") and v["encOutcome"] != "burn" and can_bond(v["encCtx"], v["encOutcome"]):
enc[v["encCtx"]]["seen"][v["encOutcome"]] = 1
return T
def support_from(prepared, min_n):
"""Options taken at least min_n times; options never recorded at all are not restricted."""
n = {}
def bump(k, o):
n.setdefault(k, {})
n[k][o] = n[k].get(o, 0) + 1
for v in prepared:
for k in ("company", "direction", "cadet", "hour", "descend", "valley"):
if v.get(k):
bump(k, v[k])
if v.get("left") and v["left"] != ALONE:
bump("leave", v["left"])
if v.get("fs") and v.get("react"):
bump("react:" + v["fs"], v["react"])
if v.get("post") and v["post"] != "(no fork)":
bump("post", v["post"])
# the cadet encounter's steps, including riders killed in the fight (they chose to help)
if v.get("help") or v.get("cadet"):
ignore = bool(v.get("cadet") and v["cadet"] in IGNORE)
bump("scream", "Keep walking" if ignore else "Investigate the scream")
if ignore:
bump("wounded", v["cadet"])
else:
bump("clearing", "Walk away" if v.get("cadet") == "Left them to it" else "Help your squadmate")
if v.get("cadet") in HELP:
bump("fate", v["cadet"])
if v.get("help") and v.get("fight"):
bump("fight", v["fight"])
if v.get("dagger") and v["dagger"] != NO_DAGGER:
bump("dagger", v["dagger"])
s = {"encounter": DECISIONS["encounter"]}
for k in ("company", "leave", "direction", "cadet", "scream", "clearing", "fight", "dagger", "fate", "wounded",
"post", "hour", "descend", "valley"):
s[k] = [o for o in DECISIONS[k] if n.get(k, {}).get(o, 0) >= min_n] or list(DECISIONS[k])
for fs in ("Red", "Brown", "Green", "Orange"):
k = "react:" + fs
s[k] = [o for o in DECISIONS["react"] if n.get(k, {}).get(o, 0) >= min_n] or list(DECISIONS["react"])
for k, d in G["decisions"].items():
if d.get("always_offered") and k != "encounter":
s[k] = list(d["options"])
return s, n
# ---------------------------------------------------------------- 3. empirical-Bayes concentration
def lgamma(x):
"""Log-gamma (Lanczos), the same approximation the route model has always used."""
c = [76.18009172947146, -86.50532032941677, 24.01409824083091, -1.231739572450155, 0.1208650973866179e-2,
-0.5395239384953e-5]
y = x
tmp = x + 5.5
tmp -= (x + 0.5) * math.log(tmp)
ser = 1.000000000190015
for v in c:
y += 1
ser += v / y
return -tmp + math.log(2.5066282746310005 * ser / x)
def fit_alpha(T, node):
"""The concentration that maximises the Dirichlet-multinomial likelihood of each back-off level given the one above."""
cats = CHANCE[node]["outcomes"]
t = T[node]
def pooled(key):
c = t.get(key, {})
a = [c.get(k, 0) + 0.5 for k in cats]
s = 0
for x in a:
s += x
return [x / s for x in a]
pairs = []
for key in t:
L = int(key.split(":")[0])
if L == 0:
continue
ctx = key[key.index(":") + 1:].split("|")
parent = f"{L - 1}:" + "|".join(ctx[:L - 1])
pairs.append(([t[key].get(k, 0) for k in cats], pooled(parent)))
if not pairs:
return {"alpha": ALPHA, "logLik": None}
# a roll that has only ever come out one way says nothing about whether routes differ: pool fully (the fit
# would otherwise drive every route's chance of the unseen outcome to zero)
if sum(1 for k in cats if t.get("0:", {}).get(k, 0) > 0) < 2:
return {"alpha": max(ALPHA_GRID), "logLik": None}
best_a, best_ll, lls = ALPHA, -math.inf, {}
for a in ALPHA_GRID:
ll = 0
for c, p in pairs:
n = 0
for x in c:
n += x
ll += lgamma(a) - lgamma(n + a)
for i in range(len(cats)):
ll += lgamma(c[i] + a * p[i]) - lgamma(a * p[i])
lls[a] = ll
if ll > best_ll:
best_ll, best_a = ll, a
return {"alpha": best_a, "logLik": lls}
# ---------------------------------------------------------------- 4. random numbers (reproducible from the seed)
class Rng:
"""xorshift32, as in the original route model (JavaScript semantics)."""
def __init__(self, seed):
self.s = (seed & 0xFFFFFFFF) or 1
def __call__(self):
s = self.s
s = (s ^ (s << 13)) & 0xFFFFFFFF
s ^= s >> 17
s = (s ^ (s << 5)) & 0xFFFFFFFF
self.s = s
return s / 4294967296
def gamma(shape, rand):
if shape < 1:
g = gamma(shape + 1, rand)
return g * math.pow(rand() or 1e-12, 1 / shape)
d = shape - 1 / 3
c = 1 / math.sqrt(9 * d)
while True:
while True:
u1 = rand() or 1e-12
u2 = rand()
x = math.sqrt(-2 * math.log(u1)) * math.cos(2 * math.pi * u2)
v = 1 + c * x
if v > 0:
break
v = v * v * v
u = rand()
if u < 1 - 0.0331 * x ** 4 or math.log(u) < 0.5 * x * x + d * (1 - v + math.log(v)):
return d * v
def dirichlet(alpha, rand):
g = [gamma(max(a, 1e-6), rand) for a in alpha]
s = 0
for x in g:
s += x
return [x / s for x in g]
def _normalise(a):
s = 0
for x in a:
s = s + x
return [x / s for x in a]
# ---------------------------------------------------------------- 5. the probability source
class Params:
"""Chance probabilities and encounter outcomes, as arrays over D worlds.
mode "mean": D = 1, posterior means. mode "draw": D = len(seeds), one joint posterior draw per seed (each
distribution is drawn once, the first time it is needed, and reused, so a draw is one consistent world).
In draw mode each world draws its numbers in the order its own walk of the game first needs them (a branch with
probability exactly zero in that world is never walked), so call solver.draw_worlds() before using it.
chance(node, state) -> {outcome: array(D)}; encounter(ctx) -> {outcome: array(D)}.
"""
def __init__(self, T, mode="mean", seeds=(), alphas=None):
self.T, self.mode, self.alphas = T, mode, alphas or {}
self.rngs = [Rng(s) for s in seeds] if mode == "draw" else []
self.D = len(self.rngs) if mode == "draw" else 1
self.memo = {} # (node, level key) or ("enc", ctx) -> array (K, D)
self.filled = {} # same keys -> bool array (D,): which worlds have drawn this distribution
self.world = None # while drawing one world (see draw_world), its index
self._cache = {}
def _levels(self, node, state):
sp = CHANCE[node]
out = []
for L in range(len(sp["context"]) + 1):
names = sp["context"][:L]
if any(state.get(k) is None for k in names):
break
out.append(f"{L}:{ctx_key(state, names)}")
return out
def _get(self, mk, K, make_a):
"""The distribution for key mk: drawn (or computed) the first time it is needed, then reused."""
if self.mode == "mean":
if mk not in self.memo:
self.memo[mk] = np.array(_normalise(make_a(None)), dtype=float).reshape(K, 1)
return self.memo[mk]
if mk not in self.memo:
self.memo[mk] = np.zeros((K, self.D))
self.filled[mk] = np.zeros(self.D, dtype=bool)
d = self.world
if d is not None and not self.filled[mk][d]:
self.memo[mk][:, d] = dirichlet([float(x) for x in make_a(d)], self.rngs[d])
self.filled[mk][d] = True
return self.memo[mk]
def chance(self, node, state):
if not gate_open(node, state): # a closed gate: the roll always comes out the same way
other = CHANCE[node]["otherwise"]
return {k: np.full(self.D, 1.0 if k == other else 0.0) for k in CHANCE[node]["outcomes"]}
# once every world has been drawn, the answer depends only on the context values: cache it
ck = (node, tuple(state.get(k) for k in CHANCE[node]["context"]))
if self.world is None and ck in self._cache:
return self._cache[ck]
out = self._chance(node, state)
if self.world is None:
self._cache[ck] = out
return out
def _chance(self, node, state):
cats = CHANCE[node]["outcomes"]
al = self.alphas.get(node) or ALPHA
p = None
for key in self._levels(node, state):
c = self.T[node].get(key, {})
parent = p
def make_a(d, c=c, parent=parent):
if parent is None:
return [c.get(k, 0) + 0.5 for k in cats]
return [c.get(k, 0) + al * (parent[i] if d is None else parent[i][d]) for i, k in enumerate(cats)]
p = self._get((node, key), len(cats), make_a)
return dict(zip(cats, p))
def encounter(self, ctx):
e = self.T["encounter"].get(ctx, {"outcomes": {}, "seen": {}})
cats = [k for k in ENC_CATS if k == "burn" or e["seen"].get(k) or e["outcomes"].get(k, 0) > 0 or k == enc_colour(ctx)]
p = self._get(("enc", ctx), len(cats), lambda d: [e["outcomes"].get(k, 0) + 0.5 for k in cats])
return dict(zip(cats, p))
+32
View File
@@ -0,0 +1,32 @@
"""Read data/public/runs_clean.csv (written by `python -m collection build`) as typed records.
Every analysis reads the runs from this one published file. Types come from data/dictionary.yaml: integers and
booleans are parsed, empty cells are None (data_flags is "" when a row has no flags).
"""
import csv
from pathlib import Path
import yaml
ROOT = Path(__file__).resolve().parents[2]
PATH = ROOT / "data/public/runs_clean.csv"
with open(ROOT / "data/dictionary.yaml", encoding="utf-8") as _f:
TYPES = {k: v["type"] for k, v in yaml.safe_load(_f)["columns"].items()}
def _parse(col, v):
if v == "":
return "" if col == "data_flags" else None
t = TYPES.get(col, "text")
if t == "integer":
return int(v)
if t == "boolean":
return v == "True"
return v
def read(path=PATH, sources=None, drop=("run_id",)):
"""Typed records, optionally only from some sources (the `source` column)."""
with open(path, encoding="utf-8", newline="") as f:
rows = [{k: _parse(k, v) for k, v in r.items() if k not in drop} for r in csv.DictReader(f)]
return [r for r in rows if sources is None or r["source"] in sources]
+384
View File
@@ -0,0 +1,384 @@
"""The route model: best decisions for bonding each dragon colour.
The game tree is core/spec/game.yaml. One interpreter (Walker) walks it; three kinds of walk reuse it:
Solver backward induction: the best option at every decision (vectorised over posterior draws)
Evaluator the value of a fixed policy (the one chosen on the posterior means) in every draw
Exporter the published decision tree, following the chosen options
Two objectives per target colour X:
1. "this attempt": maximise P(bond X on this attempt).
2. "eventually": deaths are free (you can try again), so what matters is not ending the account on the wrong
dragon: maximise P(X) / (P(X) + P(another colour)), by Dinkelbach iteration; ties go to the higher P(X).
Values are triples (x, o, r) of arrays over worlds: P(target), P(another colour), P(reaching an encounter alive).
"""
import numpy as np
from . import model, spec
G = spec.game()
STEPS = G["steps"]
LABEL = {**{k: v["label"] for k, v in G["decisions"].items()}, **{k: v["label"] for k, v in G["chance"].items()}}
def canon(state):
return tuple(sorted(state.items()))
def apply(then, state, value):
"""The state after an option or outcome: keep / drop, then set ($ = the value just taken)."""
s = {k: state[k] for k in then["keep"] if k in state} if "keep" in then else dict(state)
for k in then.get("drop", ()):
s.pop(k, None)
for k, v in (then.get("set") or {}).items():
s[k] = value if v == "$" else v
return s
class Walker:
"""Walks the game tree of game.yaml. Subclasses say what a decision, a roll, an ending and an encounter mean."""
def __init__(self, params, X, support, only=None):
self.params, self.X, self.support, self.only = params, X, support, only
def options(self, name, state):
by = G["decisions"][name].get("support_by")
if by:
return self.support.get(f"{name}:{state.get(by)}") or model.DECISIONS[name]
return self.support[name]
def root(self):
return self.run(G["start"], {})
def run(self, step_id, state):
st = STEPS[step_id]
if "decision" in st:
name = st["decision"]
return self.decision(name, state, self.options(name, state), lambda o: self.follow(st["then"], o, state))
node = st["chance"]
return self.chance(node, state, lambda k: self.follow(st["then"], k, state))
def follow(self, then, value, state):
t = then.get(value) or then["default"]
if "end" in t:
return self.end(t["end"])
s = apply(t, state, value)
if "encounter" in t:
ctx = t["encounter"].replace("$", value)
opts = ["Die on purpose"] if self.only and ctx not in self.only else self.support["encounter"]
return self.decision("encounter", {**s, "enc": ctx}, opts,
lambda o: self.die_on_purpose() if o == "Die on purpose" else self.attempt(ctx))
return self.run(t["go"], s)
class _Values(Walker):
"""Shared by Solver and Evaluator: values are (x, o, r) arrays over the worlds in params."""
def __init__(self, params, X, support, only=None):
super().__init__(params, X, support, only)
D = params.D
self.ZERO = (np.zeros(D), np.zeros(D), np.zeros(D))
self.REACHED = (np.zeros(D), np.zeros(D), np.ones(D))
def end(self, what):
return self.ZERO
def die_on_purpose(self):
return self.REACHED
def attempt(self, ctx):
cache = self.__dict__.setdefault("_attempt", {})
if ctx not in cache:
cache[ctx] = self._attempt_value(ctx)
return cache[ctx]
def _attempt_value(self, ctx):
x = 0
oth = 0
for k, p in self.params.encounter(ctx).items():
if k != "burn":
if k == self.X:
x = x + p
else:
oth = oth + p
D = self.params.D
return (np.broadcast_to(x, D).astype(float), np.broadcast_to(oth, D).astype(float), np.ones(D))
def chance(self, node, state, cont):
acc = self.ZERO
for k, p in self.params.chance(node, state).items():
if not np.any(p):
continue
v = cont(k)
acc = (acc[0] + p * v[0], acc[1] + p * v[1], acc[2] + p * v[2])
return acc
class Solver(_Values):
"""Backward induction. lam: scalar or array (one per world). After root(): .value, .choices, .option_values."""
def __init__(self, params, X, support, lam=0.0, record=False, only=None):
super().__init__(params, X, support, only)
self.lam = lam
self.memo, self.choices = {}, {}
self.option_values = {} if record else None
def score(self, v):
lam = self.lam
return (1 - lam) * v[0] - lam * v[1] + 1e-9 * v[0] - 1e-12 * v[1]
def decision(self, name, state, options, cont):
key = (name, canon(state))
if key in self.memo:
return self.memo[key]
top = arg = None
vals = {}
for i, o in enumerate(options):
v = cont(o)
vals[o] = v
if top is None:
top, arg = v, np.zeros(self.params.D, dtype=int)
else:
better = self.score(v) > self.score(top)
top = tuple(np.where(better, v[j], top[j]) for j in range(3))
arg = np.where(better, i, arg)
self.memo[key] = top
self.choices[key] = (list(options), arg)
if self.option_values is not None:
self.option_values[key] = vals
return top
def solve(self):
self.value = self.root()
self.memo.clear() # the values are no longer needed; posterior draws keep only their choices
return self
def decide(self, name, state, world=0):
opts, arg = self.choices[(name, canon(state))]
return opts[int(arg[world])]
class Evaluator(_Values):
"""The value of a fixed policy: decide(name, state) -> option, in every world of params."""
def __init__(self, params, X, support, decide, only=None):
super().__init__(params, X, support, only)
self.decide = decide
def decision(self, name, state, options, cont):
return cont(self.decide(name, state))
class Exporter(Walker):
"""The published tree: at decisions the chosen option, every option's value (each followed by the best play
afterwards) and how often it stays best across posterior draws; at rolls every branch and its probability.
Only the chosen option's subtree is expanded."""
def __init__(self, params, X, support, sol, draws, min_show=1e-4, only=None):
super().__init__(params, X, support, only)
self.sol, self.draws, self.min_show = sol, draws, min_show
def decision(self, name, state, options, cont):
key = (name, canon(state))
chosen = self.sol.decide(name, state)
ov = self.sol.option_values.get(key, {})
xs = sorted((float(v[0][0]) for v in ov.values()), reverse=True)
tie = len(xs) > 1 and xs[0] - xs[1] < 1e-12 # nothing to choose between (e.g. every option ends the run)
still = None
if not tie and self.draws is not None:
opts, arg = self.draws.choices[key]
ok = arg == opts.index(chosen)
reached = getattr(self.draws.params, "reached", {}).get(key)
if reached is not None:
ok = ok & reached
still = int(np.sum(ok)) / len(arg)
return {
"type": "decision", "var": name, "label": LABEL[name], "choice": chosen, "tie": tie, "stillBest": still,
"options": {o: {"pX": float(v[0][0]), "pOther": float(v[1][0]), "pReach": float(v[2][0])} for o, v in ov.items()},
"next": cont(chosen),
}
def chance(self, node, state, cont):
dist = self.params.chance(node, state)
return {"type": "chance", "var": node, "label": LABEL[node],
"branches": {k: {"p": float(p[0]), "next": cont(k)} for k, p in dist.items() if float(p[0]) >= self.min_show}}
def end(self, what):
return {"type": "end", "what": what}
def die_on_purpose(self):
return self.end("die on purpose")
def attempt(self, ctx):
return {"type": "end", "what": f"encounter: {ctx}", "outcomes": {k: float(p[0]) for k, p in self.params.encounter(ctx).items()}}
class _Drawer(Walker):
"""Walks the game in one world only, drawing its distributions in the order the walk first needs them and
skipping branches with probability exactly zero in that world. Records which decisions the world reaches."""
def __init__(self, params, support, world, reached):
super().__init__(params, None, support)
self.d, self.seen, self.reached = world, set(), reached
def decision(self, name, state, options, cont):
key = (name, canon(state))
if key in self.seen:
return
self.seen.add(key)
self.reached.setdefault(key, np.zeros(self.params.D, dtype=bool))[self.d] = True
for o in options:
cont(o)
def chance(self, node, state, cont):
for k, p in self.params.chance(node, state).items():
if p[self.d]:
cont(k)
def attempt(self, ctx):
self.params.encounter(ctx)
def end(self, what):
return None
def die_on_purpose(self):
return None
def draw_worlds(T, seeds, alphas, support):
"""Posterior draws, one world per seed, each drawn in its own walk of the game (see Params)."""
p = model.Params(T, "draw", seeds=seeds, alphas=alphas)
p.reached = {}
for d in range(p.D):
p.world = d
_Drawer(p, support, d, p.reached).root()
p.world = None
return p
# ---------------------------------------------------------------- objectives
def solve(params, X, support, lam=0.0, record=False, only=None):
return Solver(params, X, support, lam=lam, record=record, only=only).solve()
def solve_ratio(params, X, support, record=False, only=None):
"""Dinkelbach: lam* = max P(X) / (P(X) + P(other)), separately in every world (at most 30 updates each)."""
D = params.D
lam = np.zeros(D)
s = solve(params, X, support, lam=lam, only=only)
done = np.zeros(D, dtype=bool)
for _ in range(30):
x, o = s.value[0], s.value[1]
tot = x + o
r = np.where(tot > 0, x / np.where(tot > 0, tot, 1), 0.0)
done = done | (np.abs(r - lam) < 1e-10)
if done.all():
break
lam = np.where(done, lam, r)
s = solve(params, X, support, lam=lam, only=only)
if record:
s = solve(params, X, support, lam=lam, record=True, only=only)
s.lam = lam
return s
def evaluate(params, X, support, decide, only=None):
return Evaluator(params, X, support, decide, only=only).root()
# ---------------------------------------------------------------- summaries
def _sum(xs):
s = 0
for x in xs:
s += x
return s
def quantile(xs, q):
s = sorted(xs)
i = (len(s) - 1) * q
lo, hi = int(np.floor(i)), int(np.ceil(i))
return s[lo] + (s[hi] - s[lo]) * (i - lo)
def summarise(xs):
xs = [float(x) for x in xs]
return {"mean": _sum(xs) / len(xs), "lo": quantile(xs, 0.025), "hi": quantile(xs, 0.975)}
# ---------------------------------------------------------------- the published policy
def build_policy(runs, draws=200, seed=20261101, min_support=None, alpha=None, colours=None, bias_config=None):
"""The full policy for every colour. runs: coded runs (data/public/runs_clean.csv), as dicts. bias_config:
planner/policy.yaml `reporting_bias` (None: every run counts as reported)."""
colours = colours or model.COLOURS
min_support = G["min_support"] if min_support is None else min_support
prepared = [model.prepare_run(r) for r in runs]
bias_est, w = None, None
if bias_config:
from . import bias
bias_est, names = bias.estimate(runs, prepared, bias_config, set(model.RARE_GOALS))
w = bias.weights(names, prepared, bias_est, bias_config["rolls"])
T = model.count_tables(prepared, w)
support, counts = model.support_from(prepared, min_support)
fitted = {k: model.fit_alpha(T, k) for k in model.CHANCE}
alphas = {k: alpha for k in model.CHANCE} if alpha else {k: f["alpha"] for k, f in fitted.items()}
mean = model.Params(T, "mean", alphas=alphas)
drawp = draw_worlds(T, [seed + i * 7919 for i in range(draws)], alphas, support)
# Cross-fitting: choose the policy on one random half of the runs and score it on the other half.
r = model.Rng(seed)
fold = [0 if r() < 0.5 else 1 for _ in prepared]
halves = [model.count_tables([v for v, f in zip(prepared, fold) if f == h],
[x for x, f in zip(w, fold) if f == h] if w else None) for h in (0, 1)]
half_params = [model.Params(Th, "mean", alphas=alphas) for Th in halves]
targets = {}
for X in colours:
one = solve(mean, X, support, record=True)
ratio = solve_ratio(mean, X, support, record=True)
d_one = solve(drawp, X, support)
d_ratio = solve_ratio(drawp, X, support)
ev_one = evaluate(drawp, X, support, one.decide)
ev_ratio = evaluate(drawp, X, support, ratio.decide)
def block(sol, ev, dr):
x, o = ev[0], ev[1]
return {
"pX": {**summarise(x), "point": float(sol.value[0][0])},
"pOther": {**summarise(o), "point": float(sol.value[1][0])},
"ratio": summarise([xi / (xi + oi) if xi + oi else 0 for xi, oi in zip(x, o)]),
"expectedAttempts": summarise([1 / xi if xi > 0 else float("inf") for xi in x]),
"tree": Exporter(mean, X, support, sol, dr).root(),
}
cross = []
for f in (0, 1):
pol = solve(half_params[f], X, support)
cross.append({"inSample": float(pol.value[0][0]),
"heldOut": float(evaluate(half_params[1 - f], X, support, pol.decide)[0][0])})
targets[X] = {
"thisAttempt": block(one, ev_one, d_one), "eventually": block(ratio, ev_ratio, d_ratio),
"crossFit": {"inSample": (cross[0]["inSample"] + cross[1]["inSample"]) / 2,
"heldOut": (cross[0]["heldOut"] + cross[1]["heldOut"]) / 2},
}
return {
"schema": 1,
"model": {
"description": "Decision tree with perfect recall; chance probabilities depend on earlier choices via hierarchical Dirichlet back-off.",
"alphas": alphas, "alphaFit": {k: f["logLik"] for k, f in fitted.items()}, "draws": draws, "seed": seed,
"minSupport": min_support,
"chanceContext": {k: s["context"] for k, s in model.CHANCE.items()},
"decisions": model.DECISIONS, "support": support, "supportCounts": counts,
"tables": T,
# how much each kind of source over-reports each rare roll, and the correction applied (bias.py)
"reportingBias": bias_est,
# the game itself (core/spec/game.yaml), so the advisor in core/solver.js can re-solve from any point
"game": {k: G[k] for k in ("version", "colours", "decisions", "chance", "encounters", "encounter_outcomes",
"by_colour", "start", "steps", "from_form", "bot_text")},
},
"data": {"runs": len(runs)},
"targets": targets,
}
+22
View File
@@ -0,0 +1,22 @@
"""Load the declarative spec files in core/spec/."""
from functools import lru_cache
from pathlib import Path
import yaml
SPEC_DIR = Path(__file__).resolve().parent.parent / "spec"
@lru_cache(maxsize=None)
def load(name):
"""The parsed contents of core/spec/<name>.yaml (cached; treat as read-only)."""
with open(SPEC_DIR / f"{name}.yaml", encoding="utf-8") as f:
return yaml.safe_load(f)
def form():
return load("form")
def game():
return load("game")
+3 -13
View File
@@ -126,19 +126,9 @@
// END CROSSWALK
/** Map one bot trajectory onto the form's decision variables. Unmapped choices are listed, not guessed. */
/**
* The steps that were actually played. The bot logs a pick it then overrode (its own rules against the atlas's
* advice) as a step whose `to` is not where the run went, followed by the pick it made on the same screen. Those
* superseded picks are dropped. A step without `to` (a run in progress) is kept unless the next step is on the
* same screen.
*/
function playedSteps(steps) {
return (steps || []).filter((s, i) => !(i + 1 < steps.length && steps[i + 1].scene != null && steps[i + 1].scene === s.scene && s.to !== steps[i + 1].scene));
}
function trajectoryVariables(traj) {
const vars = {}, unmapped = [];
for (const s of playedSteps(traj.steps)) {
for (const s of traj.steps) {
const t = norm(s.optionText);
const hit = CROSSWALK.find(([re]) => re.test(t));
if (hit) { if (!(hit[1] in vars)) vars[hit[1]] = hit[2]; }
@@ -218,7 +208,7 @@
for (const o of s.options) g[id].options[o.id] = { id: o.id, text: o.text, n: 0, to: {}, bySource: {}, intentionalBurns: 0 };
}
for (const t of trajs) {
for (const s of playedSteps(t.steps)) {
for (const s of t.steps) {
const node = g[s.scene] || (g[s.scene] = { id: s.scene, stage: s.stage, tint: s.tint, label: s.stage, visits: 0, options: {} });
node.visits++;
const o = node.options[s.option] || (node.options[s.option] = { id: s.option, text: s.optionText, n: 0, to: {}, bySource: {}, intentionalBurns: 0 });
@@ -241,5 +231,5 @@
return g;
}
return { betaPosterior, betaQuantile, ibeta, CROSSWALK, trajectoryVariables, playedSteps, formRunVariables, VAR_STAGES, buildVariableGraph, buildSceneGraph, norm };
return { betaPosterior, betaQuantile, ibeta, CROSSWALK, trajectoryVariables, formRunVariables, VAR_STAGES, buildVariableGraph, buildSceneGraph, norm };
});
+312
View File
@@ -0,0 +1,312 @@
/*
* solver.js: the route advisor for the site and the DragonKind bot.
*
* The route model is built in Python (core/atlas/solver.py) from the game in core/spec/game.yaml and published as
* data/policy.json. Each sample in it carries the game itself (model.game) and the count tables behind every roll
* (model.tables, model.alphas). This file reads both and re-solves the game from any point in a run, including
* points off the recommended route, so a rider (or the bot) always gets the best next choice. It is the same
* interpreter as the Python one, kept small: a walk of the game's steps, posterior-mean odds with hierarchical
* back-off, backward induction, and Dinkelbach iteration for the "eventually" goal.
* tests/core/advisor.test.js checks it gives exactly the Python model's values.
*
* Public API (unchanged for the bot): advisor(sample, colour, objective, { only }), recommendOption(adv, h, texts),
* solverHistory(formVars, seen), makeParams(tables, { alphas, game }), ENCOUNTERS (set from the first sample).
* UMD: window.ThreshSolver in the browser, module.exports in Node. No dependencies.
*/
(function (root, factory) {
if (typeof module === "object" && module.exports) module.exports = factory();
else root.ThreshSolver = factory();
})(typeof self !== "undefined" ? self : this, function () {
"use strict";
const ALPHA = 20;
const ZERO = { x: 0, o: 0, r: 0 }, REACHED = { x: 0, o: 0, r: 1 };
const canon = (s) => JSON.stringify(Object.keys(s).sort().map((k) => [k, s[k]]));
const encColour = (ctx) => (ctx === "tree-Greens" ? "Green" : ctx.split("-")[1]);
const api = {};
/* ---------- posterior draws, for Thompson sampling ---------- */
function rng(seed) {
let x = (seed >>> 0) || 0x9e3779b9;
return () => { x ^= x << 13; x >>>= 0; x ^= x >>> 17; x ^= x << 5; x >>>= 0; return (x + 0.5) / 4294967296; };
}
function normal(rand) { return Math.sqrt(-2 * Math.log(rand())) * Math.cos(2 * Math.PI * rand()); }
function gamma(k, rand) { // Marsaglia and Tsang
if (k < 1) return gamma(k + 1, rand) * Math.pow(rand(), 1 / k);
const d = k - 1 / 3, c = 1 / Math.sqrt(9 * d);
for (;;) {
let x, v;
do { x = normal(rand); v = 1 + c * x; } while (v <= 0);
v = v * v * v;
const u = rand();
if (u < 1 - 0.0331 * x ** 4 || Math.log(u) < 0.5 * x * x + d * (1 - v + Math.log(v))) return d * v;
}
}
function dirichlet(a, rand) {
const g = a.map((x) => Math.max(gamma(x, rand), 1e-300));
let s = 0; for (const x of g) s += x;
return g.map((x) => x / s);
}
/* ---------- the odds: posterior means (or, with rand, one posterior draw) with hierarchical back-off ---------- */
function makeParams(T, { alphas = {}, game, rand = null }) {
const normalise = (a) => { let sum = 0; for (const x of a) sum += x; return a.map((x) => x / sum); };
const estimate = rand ? (a) => dirichlet(a, rand) : normalise;
const memo = new Map();
const ctxKey = (s, names) => names.map((k) => (s[k] == null ? "?" : s[k])).join("|");
function chance(node, state) {
const sp = game.chance[node], cats = sp.outcomes;
// a closed gate (game.yaml `requires`): the roll always comes out as `otherwise`
if (sp.requires && Object.entries(sp.requires).some(([k, v]) => state[k] !== v)) return Object.fromEntries(cats.map((k) => [k, k === sp.otherwise ? 1 : 0]));
let p = null;
for (let L = 0; L <= sp.context.length; L++) {
const names = sp.context.slice(0, L);
if (names.some((k) => state[k] == null)) break;
const key = L + ":" + ctxKey(state, names), mk = node + "#" + key;
if (memo.has(mk)) { p = memo.get(mk); continue; }
const c = T[node][key] || {}, al = alphas[node] || ALPHA;
const a = cats.map((k, i) => (c[k] || 0) + (p ? al * p[i] : 0.5));
p = estimate(a);
memo.set(mk, p);
}
return Object.fromEntries(cats.map((k, i) => [k, p[i]]));
}
function encounter(ctx) {
const mk = "enc#" + ctx;
if (!memo.has(mk)) {
const e = T.encounter[ctx] || { outcomes: {}, seen: {} };
const cats = game.encounter_outcomes.filter((k) => k === "burn" || e.seen[k] || (e.outcomes[k] || 0) > 0 || k === encColour(ctx));
const a = estimate(cats.map((k) => (e.outcomes[k] || 0) + 0.5));
memo.set(mk, Object.fromEntries(cats.map((k, i) => [k, a[i]])));
}
return memo.get(mk);
}
return { chance, encounter };
}
/* ---------- one walk of the game, used to solve (as Walker in core/atlas/solver.py) ---------- */
function apply(then, state, value) {
const s = then.keep ? Object.fromEntries(then.keep.filter((k) => k in state).map((k) => [k, state[k]])) : { ...state };
for (const k of then.drop || []) delete s[k];
for (const [k, v] of Object.entries(then.set || {})) s[k] = v === "$" ? value : v;
return s;
}
function walker(game, support, only, hooks) {
const options = (name, state) => {
const by = game.decisions[name].support_by;
return by ? support[`${name}:${state[by]}`] || game.decisions[name].options : support[name];
};
function follow(then, value, state) {
const t = then[value] || then.default;
if (t.end) return hooks.end(t.end);
const s = apply(t, state, value);
if (t.encounter) {
const ctx = t.encounter.replace("$", value);
const opts = only && !only.includes(ctx) ? ["Die on purpose"] : support.encounter;
return hooks.decision("encounter", { ...s, enc: ctx }, opts, (o) => (o === "Die on purpose" ? hooks.dieOnPurpose() : hooks.attempt(ctx)));
}
return run(t.go, s);
}
function run(id, state) {
const st = game.steps[id];
if (st.decision) return hooks.decision(st.decision, state, options(st.decision, state), (o) => follow(st.then, o, state));
return hooks.chance(st.chance, state, (k) => follow(st.then, k, state));
}
return { root: () => run(game.start, {}) };
}
/** Backward induction for colour X: score = (1 - lam) P(X) - lam P(other), ties to the higher P(X). */
function solve(params, game, support, X, lam = 0, only = null) {
const memo = new Map(), choices = new Map(), optVals = new Map();
const score = (v) => (1 - lam) * v.x - lam * v.o + 1e-9 * v.x - 1e-12 * v.o;
const w = walker(game, support, only, {
decision(name, state, opts, cont) {
const key = name + "@" + canon(state);
if (memo.has(key)) return memo.get(key);
let top = null, arg = null;
const vals = {};
for (const o of opts) {
const v = cont(o);
vals[o] = v;
if (!top || score(v) > score(top)) { top = v; arg = o; }
}
memo.set(key, top); choices.set(key, arg); optVals.set(key, vals);
return top;
},
chance(node, state, cont) {
let acc = ZERO;
for (const [k, p] of Object.entries(params.chance(node, state))) {
if (!p) continue;
const v = cont(k);
acc = { x: acc.x + p * v.x, o: acc.o + p * v.o, r: acc.r + p * v.r };
}
return acc;
},
end: () => ZERO,
dieOnPurpose: () => REACHED,
attempt(ctx) {
let x = 0, o = 0;
for (const [k, p] of Object.entries(params.encounter(ctx))) if (k !== "burn") { if (k === X) x += p; else o += p; }
return { x, o, r: 1 };
},
});
return { value: w.root(), choices, optVals };
}
function solveRatio(params, game, support, X, only) {
let lam = 0, s = solve(params, game, support, X, 0, only);
for (let i = 0; i < 30; i++) {
const v = s.value, r = v.x + v.o > 0 ? v.x / (v.x + v.o) : 0;
if (Math.abs(r - lam) < 1e-10) break;
lam = r;
s = solve(params, game, support, X, lam, only);
}
return { ...s, lam };
}
/* ---------- the advisor ---------- */
/**
* advisor(sample, X, objective, { only }): sample is policy.samples.all (or .lowBias); X a colour; objective
* "eventually" (default) or "thisAttempt"; only: bond only at these encounters, die on purpose elsewhere.
* Returns { value, step(h), next(h), attempts(ctx), params, game }.
*
* h is a run so far, keyed by the game's step names: decisions (company, leave, direction, react, scream,
* clearing, fight, dagger, fate, wounded, post, hour, descend, red, valley, encounter) and rolls (fs, shadow,
* shadowColour, meadow). A rider asking for advice survived every deadly roll so far; step() reports the risk of
* the deadly roll just passed on the step after it. When h already has a later step but skips an earlier
* decision (an older form record, say), the recommended option is assumed for the skipped one.
*/
function advisor(sample, X, objective = "eventually", { only = null, sampling = "best", seed = 1, draws = 40 } = {}) {
const m = sample.model, game = m.game;
api.game = game; api.ENCOUNTERS = game.by_colour;
const solveWith = (params) => (objective === "eventually" ? solveRatio(params, game, m.support, X, only) : solve(params, game, m.support, X, 0, only));
// "best": the best route under the posterior means. "thompson": the best route of one posterior draw of the odds
// (one per attempt: make a new advisor with a new seed for each attempt), so every option is tried about as
// often as it is likely to be the best one; as the data firm up, sampling settles on the best route.
const thompson = sampling === "thompson";
const params = makeParams(m.tables, { alphas: m.alphas, game, rand: thompson ? rng(seed) : null });
const sol = solveWith(params);
// the chance Thompson sampling picks each option at a history, estimated from `draws` other draws: the
// propensity to log, so the runs can be re-weighted later
let worlds = null;
const propensityAt = (key, choice) => {
if (!thompson) return 1;
if (!worlds) worlds = Array.from({ length: draws }, (_, i) => solveWith(makeParams(m.tables, { alphas: m.alphas, game, rand: rng(seed * 7919 + i + 1) })).choices);
return worlds.filter((c) => c.get(key) === choice).length / draws;
};
const VARS = new Set([...Object.keys(game.decisions), ...Object.keys(game.chance), "encounter"]);
const fmt = (v) => ({ pX: v.x, pOther: v.o, pReach: v.r });
const label = (k) => (game.decisions[k] || game.chance[k]).label;
const decisionAt = (name, key, extra) => {
const vals = sol.optVals.get(key) || {};
const choice = sol.choices.get(key);
return { kind: "decision", var: name, label: label(name), choice, propensity: propensityAt(key, choice),
options: Object.fromEntries(Object.entries(vals).map(([o, v]) => [o, fmt(v)])), ...extra };
};
/** The next thing that happens after history h: a decision, a roll, or the end of the run. */
function step(h) {
const used = new Set();
const later = () => Object.keys(h).some((k) => VARS.has(k) && h[k] != null && !used.has(k));
let id = game.start, state = {}, risk = null;
for (let guard = 0; guard < 100; guard++) {
const st = game.steps[id];
let value;
if (st.decision) {
const name = st.decision, key = name + "@" + canon(state);
if (h[name] != null) { value = h[name]; used.add(name); }
else if (later()) value = sol.choices.get(key);
else return decisionAt(name, key, risk ? { risk } : {});
risk = null;
} else {
const node = st.chance, probs = params.chance(node, state), sp = game.chance[node];
if (sp.risk_label) { risk = { label: sp.risk_label, p: probs.die }; value = "live"; }
else if (h[node] != null) { value = h[node]; used.add(node); risk = null; }
else return { kind: "chance", var: node, label: label(node), probs, ...(risk ? { risk } : {}) };
}
const t = st.then[value] || st.then.default;
if (!t) return { kind: "end", invalid: `${st.decision || st.chance} = ${value}` };
if (t.end) return { kind: "end", what: t.end };
const s = apply(t, state, value);
if (t.encounter) {
const ctx = t.encounter.replace("$", value);
if (h.encounter == null) return decisionAt("encounter", "encounter@" + canon({ ...s, enc: ctx }), { encounter: ctx, ...(risk ? { risk } : {}) });
return { kind: "end", encounter: ctx, action: h.encounter, outcomes: h.encounter === "Die on purpose" ? { burn: 1 } : params.encounter(ctx) };
}
id = t.go; state = s;
}
throw new Error("the game has no end");
}
return {
colour: X, objective, only, sampling, seed: thompson ? seed : null, value: sol.value, step, params, game,
/** attempts recorded at an encounter (genuine attempts only), to show how much data a bond chance rests on */
attempts: (ctx) => Object.values(((m.tables.encounter || {})[ctx] || { outcomes: {} }).outcomes).reduce((a, b) => a + b, 0),
/** the next decision only (null when the next step is a roll or the run is over) */
next(h) {
const s = step(h);
return s.kind === "decision" ? { decision: s.var, label: s.label, choice: s.choice, propensity: s.propensity, options: s.options } : null;
},
};
}
/* ---------- the bot ---------- */
const norm = (t) => String(t || "").toLowerCase().replace(/[‘’‛`']/g, "'").replace(/[–—-]/g, " ").replace(/[^a-z0-9'\s]/g, " ").replace(/\s+/g, " ").trim();
/**
* Which of the options on the bot's screen to pick: { index, decision, choice, margin, options, reason }.
* index is null when there is no advice for this screen (use the bot's own rules). The encounter decision
* ("Attempt the bond" / "Die on purpose") is returned without an index: the bot knows which option is which.
* The on-screen text of each option is in game.yaml (bot_text).
*/
function recommendOption(adv, h, offered) {
const rec = adv.next(h);
if (!rec) return null;
const pat = ((adv.game.bot_text || {})[rec.decision] || {})[rec.choice];
const idx = pat ? offered.map(norm).findIndex((t) => new RegExp(pat).test(t)) : -1;
const values = Object.values(rec.options).map((v) => v.pX).sort((a, b) => b - a);
return { index: idx < 0 ? null : idx, decision: rec.decision, choice: rec.choice, propensity: rec.propensity,
margin: values.length > 1 ? values[0] - values[1] : null,
options: rec.options,
reason: idx < 0 && rec.decision !== "encounter" ? "the recommended choice is not on this screen; use the bot's own rules" : `${rec.label}: ${rec.choice}` };
}
/**
* The community form's variables for a run so far (graph.trajectoryVariables(t).vars, or a coded form run) as a
* history for advisor().step(), keyed by the game's step names. seen: what the bot saw on screen that the form does
* not ask: { shadow: "yes"|"no", shadowColour, meadow }. Uses the game of the last advisor made (or pass one).
*/
function solverHistory(vars, seen = {}, game = api.game) {
const D = game.decisions, F = game.from_form, h = {};
const has = (k, v) => D[k].options.includes(v);
if (has("company", vars.company)) h.company = vars.company;
const lf = vars.left_squadmates;
if (h.company && h.company !== "Alone" && lf != null && lf !== "") h.leave = String(lf).toLowerCase() === "true" ? "Leave them" : "Stay together";
if (has("direction", vars.direction)) h.direction = vars.direction;
if (["Red", "Brown", "Green", "Orange"].includes(vars.first_sighting)) h.fs = vars.first_sighting;
if (has("react", vars.sighting_action)) h.react = vars.sighting_action;
if (vars.scream === "Ignore the scream") h.scream = "Keep walking";
else if (vars.scream === "Investigate & help" || vars.scream === "Investigate & leave" || vars.scream_investigate) h.scream = "Investigate the scream";
if (vars.scream === "Investigate & help") h.clearing = "Help your squadmate";
if (vars.scream === "Investigate & leave") h.clearing = "Walk away";
if (F.fight[vars.combat_first]) h.fight = F.fight[vars.combat_first];
if (F.dagger[vars.combat_second]) h.dagger = F.dagger[vars.combat_second];
if (F.helped.includes(vars.resolution)) h.fate = vars.resolution;
if (F.ignored.includes(vars.resolution)) h.wounded = vars.resolution;
if (has("post", vars.post_path)) h.post = vars.post_path;
if (has("hour", vars.hour)) h.hour = vars.hour;
if (vars.branch === "Descend quickly: Red" || vars.branch === "Descend quickly: let the Red pass") h.descend = "Quickly (Red)";
if (vars.branch === "Descend quickly: let the Red pass") h.red = "Let it pass (two Greens)";
if (has("red", vars.red)) h.red = vars.red;
if (vars.branch === "Descend slowly: two Greens") h.descend = "Slowly (two Greens)";
if (vars.branch === "Valley Red") h.valley = "Face the Red";
if (vars.branch === "Passed the Red: meadow") h.valley = "Pass the Red (meadow)";
for (const k of ["meadow", "shadow", "shadowColour"]) if (seen[k]) h[k] = seen[k];
if (h.hour === "Tree" && h.descend && !h.shadow) h.shadow = "no";
return h;
}
return Object.assign(api, {
advisor, recommendOption, solverHistory, norm,
makeParams: (T, { alphas, game } = {}) => makeParams(T, { alphas, game: game || api.game }),
/** remember the game of a policy sample (sets ENCOUNTERS) without solving anything */
useGame(sample) { api.game = sample.model.game; api.ENCOUNTERS = api.game.by_colour; return api.game; },
ENCOUNTERS: null, game: null,
});
});
-42
View File
@@ -104,12 +104,6 @@ answers:
"Trying to bond the Red dragon under the tree": "Red (tree)"
"Daily Run Assignment data": "Daily run data"
"Just here for fun, and maybe a dragon": "Any (for fun)"
# Squad: matched ignoring case and spaces (riders type it); an answer not listed still stops the build
squad_any_case:
"first": "First"
"second": "Second"
"third": "Third"
"don't know": "Don't know"
sighting_action:
"Hold Ground / Stay Still": "Hold still"
"Respect / Face it": "Respect / face it"
@@ -153,41 +147,5 @@ sighting_pool:
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] }
# 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.
# Flags (data_flags, matched as text inside a flag) that mean a run cannot have happened as recorded: the game's own
# rules, from the form coder (core/atlas/coding.py) and the checks of collection/etl/runs.py rule_flags. A run with one
# is kept in runs_clean.csv, flagged, and left out of the route model and the site statistics (atlas.runs.impossible).
# Everything else, however partial, is used. Not here on purpose: a first sighting outside the documented pool (the
# pool is what riders have seen, not a rule), a missing direction, several wings, a missing Green before a rescue.
impossible_flags:
- "Green recorded on a Valley run"
- "Black recorded on a Valley run"
- "encounter, which has only"
- "more than one dragon marked Bonded"
- "more than one dragon marked Incinerated"
- "tree run with both the Red and the two Greens attempted"
- "died in combat on a path without combat"
- "rare-dragon answer does not match the path"
- "does not follow"
- "fight answers on a run that did not help"
- "a path after the fight on a run without a fight"
- "a second fight move without pausing to assess"
- "died before the hour, yet reached"
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
# original answer (data_flags), so nothing is lost.
first_sighting_alias:
"2 Greens": Green
# How a bulk-pasted row's attempt answer is read
attempt_words: { first: 1, second: 2, third: 3, fourth: 4, fifth: 5 }
+223
View File
@@ -0,0 +1,223 @@
# The threshing as a game tree: every choice a rider makes (decisions), every roll of the dice (chance events),
# and every bonding encounter, in the game's own order.
#
# This file is the single source of truth for the route model. core/atlas/solver.py builds the decision tree from
# it, and the route advisor used by the site and Ken's bot reads the same file (published as game.json).
# Adding a choice to the game means adding it here (plus, if the form records it, how in core/atlas/model.py).
version: 1
# Colours in the order the route model reports them
colours: [Red, Orange, Brown, Green, Blue, Black]
# ---------------------------------------------------------------- decisions: the rider's choices
# options: every option the game offers, in a fixed order (ties go to the first). Options seen fewer than
# min_support times in the data are not recommended, except where `always_offered` says so.
decisions:
company: { label: Company, options: [Alone, 1 Squadmate, 2 Squadmates] }
leave: { label: Your squadmates, options: [Stay together, Leave them] }
direction: { label: First direction, options: [East, West, Center] }
react:
label: Facing the first dragon
# the form's categories; which ones each dragon offers is learned per first dragon (support key react:<fs>)
options: [Hold still, Respect / face it, Retreat / run, Hide, Weapon, Meet its gaze, Protect squadmate]
support_by: fs
scream: { label: The scream, options: [Investigate the scream, Keep walking] }
clearing: { label: The clearing (your squadmate vs two bullies), options: [Help your squadmate, Walk away] }
fight: { label: "The fight: your first move", options: [Pause to assess, Charge the smaller cadet, Charge between the bigger cadet and your squadmate] }
dagger: { label: The smaller cadet's dagger, options: [Engage the smaller cadet, Charge the bigger cadet anyway] }
fate: { label: The bullies' fate, options: [Killed the bullies yourself, Squadmate's revenge, Left bullies to the dragons] }
wounded: { label: The wounded cadet, options: [Tourniquet, Left injured cadet, Took their weapons] }
post: { label: Fork in the road, options: [Forest, West, East] }
hour: { label: After an hour, options: [Tree, Valley] }
descend: { label: Climb down, options: [Quickly (Red), Slowly (two Greens)] }
red:
label: The Red below the tree
options: [Jump onto the Red, Let it pass (two Greens)]
# rarely logged on its own, but letting it pass leads to the two Greens' encounter, which has plenty of data
always_offered: true
valley: { label: Valley centre, options: [Face the Red, Pass the Red (meadow)] }
encounter: { label: Bonding encounter, options: [Attempt the bond, Die on purpose], always_offered: true }
# the whole cadet encounter as one answer (how the community form records it)
cadet:
label: Cadet encounter
options: [Killed the bullies yourself, Squadmate's revenge, Left bullies to the dragons, Tourniquet, Left injured cadet, Took their weapons, Left them to it]
summary_only: true
min_support: 20
# ---------------------------------------------------------------- chance events: the game's rolls
# outcomes: in a fixed order. context: the earlier steps the odds may depend on, most important first; the
# estimate for a full context is shrunk toward the estimate for a shorter one (hierarchical Dirichlet back-off,
# strength learned from the data). requires: earlier choices without which the roll always comes out as
# `otherwise` (a gate); runs that did not make them say nothing about the roll and are not counted.
chance:
fs: { label: First dragon, outcomes: [Red, Brown, Green, Orange], context: [direction, company, left] }
# rolls that can kill you: risk_label names the danger when the advisor reports it
dieSight: { label: Survive the first dragon, outcomes: [die, live], context: [fs, direction, company, left, react], risk_label: Killed at the first sighting }
dieCombat: { label: Survive the fight, outcomes: [die, live], context: [fight, dagger, fs, direction], risk_label: Killed in the fight }
dieHour: { label: Survive the hour, outcomes: [die, live], context: [cadet, post], risk_label: Killed before the hour }
shadow:
label: Shadow at the tree
outcomes: ["yes", "no"]
context: [cadet, post, fs, direction, company]
# the "Black Dragon Gates" of the community route PDF (November 2026). The runs agree: in the spreadsheet,
# 78 shadows in 4199 tree runs that investigated and helped, 2 (both form submissions) in 646 that did not.
requires: { scream: Investigate the scream, clearing: Help your squadmate }
otherwise: "no"
shadowColour: { label: Shadow dragon, outcomes: [Black, Blue], context: [] }
meadow: { label: Meadow dragon, outcomes: [Orange, Brown, Blue], context: [cadet, post, fs, direction, company] }
# Bonding encounters: where each colour can be bonded. A run can only bond the encounter's own colour, except at
# the two Greens, where an Orange or a Brown can swoop in (`also`). A recorded bond with any other colour is a
# data-entry error and is not counted.
encounters:
valley-Red: { label: The valley Red, colour: Red }
tree-Red: { label: The Red below the tree, colour: Red }
tree-Greens: { label: The two Greens, colour: Green, also: [Orange, Brown] }
meadow-Orange: { label: The meadow Orange, colour: Orange }
meadow-Brown: { label: The meadow Brown, colour: Brown }
meadow-Blue: { label: The meadow Blue, colour: Blue }
shadow-Blue: { label: The Blue at the redwood, colour: Blue }
shadow-Black: { label: The Black (the shadow), colour: Black }
encounter_outcomes: [burn, Red, Orange, Brown, Green, Blue, Black]
by_colour:
Red: [valley-Red, tree-Red]
Orange: [meadow-Orange, tree-Greens]
Brown: [meadow-Brown, tree-Greens]
Green: [tree-Greens]
Blue: [meadow-Blue, shadow-Blue]
Black: [shadow-Black]
# ---------------------------------------------------------------- the flow of a run
# Each step is a decision, a chance event or an encounter, keyed by the history so far (the "state").
# After an option or outcome, `then` says what happens: `set` adds to the state ($ = the option or outcome just
# taken), `keep` / `drop` remove steps nothing later depends on, `go` names the next step, `end` finishes the run
# (with a death, the value is zero). `default` covers every option without its own entry.
start: company
steps:
company:
decision: company
then:
Alone: { set: { company: $, left: (alone) }, go: direction }
default: { set: { company: $ }, go: leave }
leave:
decision: leave
then: { default: { set: { left: $ }, go: direction } }
direction:
decision: direction
then: { default: { set: { direction: $ }, go: first_dragon } }
first_dragon:
chance: fs
then: { default: { set: { fs: $ }, go: react } }
react:
decision: react
then: { default: { set: { react: $ }, go: survive_sighting } }
survive_sighting:
chance: dieSight
then:
die: { end: incinerated at the first sighting }
# leaving your squadmates and your reaction only matter at the first dragon
live: { keep: [company, direction, fs], go: scream }
scream:
decision: scream
then:
Keep walking: { set: { scream: $ }, go: wounded }
Investigate the scream: { set: { scream: $ }, go: clearing }
wounded:
decision: wounded
then: { default: { set: { cadet: $, post: (no fork) }, go: survive_hour } }
clearing:
decision: clearing
then:
Walk away: { set: { clearing: $, cadet: Left them to it, post: (no fork) }, go: survive_hour }
Help your squadmate: { set: { clearing: $ }, go: fight }
fight:
decision: fight
then:
Pause to assess: { set: { fight: $ }, go: dagger }
default: { set: { fight: $, dagger: (no dagger choice) }, go: survive_fight }
dagger:
decision: dagger
then: { default: { set: { dagger: $ }, go: survive_fight } }
survive_fight:
chance: dieCombat
then:
die: { end: killed in the fight }
live: { go: fate }
fate:
decision: fate
# the fight's moves only matter for surviving it
then: { default: { drop: [fight, dagger], set: { cadet: $ }, go: post } }
post:
decision: post
then: { default: { set: { post: $ }, go: survive_hour } }
survive_hour:
chance: dieHour
then:
die: { end: incinerated }
live: { go: hour }
hour:
decision: hour
then:
Tree: { set: { hour: $ }, go: shadow }
Valley: { set: { hour: $ }, go: valley }
shadow:
chance: shadow
then:
"yes": { go: shadow_colour }
"no": { set: { shadow: "no" }, go: descend }
shadow_colour:
chance: shadowColour
then: { default: { set: { shadow: "yes" }, encounter: "shadow-$" } }
descend:
decision: descend
then:
Quickly (Red): { set: { descend: $ }, go: red }
Slowly (two Greens): { set: { descend: $ }, encounter: tree-Greens }
red:
decision: red
then:
Jump onto the Red: { set: { red: $ }, encounter: tree-Red }
Let it pass (two Greens): { set: { red: $ }, encounter: tree-Greens }
valley:
decision: valley
then:
Face the Red: { set: { valley: $ }, encounter: valley-Red }
Pass the Red (meadow): { set: { valley: $ }, go: meadow }
meadow:
chance: meadow
then: { default: { set: { meadow: $ }, encounter: "meadow-$" } }
# ---------------------------------------------------------------- how the community form's answers map onto the game
# (used to count how often each option was taken and how each roll came out; see core/atlas/model.py)
from_form:
fight:
"Assess the situation": Pause to assess
"Even the numbers (smaller cadet)": Charge the smaller cadet
"Put yourself in the middle (bigger cadet)": Charge between the bigger cadet and your squadmate
dagger:
"Engage the smaller cadet": Engage the smaller cadet
"Daggers or not (protect squadmate)": Charge the bigger cadet anyway
# cadet resolutions on each side of the scream
helped: [Killed the bullies yourself, Squadmate's revenge, Left bullies to the dragons]
ignored: [Tourniquet, Left injured cadet, Took their weapons]
# a rider's stated goal that means "chasing a rare dragon"
rare_goals: [Blue, Black, Blue or Black]
# ---------------------------------------------------------------- the bot: which on-screen text is which option
# Regular expressions over the option text, lower-cased with punctuation removed (see core/graph.js norm()).
# recommendOption() in core/solver.js uses these to point the bot at the recommended option on its screen.
bot_text:
company: { Alone: "^enter the valley alone", "1 Squadmate": "^enter the valley with one", "2 Squadmates": "^enter the valley with two" }
direction: { East: "^head east", West: "^head west", Center: "^head toward the center of the forest" }
react: { Hold still: "hold still", Respect / face it: "in respect|turn to face it", Retreat / run: "^run and hope", Hide: "^hide", Meet its gaze: "meeting its gaze" }
scream: { Investigate the scream: "^investigate the scream", Keep walking: "^keep walking" }
clearing: { Help your squadmate: "^help your squadmate", Walk away: "^play it safe and leave them" }
fight: { Pause to assess: "^pause to assess", Charge the smaller cadet: "^charge the other cadet", Charge between the bigger cadet and your squadmate: "^unsheathe your weapon" }
dagger: { Engage the smaller cadet: "^engage the smaller cadet", Charge the bigger cadet anyway: "^daggers or not" }
fate: { Killed the bullies yourself: "^end the lives of the bullies", Squadmate's revenge: "^allow your squadmate to exact", Left bullies to the dragons: "^leave the bullies alive" }
wounded: { Tourniquet: "tourniquet", Left injured cadet: "leave (them|him|her) to die", Took their weapons: "take (their|his|her) weapons?" }
post: { East: "^walk toward the east", West: "^walk toward the west", Forest: "^walk farther into the forest" }
hour: { Valley: "^continue toward the center of the valley", Tree: "^find the tallest tree" }
descend: { Quickly (Red): "^descend quickly", Slowly (two Greens): "^climb down slowly" }
red: { Jump onto the Red: "^jump", Let it pass (two Greens): "^reds are too hot tempered" }
+25
View File
@@ -0,0 +1,25 @@
# Data sources
Every source is declared in `collection/pipeline.yaml` and collected by `python -m collection update`
(see `collection/README.md`). Every run from every source is in `public/runs_clean.csv`, with a `source` column.
| Source (`source` column) | Where it lives here |
|---|---|
| Community "Threshing Routes" form and spreadsheet, u/ClumsyBadger (`reddit spreadsheet`) | `public/form_responses.json` (emails redacted) |
| Result pages posted in the r/fourthwing megathreads (`reddit thread`) | `collection/manual/reddit_results.yaml` |
| The Atlas's "Report a run" form (`reported`) | `public/reports.json` (answers only, no usernames) |
| DragonKind bot exports (`bot`) | `bot/scenes.json`, `bot/trajectories-<date>.jsonl` (anonymised; see `docs/BOT_DATA_PROTOCOL.md`) |
| Community route PDF, u/ClumsyBadger (`reddit pdf`) | not redistributed: `derived/pdf_fingerprint.json` only; it maps the choices and holds no runs |
| Unofficial Dragon Register | `public/register.json` (rider names and photos dropped); no runs |
| Discord | not yet: planned, with admin consent and anonymised usernames |
Raw files (`raw/`, git-ignored) are never published: the current version of each source and the one before it.
`manifest.json` records the current raw file's checksum and when it last changed.
## What each column means
`data/dictionary.yaml` describes every published file and every column of `data/public/runs_clean.csv`: its type,
what it means and every value it can take. `data/croissant.json` says the same in the
[Croissant](https://docs.mlcommons.org/croissant/) metadata format (with a sha256 checksum for every file), so
dataset tools can load and cite the data. `python -m collection build` rewrites it; the tests fail if a column or
value is not described or the metadata is out of date.
-179
View File
@@ -1,179 +0,0 @@
{
"schema": 1,
"by_attempt": {
"form": {
"1": [
97,
973
],
"2": [
0,
301
],
"3": [
0,
198
],
"4-10": [
0,
574
],
"11-30": [
0,
706
],
"31 or more": [
1,
847
]
},
"bulk logs": {
"1": [
0,
29
],
"2": [
0,
21
],
"3": [
0,
14
],
"4-10": [
0,
102
],
"11-30": [
0,
58
],
"31 or more": [
0,
57
]
},
"bot": {
"1": [
0,
0
],
"2": [
0,
4
],
"3": [
0,
5
],
"4-10": [
0,
36
],
"11-30": [
0,
137
],
"31 or more": [
0,
333
]
},
"Reddit comments": {
"1": [
1,
1
],
"2": [
0,
0
],
"3": [
0,
0
],
"4-10": [
0,
0
],
"11-30": [
0,
0
],
"31 or more": [
0,
0
]
}
},
"reddit_shadows": {
"all": 17,
"gated": 3,
"first_attempt": 3
},
"same_route": {
"routes": 334,
"first_shadows": 93,
"expected": 38.0,
"odds_ratio": 111.1,
"z": 12.7
},
"form_first": [
97,
973
],
"form_later": [
1,
2626
],
"best_route": {
"route": [
"Alone",
"West",
"Assess the situation",
"Engage the smaller cadet",
"Squadmate's revenge",
"West"
],
"first": [
23,
114
],
"later": [
0,
113
]
},
"shadow_routes": {
"runs": 99,
"routes": 48,
"off_gate": 3,
"gates_unstated": 14
},
"after_shadow": {
"reached_black": 91,
"bonded_black": 67,
"died_at_blue": 19,
"answers": {
"held its gaze": [
29,
41
],
"lowered eyes": [
0,
7
],
"ignored the sound": [
0,
1
]
}
},
"bot": {
"attempts": 878,
"accounts": 27,
"gated_tree": 515,
"shadows": 0,
"earliest_attempt": 2
}
}
View File
+826
View File
@@ -0,0 +1,826 @@
{
"01c36238ed4d": {
"stage": "FORK_IN_FOREST",
"tint": "red",
"backdrop": "clearing",
"label": "FORK_IN_FOREST · red",
"options": [
{
"id": "8815af6f63",
"text": "There’s no way this is your dragon and you need to get out of here"
},
{
"id": "ec479648fd",
"text": "This is your dragon and it’s time to start bonding"
}
]
},
"07e24681e3b3": {
"stage": "TREE_SHADOW_CHECK",
"tint": "green",
"backdrop": "clearing",
"label": "Descended slowly: two Greens in the clearing",
"options": [
{
"id": "d7f4b4e9da",
"text": "Lower your eyes and turn your body toward the right"
},
{
"id": "9da997c847",
"text": "Lower your eyes but keep your body neutral, letting them decide"
},
{
"id": "bafcacfd8c",
"text": "Lower your eyes and turn your body toward the left"
}
]
},
"0905c924562b": {
"stage": "FORK_IN_FOREST",
"tint": null,
"backdrop": "clearing",
"label": "FORK_IN_FOREST",
"options": [
{
"id": "fad9b2b701",
"text": "Approach the orange dragon"
},
{
"id": "4003505565",
"text": "Approach the brown dragon"
}
]
},
"0a561d53ad19": {
"stage": "THORN_WALK",
"tint": null,
"backdrop": "clearing",
"label": "An hour later: valley or tree",
"options": [
{
"id": "f0700810bf",
"text": "Continue toward the center of the valley"
},
{
"id": "7276f2fd9a",
"text": "Find the tallest tree and climb for a better view"
}
]
},
"0cfd06cf8939": {
"stage": "SCREAM_AND_CADETS",
"tint": null,
"backdrop": "forest",
"label": "After the fight: choose a direction",
"options": [
{
"id": "d79c512261",
"text": "Walk toward the east"
},
{
"id": "cfe44a775d",
"text": "Walk toward the west"
},
{
"id": "3929adfa07",
"text": "Walk farther into the forest"
}
]
},
"10bc7353b8eb": {
"stage": "FORK_IN_FOREST",
"tint": "red",
"backdrop": "clearing",
"label": "Descended quickly: a Red below",
"options": [
{
"id": "714e3abd94",
"text": "Reds are too hot-tempered. You’d rather take your chance with that green"
},
{
"id": "2991a60b20",
"text": "Jump in a few seconds and you’ll land closer to its tail, farther from the teeth"
},
{
"id": "40c171677e",
"text": "Jump now, and you can land on its back"
}
]
},
"13673f2461a1": {
"stage": "SCREAM_AND_CADETS",
"tint": null,
"backdrop": "forest",
"label": "SCREAM_AND_CADETS",
"options": [
{
"id": "1477a0f34f",
"text": "Keep going. Clearly they’ve been found lacking and weak riders threaten the wing"
},
{
"id": "2de42c6660",
"text": "Take the cadet’s weapons and continue along your way. Good steel shouldn’t go to waste"
},
{
"id": "8cf4b0cf60",
"text": "Use the cadet’s own belt as a tourniquet to staunch the blood flow and wait for a wingleader to come along"
}
]
},
"3f5d4c880fa9": {
"stage": "MEADOW_ENCOUNTER",
"tint": "brown",
"backdrop": "clearing",
"label": "MEADOW_ENCOUNTER · brown",
"options": [
{
"id": "f1aaea7f76",
"text": "You point out that it’s already talking to you, so clearly you’re on the right track"
},
{
"id": "ef5d1b474e",
"text": "You’ll respect its decision and hope for a clean death"
},
{
"id": "aed44971b9",
"text": "You’ll convince it with charm"
}
]
},
"4118582c85df": {
"stage": "TARGET_BONDING",
"tint": "blue",
"backdrop": "clearing",
"label": "TARGET_BONDING · blue",
"options": [
{
"id": "7d7788a891",
"text": "Hold the blue’s glare and advance"
},
{
"id": "06a35668b0",
"text": "Keep moving forward with your eyes lowered"
},
{
"id": "6a855c9d5c",
"text": "Halt your approach and lower your eyes"
}
]
},
"4f4ae4c4e49a": {
"stage": "MEADOW_ENCOUNTER",
"tint": "orange",
"backdrop": "clearing",
"label": "MEADOW_ENCOUNTER · orange",
"options": [
{
"id": "c95309baca",
"text": "Take a chance and try a tail-mount"
}
]
},
"545578ddbe46": {
"stage": "ENTER_THRESHING",
"tint": null,
"backdrop": "forest",
"label": "ENTER_THRESHING",
"options": [
{
"id": "1147432132",
"text": "Convince them to head east instead"
},
{
"id": "5501c1635f",
"text": "Go west with your squadmate"
},
{
"id": "81dae2ed4f",
"text": "Leave your squadmate"
}
]
},
"5b2713be89b2": {
"stage": "MEADOW_ENCOUNTER",
"tint": "orange",
"backdrop": "clearing",
"label": "MEADOW_ENCOUNTER · orange",
"options": [
{
"id": "31b348db0c",
"text": "On second thought, a nice brown sounds great"
},
{
"id": "900576c438",
"text": "Absolutely. I have a feeling this is my dragon"
}
]
},
"5ddaca4ebf6c": {
"stage": "TARGET_BONDING",
"tint": "blue",
"backdrop": "clearing",
"label": "TARGET_BONDING · blue",
"options": [
{
"id": "3f99a5c45d",
"text": "Do nothing. It’s worked so far"
},
{
"id": "b67f49441d",
"text": "Speak first, claiming the dragon as yours"
},
{
"id": "8d768b0ef2",
"text": "Straighten your spine and wait for it to speak"
}
]
},
"69c5b0e2b790": {
"stage": "ENTER_THRESHING",
"tint": "orange",
"backdrop": "forest",
"label": "ENTER_THRESHING · orange",
"options": [
{
"id": "a137e8047c",
"text": "Duck behind a boulder"
},
{
"id": "b98b30e96d",
"text": "Lower your eyes in respect and retreat"
},
{
"id": "ddad2bafb4",
"text": "Approach with confidence"
}
]
},
"6b8a5625b88d": {
"stage": "FORK_IN_FOREST",
"tint": "red",
"backdrop": "clearing",
"label": "FORK_IN_FOREST · red",
"options": [
{
"id": "1a981e7715",
"text": "You’re absolutely sure"
},
{
"id": "e99d6c3481",
"text": "On second thought, let’s get out of here"
}
]
},
"78afc925529f": {
"stage": "FORK_IN_FOREST",
"tint": "brown",
"backdrop": "clearing",
"label": "FORK_IN_FOREST · brown",
"options": [
{
"id": "b2a9ecfcd0",
"text": "Ehh. On second thought, maybe it won’t see if you change direction"
},
{
"id": "70a4f53a6d",
"text": "You’re sure. The heart doesn’t lie, and it’s set on that brown"
}
]
},
"792fc5ad90c3": {
"stage": "MEADOW_ENCOUNTER",
"tint": "brown",
"backdrop": "clearing",
"label": "MEADOW_ENCOUNTER · brown",
"options": [
{
"id": "b4d31960c6",
"text": "Immediately throw your body weight onto the tail and hold on for dear life"
},
{
"id": "732901a659",
"text": "Wait for the tail to return for a more advantageous angle"
}
]
},
"84780dab01e3": {
"stage": "FIRST_SIGHTING",
"tint": "red",
"backdrop": "forest",
"label": "Survived the first sighting",
"options": [
{
"id": "6913c7fb2c",
"text": "Head deeper into the forest"
}
]
},
"848f03f8f298": {
"stage": "TARGET_BONDING",
"tint": "blue",
"backdrop": "clearing",
"label": "TARGET_BONDING · blue",
"options": [
{
"id": "7d771616e4",
"text": "No. I have better odds with the orange"
},
{
"id": "78b3ba405f",
"text": "Absolutely. My whole life hinges on this moment"
},
{
"id": "f0e858698f",
"text": "Nope. I’d rather live bonded to a brown than die pursuing a blue"
}
]
},
"900d49229a84": {
"stage": "FORK_IN_FOREST",
"tint": null,
"backdrop": "clearing",
"label": "FORK_IN_FOREST",
"options": [
{
"id": "4003505565",
"text": "Approach the brown dragon"
},
{
"id": "fad9b2b701",
"text": "Approach the orange dragon"
},
{
"id": "4bbcb73ed1",
"text": "Approach the blue dragon"
}
]
},
"959e965095c3": {
"stage": "TARGET_BONDING",
"tint": "blue",
"backdrop": "clearing",
"label": "TARGET_BONDING · blue",
"options": [
{
"id": "0f1d136c69",
"text": "Launch yourself to the right, taking cover behind a boulder"
},
{
"id": "442a0fc4eb",
"text": "Hold steady, fear will get you killed"
}
]
},
"96b68612eaf4": {
"stage": "FORK_IN_FOREST",
"tint": null,
"backdrop": "clearing",
"label": "Top of the tree (shadow check)",
"options": [
{
"id": "c71ea9e2b6",
"text": "Descend quickly in preparation for whatever’s coming your way"
},
{
"id": "2c5af7e978",
"text": "Climb down slowly to pursue the green"
}
]
},
"9dc9518d8c84": {
"stage": "FORK_IN_FOREST",
"tint": "green",
"backdrop": "clearing",
"label": "FORK_IN_FOREST · green",
"options": [
{
"id": "fe2406af4e",
"text": "Glance over at the dragon on the right, keeping situational awareness"
},
{
"id": "6c7e2bb27b",
"text": "Don’t move a muscle"
}
]
},
"a2368b0dc212": {
"stage": "SCREAM_AND_CADETS",
"tint": null,
"backdrop": "forest",
"label": "Blocked the bigger cadet: bullies’ fate",
"options": [
{
"id": "2fba1113c6",
"text": "Leave the bullies alive. The dragons will sort them out"
},
{
"id": "43fb669800",
"text": "End the lives of the bullies yourself"
},
{
"id": "e579a5cd9f",
"text": "Allow your squadmate to exact their own revenge"
}
]
},
"a68f681076c6": {
"stage": "ENTER_THRESHING",
"tint": null,
"backdrop": "forest",
"label": "Valley edge: choose direction",
"options": [
{
"id": "5f7eefac34",
"text": "Head east toward the roar"
},
{
"id": "9c613e0d47",
"text": "Head west toward the scent"
},
{
"id": "05d19abb5d",
"text": "Head toward the center of the forest"
}
]
},
"ab2da0553abf": {
"stage": "ENTER_THRESHING",
"tint": null,
"backdrop": "forest",
"label": "ENTER_THRESHING",
"options": [
{
"id": "44095be371",
"text": "Go east with your squad"
},
{
"id": "eaf6e41387",
"text": "Leave your squadmates"
},
{
"id": "55fe423f15",
"text": "Convince them to head west instead"
}
]
},
"abe3011378ac": {
"stage": "ENTER_THRESHING",
"tint": "brown",
"backdrop": "forest",
"label": "First sighting: Brown (forest centre)",
"options": [
{
"id": "1c97464061",
"text": "Run and hope it didn’t see you"
},
{
"id": "bab6a76e8b",
"text": "Lower your eyes and hold still"
},
{
"id": "f6fc843ffc",
"text": "Lower your eyes and turn to face it"
}
]
},
"afc48a9ae27f": {
"stage": "TARGET_BONDING",
"tint": "blue",
"backdrop": "clearing",
"label": "TARGET_BONDING · blue",
"options": [
{
"id": "bdbd932924",
"text": "Do nothing"
},
{
"id": "5a76aa2e2f",
"text": "Intervene and help"
}
]
},
"b209bacacec3": {
"stage": "SCREAM_AND_CADETS",
"tint": null,
"backdrop": "forest",
"label": "Bully fight: first move",
"options": [
{
"id": "6dc46afcb2",
"text": "Pause to assess the situation even though it may risk your squadmate’s life"
},
{
"id": "483000d9b9",
"text": "Charge the other cadet to even out the numbers"
},
{
"id": "249cab536f",
"text": "Unsheathe your weapon and charge between the bigger cadet and your squadmate"
}
]
},
"b637d4115786": {
"stage": "ENTER_THRESHING",
"tint": "green",
"backdrop": "forest",
"label": "ENTER_THRESHING · green",
"options": [
{
"id": "ad4f3fb6f4",
"text": "Lower your eyes and hold your ground"
},
{
"id": "911bbead41",
"text": "Approach from the left"
},
{
"id": "04c3fb524d",
"text": "Stare at the ground and drop the weapon"
}
]
},
"b7e1483dd17a": {
"stage": "FORK_IN_FOREST",
"tint": "green",
"backdrop": "clearing",
"label": "FORK_IN_FOREST · green",
"options": [
{
"id": "fbc43edf79",
"text": "You overextend yourself constantly"
},
{
"id": "cda997fd10",
"text": "Your lack of flaws is a flaw itself"
},
{
"id": "8bd1cc6042",
"text": "You’re pretty certain you’re always right… even when you’re wrong"
},
{
"id": "92e06f9e6b",
"text": "Your struggle with your temper"
}
]
},
"b98aff0fa16a": {
"stage": "TARGET_BONDING",
"tint": "blue",
"backdrop": "clearing",
"label": "TARGET_BONDING · blue",
"options": [
{
"id": "6bde02709a",
"text": "Seize the opportunity to mount"
},
{
"id": "f93b47698d",
"text": "Stand strong, waiting for an invitation"
},
{
"id": "7d564d5caf",
"text": "Move forward slowly, waiting for an invitation"
}
]
},
"bbc8a53dc679": {
"stage": "ENTER_THRESHING",
"tint": null,
"backdrop": "forest",
"label": "ENTER_THRESHING",
"options": [
{
"id": "05d19abb5d",
"text": "Head toward the center of the forest"
},
{
"id": "5f7eefac34",
"text": "Head east toward the roar"
},
{
"id": "9c613e0d47",
"text": "Head west toward the scent"
}
]
},
"bc4ee4754b9c": {
"stage": "ENTER_THRESHING",
"tint": "red",
"backdrop": "forest",
"label": "First sighting: Red (forest centre)",
"options": [
{
"id": "a31cbcb659",
"text": "Lower your eyes in respect"
},
{
"id": "14181c8e32",
"text": "Show your bravery by meeting its gaze"
},
{
"id": "1859b3cd4a",
"text": "Hide behind a tree"
}
]
},
"c62f1f1a2b3a": {
"stage": "FORK_IN_FOREST",
"tint": "green",
"backdrop": "clearing",
"label": "Let the Red pass: two Greens in the clearing",
"options": [
{
"id": "d7f4b4e9da",
"text": "Lower your eyes and turn your body toward the right"
},
{
"id": "bafcacfd8c",
"text": "Lower your eyes and turn your body toward the left"
},
{
"id": "9da997c847",
"text": "Lower your eyes but keep your body neutral, letting them decide"
}
]
},
"d25f2759ace0": {
"stage": "FIRST_SIGHTING",
"tint": null,
"backdrop": "forest",
"label": "Deeper in the forest: a scream",
"options": [
{
"id": "2b6d16a461",
"text": "Investigate the scream"
},
{
"id": "8e03986d31",
"text": "Keep walking. The cadets are just as dangerous as the dragons today"
}
]
},
"db7786392626": {
"stage": "ENTER_THRESHING",
"tint": null,
"backdrop": "forest",
"label": "Start: choose company",
"options": [
{
"id": "571af425c8",
"text": "Enter the valley with two of your squadmates"
},
{
"id": "3da794f136",
"text": "Enter the valley with one of your squadmates"
},
{
"id": "c18f80dd1e",
"text": "Enter the valley alone"
}
]
},
"ea9997720545": {
"stage": "TARGET_BONDING",
"tint": "blue",
"backdrop": "clearing",
"label": "TARGET_BONDING · blue",
"options": [
{
"id": "ea7c0027e7",
"text": "Lower your eyes for the cadet’s dignity"
},
{
"id": "973f57cd35",
"text": "Show your honor by helping the cadet"
},
{
"id": "80e3020dea",
"text": "Hold the dragon’s glare and watch as it crushes the cadet to death"
}
]
},
"f0fb1451568a": {
"stage": "FORK_IN_FOREST",
"tint": "green",
"backdrop": "clearing",
"label": "FORK_IN_FOREST · green",
"options": [
{
"id": "6e46acb832",
"text": "Don’t move a muscle. Holding your ground is imperative"
},
{
"id": "f50fb7bd4c",
"text": "Take a single step back. Getting speared won’t get you bonded"
}
]
},
"f0fc086c6590": {
"stage": "FORK_IN_FOREST",
"tint": "red",
"backdrop": "clearing",
"label": "FORK_IN_FOREST · red",
"options": [
{
"id": "871b243a92",
"text": "Continue your approach. You’re certain this is your path"
},
{
"id": "8e79717d1b",
"text": "That growl changes everything, and it’s time to exit gracefully"
}
]
},
"f4b4944d3f3b": {
"stage": "SCREAM_AND_CADETS",
"tint": null,
"backdrop": "forest",
"label": "Beat the smaller cadet: bullies’ fate",
"options": [
{
"id": "e579a5cd9f",
"text": "Allow your squadmate to exact their own revenge"
},
{
"id": "43fb669800",
"text": "End the lives of the bullies yourself"
},
{
"id": "2fba1113c6",
"text": "Leave the bullies alive. The dragons will sort them out"
}
]
},
"f72199f24b91": {
"stage": "SCREAM_AND_CADETS",
"tint": null,
"backdrop": "forest",
"label": "Clearing: squadmate vs two bullies",
"options": [
{
"id": "c5719ec9a7",
"text": "Help your squadmate"
},
{
"id": "5e4947fde1",
"text": "Play it safe and leave them to their own defense so you can find your dragon"
}
]
},
"f82683b20f3b": {
"stage": "FORK_IN_FOREST",
"tint": "brown",
"backdrop": "clearing",
"label": "FORK_IN_FOREST · brown",
"options": [
{
"id": "8b53b3dfbf",
"text": "Run after the brown dragon"
},
{
"id": "939b596a85",
"text": "Try your luck with the remaining orange"
}
]
},
"f8b8d90014f1": {
"stage": "TARGET_BONDING",
"tint": "blue",
"backdrop": "clearing",
"label": "TARGET_BONDING · blue",
"options": [
{
"id": "1437cd23ea",
"text": "I want to bring down an empire"
},
{
"id": "2237667d16",
"text": "You already know"
},
{
"id": "cf4766824b",
"text": "I seek revenge"
},
{
"id": "16ca950973",
"text": "I want to defend the helpless"
}
]
},
"fbe0f0bea700": {
"stage": "SCREAM_AND_CADETS",
"tint": null,
"backdrop": "forest",
"label": "Bully fight: smaller cadet has a dagger",
"options": [
{
"id": "40b2e3202f",
"text": "Daggers or not, your squadmate is in danger, so you charge the bigger cadet"
},
{
"id": "dd20bac96c",
"text": "Engage the smaller cadet"
}
]
}
}
File diff suppressed because one or more lines are too long
@@ -0,0 +1,6 @@
{"id":"bot-288b72e52f","source":"bot","meta":{"attempt":2,"startedAt":"2026-10-29T16:25:29.185Z","accountKey":null,"target":null,"decisionMode":null},"steps":[{"scene":"a68f681076c6","stage":"ENTER_THRESHING","tint":null,"option":"05d19abb5d","optionText":"Head toward the center of the forest","offered":["5f7eefac34","9c613e0d47","05d19abb5d"],"rule":"ENTER_TOWARDS_FOREST_CENTER","decisionMode":null,"manual":false,"at":"2026-10-29T16:25:29.185Z","to":"bc4ee4754b9c"},{"scene":"bc4ee4754b9c","stage":"FIRST_SIGHTING","tint":"red","option":"a31cbcb659","optionText":"Lower your eyes in respect","offered":["a31cbcb659","14181c8e32","1859b3cd4a"],"rule":"SIGHTING_LOWER_EYES_RESPECT","decisionMode":null,"manual":false,"at":"2026-10-29T16:25:31.387Z","to":"84780dab01e3"},{"scene":"84780dab01e3","stage":"ENTER_THRESHING","tint":"red","option":"6913c7fb2c","optionText":"Head deeper into the forest","offered":["6913c7fb2c"],"rule":"SINGLE_CHOICE_ADVANCE","decisionMode":"guide","manual":false,"at":"2026-10-29T19:55:36.225Z","to":"d25f2759ace0"},{"scene":"d25f2759ace0","stage":"SCREAM_AND_CADETS","tint":null,"option":"2b6d16a461","optionText":"Investigate the scream","offered":["2b6d16a461","8e03986d31"],"rule":"SCREAM_INVESTIGATE","decisionMode":"guide","manual":false,"at":"2026-10-29T19:55:38.219Z","to":"f72199f24b91"},{"scene":"f72199f24b91","stage":"BLUE_DRAGON_ROUTE","tint":null,"option":"c5719ec9a7","optionText":"Help your squadmate","offered":["c5719ec9a7","5e4947fde1"],"rule":"BLUE_7_HELP_CADET","decisionMode":"guide","manual":false,"at":"2026-10-29T19:55:45.720Z","to":"b209bacacec3"},{"scene":"b209bacacec3","stage":"SCREAM_AND_CADETS","tint":null,"option":"6dc46afcb2","optionText":"Pause to assess the situation even though it may risk your squadmate’s life","offered":["6dc46afcb2","483000d9b9","249cab536f"],"rule":null,"decisionMode":"manual","manual":true,"at":"2026-10-29T19:56:20.518Z","to":"fbe0f0bea700"},{"scene":"fbe0f0bea700","stage":"SCREAM_AND_CADETS","tint":null,"option":"40b2e3202f","optionText":"Daggers or not, your squadmate is in danger, so you charge the bigger cadet","offered":["40b2e3202f","dd20bac96c"],"rule":null,"decisionMode":"manual","manual":true,"at":"2026-10-29T19:56:29.785Z","to":"a2368b0dc212"},{"scene":"a2368b0dc212","stage":"SCREAM_AND_CADETS","tint":null,"option":"43fb669800","optionText":"End the lives of the bullies yourself","offered":["2fba1113c6","43fb669800","e579a5cd9f"],"rule":null,"decisionMode":"manual","manual":true,"at":"2026-10-29T19:56:36.498Z","to":"0cfd06cf8939"},{"scene":"0cfd06cf8939","stage":"SCREAM_AND_CADETS","tint":null,"option":"3929adfa07","optionText":"Walk farther into the forest","offered":["d79c512261","cfe44a775d","3929adfa07"],"rule":null,"decisionMode":"manual","manual":true,"at":"2026-10-29T19:56:42.280Z","to":"0a561d53ad19"},{"scene":"0a561d53ad19","stage":"THORN_WALK","tint":null,"option":"7276f2fd9a","optionText":"Find the tallest tree and climb for a better view","offered":["f0700810bf","7276f2fd9a"],"rule":null,"decisionMode":"manual","manual":true,"at":"2026-10-29T19:56:51.226Z","to":"96b68612eaf4"},{"scene":"96b68612eaf4","stage":"FORK_IN_FOREST","tint":null,"option":"c71ea9e2b6","optionText":"Descend quickly in preparation for whatever’s coming your way","offered":["c71ea9e2b6","2c5af7e978"],"rule":null,"decisionMode":"manual","manual":true,"at":"2026-10-29T19:57:01.275Z","to":"10bc7353b8eb"},{"scene":"10bc7353b8eb","stage":"FORK_IN_FOREST","tint":"red","option":"2991a60b20","optionText":"Jump in a few seconds and you’ll land closer to its tail, farther from the teeth","offered":["714e3abd94","2991a60b20","40c171677e"],"rule":null,"decisionMode":"manual","manual":true,"at":"2026-10-29T19:57:08.857Z","to":"BURNED"}],"outcome":{"type":"BURNED","colour":null,"intentional":false}}
{"id":"bot-a181b520f1","source":"bot","meta":{"attempt":3,"startedAt":"2026-10-30T01:21:31.420Z","accountKey":null,"target":null,"decisionMode":null},"steps":[{"scene":"db7786392626","stage":"ENTER_THRESHING","tint":null,"option":"c18f80dd1e","optionText":"Enter the valley alone","offered":["571af425c8","3da794f136","c18f80dd1e"],"rule":"ENTER_GO_ALONE","decisionMode":"guide","manual":false,"at":"2026-10-30T01:21:31.420Z","to":"a68f681076c6"},{"scene":"a68f681076c6","stage":"ENTER_THRESHING","tint":null,"option":"05d19abb5d","optionText":"Head toward the center of the forest","offered":["05d19abb5d","9c613e0d47","5f7eefac34"],"rule":"ENTER_TOWARDS_FOREST_CENTER","decisionMode":"guide","manual":false,"at":"2026-10-30T01:21:34.893Z","to":"bc4ee4754b9c"},{"scene":"bc4ee4754b9c","stage":"FIRST_SIGHTING","tint":"red","option":"a31cbcb659","optionText":"Lower your eyes in respect","offered":["14181c8e32","a31cbcb659","1859b3cd4a"],"rule":"SIGHTING_LOWER_EYES_RESPECT","decisionMode":"guide","manual":false,"at":"2026-10-30T01:21:38.316Z","to":"84780dab01e3"},{"scene":"84780dab01e3","stage":"FIRST_SIGHTING","tint":"red","option":"6913c7fb2c","optionText":"Head deeper into the forest","offered":["6913c7fb2c"],"rule":"SINGLE_CHOICE_ADVANCE","decisionMode":"guide","manual":false,"at":"2026-10-30T01:21:41.767Z","to":"d25f2759ace0"},{"scene":"d25f2759ace0","stage":"SCREAM_AND_CADETS","tint":null,"option":"2b6d16a461","optionText":"Investigate the scream","offered":["2b6d16a461","8e03986d31"],"rule":"SCREAM_INVESTIGATE","decisionMode":"guide","manual":false,"at":"2026-10-30T01:21:45.219Z","to":"f72199f24b91"},{"scene":"f72199f24b91","stage":"SCREAM_AND_CADETS","tint":null,"option":"c5719ec9a7","optionText":"Help your squadmate","offered":["c5719ec9a7","5e4947fde1"],"rule":"BULLY_1_HELP_THEM","decisionMode":"guide","manual":false,"at":"2026-10-30T01:21:48.695Z","to":"b209bacacec3"},{"scene":"b209bacacec3","stage":"BLUE_DRAGON_ROUTE","tint":null,"option":"6dc46afcb2","optionText":"Pause to assess the situation even though it may risk your squadmate’s life","offered":["483000d9b9","249cab536f","6dc46afcb2"],"rule":"LEARNED_EDGE","decisionMode":"learned","manual":false,"at":"2026-10-30T01:21:52.196Z","to":"fbe0f0bea700"},{"scene":"fbe0f0bea700","stage":"BLUE_DRAGON_ROUTE","tint":null,"option":"40b2e3202f","optionText":"Daggers or not, your squadmate is in danger, so you charge the bigger cadet","offered":["40b2e3202f","dd20bac96c"],"rule":"LEARNED_DASHBOARD","decisionMode":"learned","manual":false,"at":"2026-10-30T01:21:55.696Z","to":"a2368b0dc212"},{"scene":"a2368b0dc212","stage":"BLUE_DRAGON_ROUTE","tint":null,"option":"43fb669800","optionText":"End the lives of the bullies yourself","offered":["e579a5cd9f","43fb669800","2fba1113c6"],"rule":"LEARNED_DASHBOARD","decisionMode":"learned","manual":false,"at":"2026-10-30T01:22:00.378Z","to":"0cfd06cf8939"},{"scene":"0cfd06cf8939","stage":"BLUE_DRAGON_ROUTE","tint":null,"option":"3929adfa07","optionText":"Walk farther into the forest","offered":["cfe44a775d","d79c512261","3929adfa07"],"rule":"LEARNED_DASHBOARD","decisionMode":"learned","manual":false,"at":"2026-10-30T01:22:03.881Z","to":"0a561d53ad19"},{"scene":"0a561d53ad19","stage":"THORN_WALK","tint":null,"option":"7276f2fd9a","optionText":"Find the tallest tree and climb for a better view","offered":["7276f2fd9a","f0700810bf"],"rule":"LEARNED_DASHBOARD","decisionMode":"learned","manual":false,"at":"2026-10-30T01:22:08.585Z","to":"96b68612eaf4"},{"scene":"96b68612eaf4","stage":"FORK_IN_FOREST","tint":null,"option":"c71ea9e2b6","optionText":"Descend quickly in preparation for whatever’s coming your way","offered":["2c5af7e978","c71ea9e2b6"],"rule":"LEARNED_DASHBOARD","decisionMode":"learned","manual":false,"at":"2026-10-30T01:22:13.279Z","to":"10bc7353b8eb"},{"scene":"10bc7353b8eb","stage":"INTENTIONAL_BURN","tint":"red","option":"714e3abd94","optionText":"Reds are too hot-tempered. You’d rather take your chance with that green","offered":["714e3abd94","40c171677e","2991a60b20"],"rule":"RED_TREE_DIVERT_GREEN_FOR_SAFE_BURN","decisionMode":"guide","manual":false,"at":"2026-10-30T01:22:16.740Z","to":"c62f1f1a2b3a"},{"scene":"c62f1f1a2b3a","stage":"INTENTIONAL_BURN","tint":"green","option":"9da997c847","optionText":"Lower your eyes but keep your body neutral, letting them decide","offered":["d7f4b4e9da","bafcacfd8c","9da997c847"],"rule":"BURN_GUARANTEED_INCINERATION","decisionMode":"guide","manual":false,"at":"2026-10-30T01:22:21.450Z","to":"BURNED"}],"outcome":{"type":"BURNED","colour":null,"intentional":true}}
{"id":"bot-bb707b0816","source":"bot","meta":{"attempt":4,"startedAt":"2026-10-30T12:31:02.233Z","accountKey":null,"target":null,"decisionMode":null},"steps":[{"scene":"db7786392626","stage":"ENTER_THRESHING","tint":null,"option":"c18f80dd1e","optionText":"Enter the valley alone","offered":["571af425c8","c18f80dd1e","3da794f136"],"rule":"ENTER_GO_ALONE","decisionMode":"guide","manual":false,"at":"2026-10-30T12:31:02.233Z","to":"a68f681076c6"},{"scene":"a68f681076c6","stage":"ENTER_THRESHING","tint":null,"option":"05d19abb5d","optionText":"Head toward the center of the forest","offered":["5f7eefac34","05d19abb5d","9c613e0d47"],"rule":"ENTER_TOWARDS_FOREST_CENTER","decisionMode":"guide","manual":false,"at":"2026-10-30T12:31:05.712Z","to":"abe3011378ac"},{"scene":"abe3011378ac","stage":"FIRST_SIGHTING","tint":"brown","option":"bab6a76e8b","optionText":"Lower your eyes and hold still","offered":["1c97464061","bab6a76e8b","f6fc843ffc"],"rule":"SIGHTING_BROWN_A_HOLD_STILL","decisionMode":"guide","manual":false,"at":"2026-10-30T12:31:09.211Z","to":"84780dab01e3"},{"scene":"84780dab01e3","stage":"FIRST_SIGHTING","tint":"red","option":"6913c7fb2c","optionText":"Head deeper into the forest","offered":["6913c7fb2c"],"rule":"SINGLE_CHOICE_ADVANCE","decisionMode":"guide","manual":false,"at":"2026-10-30T12:31:12.622Z","to":"d25f2759ace0"},{"scene":"d25f2759ace0","stage":"SCREAM_AND_CADETS","tint":null,"option":"2b6d16a461","optionText":"Investigate the scream","offered":["8e03986d31","2b6d16a461"],"rule":"SCREAM_INVESTIGATE","decisionMode":"guide","manual":false,"at":"2026-10-30T12:31:16.054Z","to":"f72199f24b91"},{"scene":"f72199f24b91","stage":"SCREAM_AND_CADETS","tint":null,"option":"c5719ec9a7","optionText":"Help your squadmate","offered":["c5719ec9a7","5e4947fde1"],"rule":"BULLY_1_HELP_THEM","decisionMode":"guide","manual":false,"at":"2026-10-30T12:31:19.501Z","to":"b209bacacec3"},{"scene":"b209bacacec3","stage":"SCREAM_AND_CADETS","tint":null,"option":"6dc46afcb2","optionText":"Pause to assess the situation even though it may risk your squadmate’s life","offered":["249cab536f","483000d9b9","6dc46afcb2"],"rule":"BULLY_2_ASSESS_SITUATION","decisionMode":"guide","manual":false,"at":"2026-10-30T12:31:22.943Z","to":"fbe0f0bea700"},{"scene":"fbe0f0bea700","stage":"SCREAM_AND_CADETS","tint":null,"option":"dd20bac96c","optionText":"Engage the smaller cadet","offered":["40b2e3202f","dd20bac96c"],"rule":"BULLY_3_ENGAGE_SMALLER","decisionMode":"guide","manual":false,"at":"2026-10-30T12:31:26.363Z","to":"f4b4944d3f3b"},{"scene":"f4b4944d3f3b","stage":"SCREAM_AND_CADETS","tint":null,"option":"43fb669800","optionText":"End the lives of the bullies yourself","offered":["e579a5cd9f","43fb669800","2fba1113c6"],"rule":"BULLY_4_KILL_BULLIES","decisionMode":"guide","manual":false,"at":"2026-10-30T12:31:31.012Z","to":"0cfd06cf8939"},{"scene":"0cfd06cf8939","stage":"SCREAM_AND_CADETS","tint":null,"option":"3929adfa07","optionText":"Walk farther into the forest","offered":["cfe44a775d","d79c512261","3929adfa07"],"rule":"ROAD_FORK_DEEPER_FOREST","decisionMode":"guide","manual":false,"at":"2026-10-30T12:31:34.462Z","to":"0a561d53ad19"},{"scene":"0a561d53ad19","stage":"FORK_IN_FOREST","tint":null,"option":"7276f2fd9a","optionText":"Find the tallest tree and climb for a better view","offered":["f0700810bf","7276f2fd9a"],"rule":"FORK_CLIMB_TALLEST_TREE","decisionMode":"guide","manual":false,"at":"2026-10-30T12:31:39.140Z","to":"96b68612eaf4"},{"scene":"96b68612eaf4","stage":"TREE_SHADOW_CHECK","tint":null,"option":"2c5af7e978","optionText":"Climb down slowly to pursue the green","offered":["c71ea9e2b6","2c5af7e978"],"rule":"TREE_NO_SHADOW_AUTO_BURN","decisionMode":"guide","manual":false,"at":"2026-10-30T12:31:43.809Z","to":"07e24681e3b3"},{"scene":"07e24681e3b3","stage":"INTENTIONAL_BURN","tint":"green","option":"9da997c847","optionText":"Lower your eyes but keep your body neutral, letting them decide","offered":["d7f4b4e9da","9da997c847","bafcacfd8c"],"rule":"BURN_GUARANTEED_INCINERATION","decisionMode":"guide","manual":false,"at":"2026-10-30T12:31:49.673Z","to":"BURNED"}],"outcome":{"type":"BURNED","colour":null,"intentional":true}}
{"id":"bot-7e96467867","source":"bot","meta":{"attempt":5,"startedAt":"2026-10-30T16:32:01.623Z","accountKey":null,"target":"black","decisionMode":"auto_learn","policyId":null,"experimentId":null,"arm":null},"steps":[{"scene":"db7786392626","stage":"ENTER_THRESHING","tint":null,"option":"c18f80dd1e","optionText":"Enter the valley alone","offered":["c18f80dd1e","3da794f136","571af425c8"],"rule":"ENTER_GO_ALONE","decisionMode":"guide","manual":false,"at":"2026-10-30T16:32:01.623Z","to":"a68f681076c6"},{"scene":"a68f681076c6","stage":"ENTER_THRESHING","tint":null,"option":"05d19abb5d","optionText":"Head toward the center of the forest","offered":["5f7eefac34","9c613e0d47","05d19abb5d"],"rule":"ENTER_TOWARDS_FOREST_CENTER","decisionMode":"guide","manual":false,"at":"2026-10-30T16:32:05.186Z","to":"bc4ee4754b9c"},{"scene":"bc4ee4754b9c","stage":"FIRST_SIGHTING","tint":"red","option":"a31cbcb659","optionText":"Lower your eyes in respect","offered":["a31cbcb659","14181c8e32","1859b3cd4a"],"rule":"SIGHTING_LOWER_EYES_RESPECT","decisionMode":"guide","manual":false,"at":"2026-10-30T16:32:08.740Z","to":"84780dab01e3"},{"scene":"84780dab01e3","stage":"FIRST_SIGHTING","tint":"red","option":"6913c7fb2c","optionText":"Head deeper into the forest","offered":["6913c7fb2c"],"rule":"SINGLE_CHOICE_ADVANCE","decisionMode":"guide","manual":false,"at":"2026-10-30T16:32:12.292Z","to":"d25f2759ace0"},{"scene":"d25f2759ace0","stage":"SCREAM_AND_CADETS","tint":null,"option":"2b6d16a461","optionText":"Investigate the scream","offered":["8e03986d31","2b6d16a461"],"rule":"SCREAM_INVESTIGATE","decisionMode":"guide","manual":false,"at":"2026-10-30T16:32:15.815Z","to":"f72199f24b91"},{"scene":"f72199f24b91","stage":"SCREAM_AND_CADETS","tint":null,"option":"c5719ec9a7","optionText":"Help your squadmate","offered":["c5719ec9a7","5e4947fde1"],"rule":"BULLY_1_HELP_THEM","decisionMode":"guide","manual":false,"at":"2026-10-30T16:32:19.408Z","to":"b209bacacec3"},{"scene":"b209bacacec3","stage":"SCREAM_AND_CADETS","tint":null,"option":"6dc46afcb2","optionText":"Pause to assess the situation even though it may risk your squadmate’s life","offered":["249cab536f","6dc46afcb2","483000d9b9"],"rule":"BULLY_2_ASSESS_SITUATION","decisionMode":"guide","manual":false,"at":"2026-10-30T16:32:22.937Z","to":"fbe0f0bea700"},{"scene":"fbe0f0bea700","stage":"SCREAM_AND_CADETS","tint":null,"option":"dd20bac96c","optionText":"Engage the smaller cadet","offered":["dd20bac96c","40b2e3202f"],"rule":"BULLY_3_ENGAGE_SMALLER","decisionMode":"guide","manual":false,"at":"2026-10-30T16:32:26.473Z","to":"f4b4944d3f3b"},{"scene":"f4b4944d3f3b","stage":"SCREAM_AND_CADETS","tint":null,"option":"43fb669800","optionText":"End the lives of the bullies yourself","offered":["43fb669800","2fba1113c6","e579a5cd9f"],"rule":"BULLY_4_KILL_BULLIES","decisionMode":"guide","manual":false,"at":"2026-10-30T16:32:31.222Z","to":"0cfd06cf8939"},{"scene":"0cfd06cf8939","stage":"SCREAM_AND_CADETS","tint":null,"option":"3929adfa07","optionText":"Walk farther into the forest","offered":["3929adfa07","cfe44a775d","d79c512261"],"rule":"ROAD_FORK_DEEPER_FOREST","decisionMode":"guide","manual":false,"at":"2026-10-30T16:32:34.782Z","to":"0a561d53ad19"},{"scene":"0a561d53ad19","stage":"FORK_IN_FOREST","tint":null,"option":"7276f2fd9a","optionText":"Find the tallest tree and climb for a better view","offered":["7276f2fd9a","f0700810bf"],"rule":"FORK_CLIMB_TALLEST_TREE","decisionMode":"guide","manual":false,"at":"2026-10-30T16:32:39.593Z","to":"96b68612eaf4"},{"scene":"96b68612eaf4","stage":"TREE_SHADOW_CHECK","tint":null,"option":"2c5af7e978","optionText":"Climb down slowly to pursue the green","offered":["2c5af7e978","c71ea9e2b6"],"rule":"TREE_NO_SHADOW_AUTO_BURN","decisionMode":"guide","manual":false,"at":"2026-10-30T16:32:44.371Z","to":"07e24681e3b3"},{"scene":"07e24681e3b3","stage":"INTENTIONAL_BURN","tint":"green","option":"9da997c847","optionText":"Lower your eyes but keep your body neutral, letting them decide","offered":["9da997c847","d7f4b4e9da","bafcacfd8c"],"rule":"BURN_GUARANTEED_INCINERATION","decisionMode":"guide","manual":false,"at":"2026-10-30T16:32:50.391Z","to":"BURNED"}],"outcome":{"type":"BURNED","colour":null,"intentional":true}}
{"id":"bot-a4f8157ecf","source":"bot","meta":{"attempt":6,"startedAt":"2026-10-30T20:41:16.681Z","accountKey":null,"target":"black","decisionMode":"auto_learn","policyId":null,"experimentId":null,"arm":null},"steps":[{"scene":"db7786392626","stage":"ENTER_THRESHING","tint":null,"option":"c18f80dd1e","optionText":"Enter the valley alone","offered":["3da794f136","c18f80dd1e","571af425c8"],"rule":"ENTER_GO_ALONE","decisionMode":"guide","manual":false,"at":"2026-10-30T20:41:16.681Z","to":"a68f681076c6"},{"scene":"a68f681076c6","stage":"ENTER_THRESHING","tint":null,"option":"05d19abb5d","optionText":"Head toward the center of the forest","offered":["5f7eefac34","9c613e0d47","05d19abb5d"],"rule":"ENTER_TOWARDS_FOREST_CENTER","decisionMode":"guide","manual":false,"at":"2026-10-30T20:41:20.259Z","to":"abe3011378ac"},{"scene":"abe3011378ac","stage":"FIRST_SIGHTING","tint":"brown","option":"bab6a76e8b","optionText":"Lower your eyes and hold still","offered":["bab6a76e8b","f6fc843ffc","1c97464061"],"rule":"SIGHTING_BROWN_A_HOLD_STILL","decisionMode":"guide","manual":false,"at":"2026-10-30T20:41:23.740Z","to":"84780dab01e3"},{"scene":"84780dab01e3","stage":"FIRST_SIGHTING","tint":"red","option":"6913c7fb2c","optionText":"Head deeper into the forest","offered":["6913c7fb2c"],"rule":"SINGLE_CHOICE_ADVANCE","decisionMode":"guide","manual":false,"at":"2026-10-30T20:41:27.302Z","to":"d25f2759ace0"},{"scene":"d25f2759ace0","stage":"SCREAM_AND_CADETS","tint":null,"option":"2b6d16a461","optionText":"Investigate the scream","offered":["8e03986d31","2b6d16a461"],"rule":"SCREAM_INVESTIGATE","decisionMode":"guide","manual":false,"at":"2026-10-30T20:41:30.816Z","to":"f72199f24b91"},{"scene":"f72199f24b91","stage":"SCREAM_AND_CADETS","tint":null,"option":"c5719ec9a7","optionText":"Help your squadmate","offered":["c5719ec9a7","5e4947fde1"],"rule":"BULLY_1_HELP_THEM","decisionMode":"guide","manual":false,"at":"2026-10-30T20:41:34.353Z","to":"b209bacacec3"},{"scene":"b209bacacec3","stage":"SCREAM_AND_CADETS","tint":null,"option":"6dc46afcb2","optionText":"Pause to assess the situation even though it may risk your squadmate’s life","offered":["483000d9b9","6dc46afcb2","249cab536f"],"rule":"BULLY_2_ASSESS_SITUATION","decisionMode":"guide","manual":false,"at":"2026-10-30T20:41:37.937Z","to":"fbe0f0bea700"},{"scene":"fbe0f0bea700","stage":"SCREAM_AND_CADETS","tint":null,"option":"dd20bac96c","optionText":"Engage the smaller cadet","offered":["40b2e3202f","dd20bac96c"],"rule":"BULLY_3_ENGAGE_SMALLER","decisionMode":"guide","manual":false,"at":"2026-10-30T20:41:41.455Z","to":"f4b4944d3f3b"},{"scene":"f4b4944d3f3b","stage":"SCREAM_AND_CADETS","tint":null,"option":"43fb669800","optionText":"End the lives of the bullies yourself","offered":["43fb669800","2fba1113c6","e579a5cd9f"],"rule":"BULLY_4_KILL_BULLIES","decisionMode":"guide","manual":false,"at":"2026-10-30T20:41:46.182Z","to":"0cfd06cf8939"},{"scene":"0cfd06cf8939","stage":"SCREAM_AND_CADETS","tint":null,"option":"3929adfa07","optionText":"Walk farther into the forest","offered":["3929adfa07","cfe44a775d","d79c512261"],"rule":"ROAD_FORK_DEEPER_FOREST","decisionMode":"guide","manual":false,"at":"2026-10-30T20:41:49.692Z","to":"0a561d53ad19"},{"scene":"0a561d53ad19","stage":"FORK_IN_FOREST","tint":null,"option":"7276f2fd9a","optionText":"Find the tallest tree and climb for a better view","offered":["7276f2fd9a","f0700810bf"],"rule":"FORK_CLIMB_TALLEST_TREE","decisionMode":"guide","manual":false,"at":"2026-10-30T20:41:54.419Z","to":"96b68612eaf4"},{"scene":"96b68612eaf4","stage":"TREE_SHADOW_CHECK","tint":null,"option":"2c5af7e978","optionText":"Climb down slowly to pursue the green","offered":["2c5af7e978","c71ea9e2b6"],"rule":"TREE_NO_SHADOW_AUTO_BURN","decisionMode":"guide","manual":false,"at":"2026-10-30T20:41:59.186Z","to":"07e24681e3b3"},{"scene":"07e24681e3b3","stage":"INTENTIONAL_BURN","tint":"green","option":"9da997c847","optionText":"Lower your eyes but keep your body neutral, letting them decide","offered":["9da997c847","d7f4b4e9da","bafcacfd8c"],"rule":"BURN_GUARANTEED_INCINERATION","decisionMode":"guide","manual":false,"at":"2026-10-30T20:42:05.900Z","to":"BURNED"}],"outcome":{"type":"BURNED","colour":null,"intentional":true}}
{"id":"bot-c95f035604","source":"bot","meta":{"attempt":7,"startedAt":"2026-10-31T00:42:16.218Z","accountKey":null,"target":"black","decisionMode":"auto_learn","policyId":null,"experimentId":null,"arm":null},"steps":[{"scene":"db7786392626","stage":"ENTER_THRESHING","tint":null,"option":"c18f80dd1e","optionText":"Enter the valley alone","offered":["571af425c8","c18f80dd1e","3da794f136"],"rule":"ENTER_GO_ALONE","decisionMode":"guide","manual":false,"at":"2026-10-31T00:42:16.218Z","to":"a68f681076c6"},{"scene":"a68f681076c6","stage":"ENTER_THRESHING","tint":null,"option":"05d19abb5d","optionText":"Head toward the center of the forest","offered":["9c613e0d47","05d19abb5d","5f7eefac34"],"rule":"ENTER_TOWARDS_FOREST_CENTER","decisionMode":"guide","manual":false,"at":"2026-10-31T00:42:19.802Z","to":"bc4ee4754b9c"},{"scene":"bc4ee4754b9c","stage":"FIRST_SIGHTING","tint":"red","option":"a31cbcb659","optionText":"Lower your eyes in respect","offered":["a31cbcb659","1859b3cd4a","14181c8e32"],"rule":"SIGHTING_LOWER_EYES_RESPECT","decisionMode":"guide","manual":false,"at":"2026-10-31T00:42:23.442Z","to":"84780dab01e3"},{"scene":"84780dab01e3","stage":"FIRST_SIGHTING","tint":"red","option":"6913c7fb2c","optionText":"Head deeper into the forest","offered":["6913c7fb2c"],"rule":"SINGLE_CHOICE_ADVANCE","decisionMode":"guide","manual":false,"at":"2026-10-31T00:42:26.976Z","to":"d25f2759ace0"},{"scene":"d25f2759ace0","stage":"SCREAM_AND_CADETS","tint":null,"option":"2b6d16a461","optionText":"Investigate the scream","offered":["8e03986d31","2b6d16a461"],"rule":"SCREAM_INVESTIGATE","decisionMode":"guide","manual":false,"at":"2026-10-31T00:42:30.510Z","to":"f72199f24b91"},{"scene":"f72199f24b91","stage":"SCREAM_AND_CADETS","tint":null,"option":"c5719ec9a7","optionText":"Help your squadmate","offered":["c5719ec9a7","5e4947fde1"],"rule":"BULLY_1_HELP_THEM","decisionMode":"guide","manual":false,"at":"2026-10-31T00:42:34.122Z","to":"b209bacacec3"},{"scene":"b209bacacec3","stage":"SCREAM_AND_CADETS","tint":null,"option":"6dc46afcb2","optionText":"Pause to assess the situation even though it may risk your squadmate’s life","offered":["483000d9b9","6dc46afcb2","249cab536f"],"rule":"BULLY_2_ASSESS_SITUATION","decisionMode":"guide","manual":false,"at":"2026-10-31T00:42:37.643Z","to":"fbe0f0bea700"},{"scene":"fbe0f0bea700","stage":"SCREAM_AND_CADETS","tint":null,"option":"dd20bac96c","optionText":"Engage the smaller cadet","offered":["40b2e3202f","dd20bac96c"],"rule":"BULLY_3_ENGAGE_SMALLER","decisionMode":"guide","manual":false,"at":"2026-10-31T00:42:41.219Z","to":"f4b4944d3f3b"},{"scene":"f4b4944d3f3b","stage":"SCREAM_AND_CADETS","tint":null,"option":"43fb669800","optionText":"End the lives of the bullies yourself","offered":["43fb669800","2fba1113c6","e579a5cd9f"],"rule":"BULLY_4_KILL_BULLIES","decisionMode":"guide","manual":false,"at":"2026-10-31T00:42:46.033Z","to":"0cfd06cf8939"},{"scene":"0cfd06cf8939","stage":"SCREAM_AND_CADETS","tint":null,"option":"3929adfa07","optionText":"Walk farther into the forest","offered":["3929adfa07","d79c512261","cfe44a775d"],"rule":"ROAD_FORK_DEEPER_FOREST","decisionMode":"guide","manual":false,"at":"2026-10-31T00:42:50.332Z","to":"0a561d53ad19"},{"scene":"0a561d53ad19","stage":"FORK_IN_FOREST","tint":null,"option":"7276f2fd9a","optionText":"Find the tallest tree and climb for a better view","offered":["7276f2fd9a","f0700810bf"],"rule":"FORK_CLIMB_TALLEST_TREE","decisionMode":"guide","manual":false,"at":"2026-10-31T00:42:55.134Z","to":"96b68612eaf4"},{"scene":"96b68612eaf4","stage":"TREE_SHADOW_CHECK","tint":null,"option":"2c5af7e978","optionText":"Climb down slowly to pursue the green","offered":["c71ea9e2b6","2c5af7e978"],"rule":"TREE_NO_SHADOW_AUTO_BURN","decisionMode":"guide","manual":false,"at":"2026-10-31T00:42:59.963Z","to":"07e24681e3b3"},{"scene":"07e24681e3b3","stage":"INTENTIONAL_BURN","tint":"green","option":"9da997c847","optionText":"Lower your eyes but keep your body neutral, letting them decide","offered":["9da997c847","d7f4b4e9da","bafcacfd8c"],"rule":"BURN_GUARANTEED_INCINERATION","decisionMode":"guide","manual":false,"at":"2026-10-31T00:43:06.002Z","to":"BURNED"}],"outcome":{"type":"BURNED","colour":null,"intentional":true}}
+33 -68
View File
@@ -46,8 +46,8 @@
"conformsTo": "http://mlcommons.org/croissant/1.0",
"name": "Threshing Atlas",
"description": "Community-logged runs of the Dragonkind \"threshing\" (the dragon-bonding game based on Fourth Wing), coded into one record per run: every choice, what the game rolled, and how the run ended. Also the route model built from them, the statistics shown on the Threshing Atlas page, and the route graph shared with a DragonKind bot.",
"url": "https://git.kenschiano.net/DragonKind/threshing-atlas",
"sameAs": "https://git.kenschiano.net/DragonKind/threshing-atlas",
"url": "https://git.kenschiano.net/YOUR-GITEA-USERNAME/threshing-atlas",
"sameAs": "https://git.kenschiano.net/YOUR-GITEA-USERNAME/threshing-atlas",
"license": "https://creativecommons.org/licenses/by/4.0/",
"creator": {
"@type": "sc:Person",
@@ -61,38 +61,23 @@
"route planning",
"community data"
],
"citeAs": "ekcSchiano and contributors (2026). Threshing Atlas. https://git.kenschiano.net/DragonKind/threshing-atlas",
"citeAs": "ekcSchiano and contributors (2026). Threshing Atlas. https://git.kenschiano.net/YOUR-GITEA-USERNAME/threshing-atlas",
"isLiveDataset": true,
"isBasedOn": [
{
"@type": "sc:CreativeWork",
"url": "https://docs.google.com/spreadsheets/d/1gnw1AdRg1XT4JsOfRM6QTA0jSaS3n9ZF-rPWnYewzv0",
"name": "Threshing Routes form and spreadsheet (u/ClumsyBadger, linked from the r/fourthwing megathreads)"
"name": "Threshing Routes form and spreadsheet (u/ClumsyBadger, linked from the r/fourthwing megathreads)",
"url": "https://docs.google.com/spreadsheets/d/1gnw1AdRg1XT4JsOfRM6QTA0jSaS3n9ZF-rPWnYewzv0"
},
{
"@type": "sc:CreativeWork",
"url": "https://docs.google.com/spreadsheets/d/1KMiE9sec0l597Pzue1OhGYf07NF4howtQ_lPeqx7jXQ",
"name": "Unofficial Dragon Register (which dragon each rider bonded)"
"name": "Unofficial Dragon Register (which dragon each rider bonded)",
"url": "https://docs.google.com/spreadsheets/d/1KMiE9sec0l597Pzue1OhGYf07NF4howtQ_lPeqx7jXQ"
},
{
"@type": "sc:CreativeWork",
"url": "https://www.reddit.com/r/fourthwing/comments/1wvwfp9/",
"name": "Runs posted in the r/fourthwing Dragonkind megathreads (part 3)"
},
{
"@type": "sc:CreativeWork",
"url": "https://www.reddit.com/r/fourthwing/comments/1wz5cnj/",
"name": "Runs posted in the r/fourthwing Dragonkind megathreads (part 4)"
},
{
"@type": "sc:CreativeWork",
"url": "https://www.reddit.com/r/fourthwing/comments/1wvwfp9/",
"name": "Runs riders describe in the r/fourthwing Dragonkind megathread comments (part 3)"
},
{
"@type": "sc:CreativeWork",
"url": "https://www.reddit.com/r/fourthwing/comments/1wz5cnj/",
"name": "Runs riders describe in the r/fourthwing Dragonkind megathread comments (part 4)"
"name": "Runs posted in the r/fourthwing Dragonkind megathreads",
"url": "https://www.reddit.com/r/fourthwing/comments/1wvwfp9/"
}
],
"distribution": [
@@ -101,90 +86,70 @@
"@id": "runs_clean",
"name": "runs_clean",
"description": "Every run from every source, one per row, coded into the same columns (collection/etl/runs.py; the form's rules are core/spec/form.yaml). The `source` column says where each run came from.",
"contentUrl": "https://git.kenschiano.net/DragonKind/threshing-atlas/raw/branch/main/data/public/runs_clean.csv",
"contentUrl": "https://git.kenschiano.net/YOUR-GITEA-USERNAME/threshing-atlas/raw/branch/main/data/public/runs_clean.csv",
"encodingFormat": "text/csv",
"sha256": "6938f1a62d1f855ab6abbceb305b9f9388945ec44ef53a16c21d3f3d0c740fbb",
"contentSize": "3986165 B"
"sha256": "cbca1afd189a1c86b400015177a40eba14256994e880ec19b14307bb5310011b",
"contentSize": "3033793 B"
},
{
"@type": "cr:FileObject",
"@id": "form_responses",
"name": "form_responses",
"description": "The community \"Threshing Routes\" form export as published (headers and rows), with email addresses in free-text answers redacted. The source of runs_clean.",
"contentUrl": "https://git.kenschiano.net/DragonKind/threshing-atlas/raw/branch/main/data/public/form_responses.json",
"contentUrl": "https://git.kenschiano.net/YOUR-GITEA-USERNAME/threshing-atlas/raw/branch/main/data/public/form_responses.json",
"encodingFormat": "application/json",
"sha256": "d5b235f28ad3d1ba91c431328007576251e47294fd8af2ebe7a2cb29e008afef",
"contentSize": "13413071 B"
},
{
"@type": "cr:FileObject",
"@id": "reddit_comments",
"name": "reddit_comments",
"description": "Runs described in the r/fourthwing megathread comments, read into the \"Report a run\" answers: comment id, day and answers only, no usernames or comment text.",
"contentUrl": "https://git.kenschiano.net/DragonKind/threshing-atlas/raw/branch/main/data/public/reddit_comments.json",
"encodingFormat": "application/json",
"sha256": "b169d157e731db23c99f2f8317a9718d31801b7d64336b3d414511ac13f32493",
"contentSize": "23174 B"
},
{
"@type": "cr:FileObject",
"@id": "overlap",
"name": "overlap",
"description": "How many Reddit comment runs may also be in the community form (the same answers within a day), against what chance alone gives (analysis/overlap/overlap.py). Measured only: no run is removed.",
"contentUrl": "https://git.kenschiano.net/DragonKind/threshing-atlas/raw/branch/main/data/public/overlap.json",
"encodingFormat": "application/json",
"sha256": "e7511cccf9e8379d8e892639cb38772269ac228756b984e9e0d4d8e9a583a9dd",
"contentSize": "2544 B"
"sha256": "7ca72f9967a9b15fd52160106b1508c8cfbde804539d6afa3f04df326d7bf2b2",
"contentSize": "11019524 B"
},
{
"@type": "cr:FileObject",
"@id": "reports",
"name": "reports",
"description": "Runs reported through the Atlas's \"Report a run\" form (issues on its repository), answers only, no usernames.",
"contentUrl": "https://git.kenschiano.net/DragonKind/threshing-atlas/raw/branch/main/data/public/reports.json",
"contentUrl": "https://git.kenschiano.net/YOUR-GITEA-USERNAME/threshing-atlas/raw/branch/main/data/public/reports.json",
"encodingFormat": "application/json",
"sha256": "51510ed7a0b4016501fe4e0324a352842e831a48773a08b084dec6ff7dde2d14",
"contentSize": "112 B"
"sha256": "d42eb04b9923eb1d2a8e5c356452f52daab78293be5a29a448cfb69c974eab30",
"contentSize": "92 B"
},
{
"@type": "cr:FileObject",
"@id": "register",
"name": "register",
"description": "The Unofficial Dragon Register (which dragon each rider bonded), without rider names.",
"contentUrl": "https://git.kenschiano.net/DragonKind/threshing-atlas/raw/branch/main/data/public/register.json",
"contentUrl": "https://git.kenschiano.net/YOUR-GITEA-USERNAME/threshing-atlas/raw/branch/main/data/public/register.json",
"encodingFormat": "application/json",
"sha256": "71457db37c12b2e76190480c1aab9fa00347985b5556a40e877093ddb5635750",
"contentSize": "118558 B"
"sha256": "b55e62a7be1d2f8858bc3bf0ad35881bbcd87f61a634f219f2b2bea5a453ff58",
"contentSize": "116221 B"
},
{
"@type": "cr:FileObject",
"@id": "stats",
"name": "stats",
"description": "Every number the Atlas page shows, for six filter presets (analysis/stats/site_stats.py; what is measured is analysis/stats/measures.yaml).",
"contentUrl": "https://git.kenschiano.net/DragonKind/threshing-atlas/raw/branch/main/data/public/stats.json",
"contentUrl": "https://git.kenschiano.net/YOUR-GITEA-USERNAME/threshing-atlas/raw/branch/main/data/public/stats.json",
"encodingFormat": "application/json",
"sha256": "aa0a7726cbb1a96b0167329200cf6399ddaec4c4d7c8bf4c2f42045d22fd568e",
"contentSize": "5195088 B"
"sha256": "aa3b1eb313655b75c290f538373b72b1a29b4685f389feabea487b333c0f96a6",
"contentSize": "5063942 B"
},
{
"@type": "cr:FileObject",
"@id": "policy",
"name": "policy",
"description": "The route model: the game (core/spec/game.yaml), the count tables behind every roll, and the best decision tree for every dragon colour under two goals, with posterior intervals (planner/build_policy.py).",
"contentUrl": "https://git.kenschiano.net/DragonKind/threshing-atlas/raw/branch/main/data/public/policy.json",
"contentUrl": "https://git.kenschiano.net/YOUR-GITEA-USERNAME/threshing-atlas/raw/branch/main/data/public/policy.json",
"encodingFormat": "application/json",
"sha256": "b0bb5f5cb233b976b5184f121844efa765c9c3f0440d59d4fe95c7b6eeb76514",
"contentSize": "987608 B"
"sha256": "156c8ac049db20ecbc32cdfa4ea9054bb1575770073d82b1614bd14dfd45b257",
"contentSize": "599165 B"
},
{
"@type": "cr:FileObject",
"@id": "graph",
"name": "graph",
"description": "The route graph over every run in runs_clean.csv, counted per source (analysis/network/build-graph.js).",
"contentUrl": "https://git.kenschiano.net/DragonKind/threshing-atlas/raw/branch/main/data/public/graph.json",
"contentUrl": "https://git.kenschiano.net/YOUR-GITEA-USERNAME/threshing-atlas/raw/branch/main/data/public/graph.json",
"encodingFormat": "application/json",
"sha256": "8817eea999eb8ffd4848638096fd1e8f06c73fe7d6d75e4ec7ea5e0c8859c842",
"contentSize": "84523 B"
"sha256": "80df43b82f1fa14d14c4b8af46fb32849deadc4e8220379ee8dcc3ba83de30cc",
"contentSize": "73346 B"
}
],
"recordSet": [
@@ -201,7 +166,7 @@
"@type": "cr:Field",
"@id": "runs/run_id",
"name": "run_id",
"description": "Unique id of the run, stable when rows are deleted or re-sorted: sheet-<hash of the form row's answers and timestamp>, register-<hash of the register row>, thread-<result id>, comment-<Reddit comment id>, reported-<issue number> or bot-<hash>.",
"description": "Unique id of the run: sheet-<row of the form export>, thread-<result id>, reported-<issue number> or bot-<hash>.",
"dataType": "sc:Text",
"source": {
"fileObject": {
@@ -216,7 +181,7 @@
"@type": "cr:Field",
"@id": "runs/source",
"name": "source",
"description": "Where the run came from. \"reddit spreadsheet\": the community Threshing Routes form and spreadsheet linked from the r/fourthwing megathreads. \"reddit thread\": a dragonkind.com result page posted in a megathread (bonded, route not recorded). \"reddit comment\": a run a rider described in a megathread comment, read automatically into the \"Report a run\" answers by the threshing-reddit scraper, which delivers them by pull request (hand corrections in collection/manual/reddit_comments.yaml). \"reported\": the Atlas's own \"Report a run\" form. \"bot\": an attempt logged by the DragonKind bot. \"register\": a bonded dragon entered in the community's Unofficial Dragon Register (outcome only, no route; the same run may also be in the spreadsheet). \"reddit pdf\": the community route PDF (a flowchart of the routes, not a log of runs, so it adds no rows today). Values: reddit spreadsheet; reddit thread; reddit comment; register; reported; bot; reddit pdf.",
"description": "Where the run came from. \"reddit spreadsheet\": the community Threshing Routes form and spreadsheet linked from the r/fourthwing megathreads. \"reddit thread\": a dragonkind.com result page posted in a megathread (bonded, route not recorded). \"reported\": the Atlas's own \"Report a run\" form. \"bot\": an attempt logged by the DragonKind bot. \"reddit pdf\": the community route PDF (a flowchart of the routes, not a log of runs, so it adds no rows today). Values: reddit spreadsheet; reddit thread; reported; bot; reddit pdf.",
"dataType": "sc:Text",
"source": {
"fileObject": {
@@ -231,7 +196,7 @@
"@type": "cr:Field",
"@id": "runs/entry",
"name": "entry",
"description": "For spreadsheet runs, the sheet's own row label: \"Form\" for a form submission (it has a timestamp); bulk-pasted logs keep the label they were pasted with. Bulk logs record every run of the players who kept them, so they are the least selectively reported rows. Empty for other sources. Values: Form; Data Import; BulkUpload3; Manual Upload; Historical import; Unknown import; Unknown.",
"description": "For spreadsheet runs, the sheet's own row label: \"Form\" for a form submission (it has a timestamp); bulk-pasted logs keep the label they were pasted with. Bulk logs record every run of the players who kept them, so they are the least selectively reported rows. Empty for other sources. Values: Form; Data Import; BulkUpload3; Manual Upload; Historical import; Unknown import.",
"dataType": "sc:Text",
"source": {
"fileObject": {
+495
View File
@@ -0,0 +1,495 @@
{
"sha256": "3778ece486c7fca9b38f1738e7065ba20d7b1fd739bcd1b845d46e7520e3a22e",
"bytes": 641363,
"pages": 1,
"page_hashes": [
"e88c846a14efc549"
],
"line_hashes": [
"0005ef79b6b0",
"013509f3baab",
"01a32ae0ea35",
"01ff39e78d46",
"021bb8f33946",
"0309a521e7cd",
"033394145a6f",
"0340ff1da1bc",
"061bdd1646d2",
"06845f929ace",
"06deac5b8d4a",
"070e3c5097ec",
"07422fff191a",
"075f329cca76",
"0844df8fee9e",
"084d9c75411f",
"08dbea2e99c7",
"093e7d5fdbaa",
"09ede21a5670",
"0a6389a6b822",
"0c3e015009e5",
"0c5d7989af41",
"0c6edb02c260",
"0caca604d8ec",
"0d00728c456e",
"0d063950e5cb",
"0d2b6043baa9",
"0e00db4dcc8a",
"0e4e929314bc",
"0e5021c854fd",
"0fa4700b553a",
"0fb542ca6733",
"1060c135e592",
"106a5842fc5f",
"115b5cad43c0",
"119a95345c45",
"126b59a70f14",
"1290a0a97b80",
"14558e7e73c8",
"14e2d4c37b5b",
"1584dc810a09",
"16367aacb67a",
"16477688c0e0",
"16486a0e2e7e",
"16552853f950",
"167a79b5d437",
"16872ead1390",
"16a87122c069",
"17fce8dabd41",
"18136e0d6414",
"18f42f5e8e05",
"1a1d05853cee",
"1aefe47e20eb",
"1b4c9133da73",
"1fa9e3998e8b",
"1fbdd6f48a30",
"20539cda4fc1",
"208a6d1ce0de",
"21499b8293b5",
"21e4274038e8",
"2287d8613d2a",
"2309d4da946e",
"24613f13905f",
"24c668f6df98",
"25135325b8a1",
"25f6f2b99e6c",
"27042f4e6eca",
"27058a345f0b",
"27259f1f9d9b",
"27a37ec8b577",
"2840a5c2ef51",
"28fdae8deae3",
"29ba6947875f",
"29bdb54f41e3",
"2ad8a7049d7c",
"2af59eff1aba",
"2bd88b225a02",
"2bfd396cd229",
"2d306ed42cd7",
"2de7de149983",
"2e8e7a08f162",
"2f251aff0a77",
"2f501595d6f2",
"2f63258bd7ea",
"2f80077a0788",
"2f943c163229",
"2fe14cd5feca",
"306a70a396b4",
"306c9b061933",
"310ff200149b",
"31365ab9453d",
"3253cfe4c152",
"32e48995f98c",
"331306fab15d",
"3342b7db5f17",
"33b6aa152d23",
"3495806a7d6c",
"34bbac2c759b",
"34bef004e7fe",
"351421b8bac7",
"3650b7f3b7c5",
"3693c0f2d9d6",
"36bddc3a241f",
"370b1d50ab9e",
"3ad433972874",
"3af12ce68cd1",
"3af395aa2538",
"3beeaab32ac7",
"3c482346f375",
"3c6120e7558f",
"3ccce1f4da94",
"3cf48f3ba37d",
"3d5d5ba737e9",
"3d7505bbaadb",
"3d7f757f5e80",
"3daa8653d747",
"3e213b2a24a7",
"3e249a6cfd1e",
"3fc4ccfe7458",
"4062a9f595aa",
"40c432addf51",
"40d56877304e",
"40efa81686c6",
"414805731daf",
"41b0c91ed6d1",
"41bc7b0a9de2",
"41f20dee5da8",
"429e5436f520",
"42a21ed159ef",
"42ff6957f0a3",
"447048356f8c",
"453962996160",
"45847b618b88",
"45b162d4052f",
"466b733c13e3",
"46b86c91e7dc",
"4743a7d9869f",
"489620cdfe3f",
"491004bb0c9c",
"4945a70fa7f9",
"4978c1d21cf6",
"49c7fc30c959",
"4ac67444801e",
"4acde18a14fe",
"4b7e2845d537",
"4c3598c88d72",
"4cd1594422d4",
"4d0705fe0a43",
"4d74e17e5162",
"4e00a0ada947",
"4e7841613cc7",
"4f253b49f165",
"5066f3a82472",
"509a7aea82f7",
"510e291d89cb",
"519735f7b50e",
"532ef4c15de8",
"53d2eb410d18",
"53f62454ac36",
"5586092a2a2e",
"56100f08de18",
"574516c105b3",
"5751e048eb6f",
"57ae2b2ab747",
"59b6221a51c1",
"5a785c0c26ab",
"5a8a1e3f617e",
"5b3975651c3c",
"5c2b4df891b0",
"5c385ea2003b",
"5c6039c55d3e",
"5d09fad99d0b",
"5df17b0e4664",
"5e9c9ea87d06",
"5eb67f9f8409",
"5ed0a10b951b",
"5f3f6470bb31",
"6038ac4d7893",
"618cef59e81d",
"626a5a89e9aa",
"62db96bae199",
"63a1d7c638d4",
"6415fae65a2b",
"65ddfc96e288",
"668fea7bbc6f",
"680dce633db1",
"696a74e35192",
"69dacd6c8b7f",
"6a3432dd57a9",
"6a7ef134f235",
"6b32aa9d4ff4",
"6b46e167e442",
"6bb9c00e0aa5",
"6c45cb72a36e",
"6c8a73953696",
"6ca23bf7ced0",
"6d19ba36e0fe",
"6d1ef368012c",
"6d4a1297d150",
"6da5700a5639",
"6dca03cf2f51",
"6eb4b60a51cf",
"70e0378cb382",
"718b3ba4d288",
"7316da8715b2",
"73493e3a688b",
"73d41a094816",
"743b4e8706ef",
"7488af2a0881",
"75ad72417087",
"75fdd9027b0a",
"7692c3ad3540",
"76a796208b71",
"771b94c11b83",
"77aa50b9631e",
"77b8d989055a",
"793080bb3a18",
"79ea70ff1e9b",
"7b02bb57a565",
"7b78cfa89480",
"7d9d2e568dc6",
"7e125ce01532",
"7e5056bd90f6",
"806112b3adcd",
"812f1ac36f2e",
"817286c6b049",
"81f8bd569345",
"821343c8782b",
"826efdadff57",
"82b8b62bc350",
"844c6714bd43",
"844cae5956bf",
"846e18aeea60",
"84ce9897665f",
"8577b991fbf8",
"860ce7852dc3",
"87094fc18528",
"877de8ebb965",
"87c3e080dcb4",
"8838a3634b92",
"883caeb7ca11",
"88f682991696",
"89045a19abd3",
"8950aeb7bd2e",
"899b7c875126",
"8bab6b875ef7",
"8c25ea741f54",
"8d988fa37098",
"8d9f59690970",
"8e465d332643",
"8ff7f746ad0b",
"902e6d1a2e41",
"9160990b5196",
"91918d7d290f",
"919bc9b8d743",
"920a5924f124",
"935f14ac67b6",
"94844cb129a8",
"94ab1f4a7216",
"954f0ca1b653",
"95a14ed2a7fc",
"95d77302ee47",
"961836168b5b",
"964954c9200c",
"984814d47989",
"987777fb002e",
"997b80a62167",
"99b5f979b8f6",
"9a43a6e28ae1",
"9a72012b0738",
"9b6cdd23ebfd",
"9b74bfb78b8a",
"9c4180730556",
"9c96829a8db2",
"9d8368e07ec1",
"9dbb8ef0cfbe",
"9dc08e403382",
"9e13d99f2ec9",
"9e6242783cf6",
"9f56d2f4cae6",
"9fef67eeac85",
"a00b1ba9e0fb",
"a060335c66cf",
"a093d3f5ecff",
"a0f941fee4c0",
"a2972765764c",
"a2a92faf51c6",
"a35c9fb774e6",
"a36373ed77ba",
"a3d7a6bf2036",
"a3f146576c0e",
"a5973cf86c17",
"a69204c67bcd",
"a69a4139b340",
"a6e0a42de76e",
"a6e8ab03915b",
"a7937b64b8ca",
"a7cdf72224c0",
"a7dbeb539e04",
"a854942a3868",
"a8892d94fb8f",
"a8ac9cbce523",
"a8faaccd9225",
"a908043ed469",
"a9c43be948c5",
"a9c9cca61f97",
"a9d4b2eeab21",
"a9f6216a0284",
"a9fc9e5a9392",
"aa43aff07d84",
"ab455d73f4e1",
"abfc412ce6e5",
"acba25512100",
"ace6f6b30de2",
"aceee3c152b4",
"ad485b06c7ff",
"adb35344b704",
"aea01b0f80d4",
"aeb8e7b22c53",
"aee408847d35",
"aeee13ca5367",
"aef0f56e108d",
"af07ff91ab7c",
"af6ee9910675",
"afa54821283c",
"afda0d03d5a4",
"b00a0d1bf844",
"b02c92648f0c",
"b0c1e513d4a4",
"b2081dd581e8",
"b23641a50841",
"b23a6a8439c0",
"b26da2826c7d",
"b32c487e019c",
"b3b8898b5da9",
"b3d9c50e24f4",
"b4fbbe802d67",
"b5afeb8db3aa",
"b627f4168840",
"b724cc07becf",
"b7bd4220ff85",
"b8ab74d65421",
"b8b0e7effd20",
"b9514000c923",
"b95206531cb4",
"ba4788b226aa",
"bac081e175b0",
"bb0e505c6386",
"bb36f57782ca",
"bb6db2fb1f33",
"bb8b9de8437d",
"bc807bf2a135",
"be5ba8fe14a3",
"bec9019352b4",
"bf1563e43ef8",
"bf973180096e",
"bfdb888b8751",
"c0119487dd61",
"c0ac6a7adbc9",
"c176f96fff0c",
"c1a6320ab4ad",
"c1c369840b67",
"c29277f55fb3",
"c35c812678a2",
"c4bc2e4b5d80",
"c524989dd971",
"c54dbcd6c9a7",
"c5afb84019c7",
"c5d35286c108",
"c68fef1abac6",
"c78a686d7cf5",
"c78f34b0d79b",
"c84d205e4185",
"c897882a79aa",
"c95ca8650396",
"c98e94e2a5f1",
"caa6a9ced701",
"cb28392914d1",
"cc2e668bb959",
"cca94b79f1f1",
"cd1bb3012bcf",
"ce8371563887",
"ce8e9aa287dc",
"cebb73212de0",
"cec9111de36d",
"cee6d39a9dae",
"d00d825bba6b",
"d036316da911",
"d06e32ad1536",
"d0a7f376d907",
"d0bf30710858",
"d15a1edfb23c",
"d1dbecdfe93d",
"d2fa0e68a582",
"d3774d36d6cb",
"d3acc6861a0d",
"d413d29b87df",
"d4536f255583",
"d5a0d90574d5",
"d61483fb5f57",
"d76d5e7a3df7",
"d88c2c2a6831",
"d8fe183f5b8e",
"d90b4f86d5e0",
"d942f0a84262",
"d978e0e48792",
"d9a847a1a79a",
"d9ae6af36f3c",
"dab61aea1eb7",
"db875b25b06f",
"dbb3b50e59c7",
"dc439b56f090",
"dc6784c12e4a",
"dc934fe30a94",
"dc9c5edb8b2d",
"dcebdc7c87c1",
"dd0cb2944980",
"dd6222c3b730",
"dddb00ed93b8",
"ddef924cf594",
"de0e10e162e2",
"de44be0064f1",
"df3f3c5b4066",
"e10ff24d56e9",
"e1d67a1ebbc7",
"e256ee8e7aff",
"e37f279ac396",
"e3f8ef6845ac",
"e40dfff1a71e",
"e4bcc131d644",
"e4d6190e25b9",
"e53bac8ba854",
"e564b4081d7a",
"e566c53e48ba",
"e596899f114b",
"e5a05ee2bbba",
"e644b77bfa11",
"e6c66d78c859",
"e6e6263ada92",
"e76566a6d54c",
"e774d221fc45",
"e7c0d9c5bc32",
"e84978ebc645",
"e8902e5de81c",
"e9c5da6aa913",
"ea28f8974142",
"ea436127abfb",
"ea6c1c7a7a76",
"ea7fc9c5ea1c",
"eb04474cc31f",
"ec017cadac18",
"ec17f572de06",
"ed6f7162410b",
"eded8d613508",
"eeeb42e33061",
"eef98a799e12",
"ef379363dd0c",
"efd8ebf4f438",
"f0dce65b5798",
"f179a509d32b",
"f1cb18decbab",
"f2a49ad419d2",
"f35864389230",
"f39dda09980e",
"f3c7807d4750",
"f3e394c8b9dc",
"f4909e20a51e",
"f51563619474",
"f6a4807a956f",
"f70b7769ae02",
"f763b9be2dc9",
"f8c25133ee80",
"f96ae5d430a6",
"fac6a3243ed4",
"facf8b54e5c0",
"faebbd710849",
"fbd161e2c059",
"fca413c36342",
"fd5cd809e2aa",
"fdbbfc2be926",
"fe4c73974e0e",
"ff06886f82e3",
"ff1f017072cc",
"ffe503ead4e4"
],
"checked": "2026-11-10"
}
+6 -21
View File
@@ -35,18 +35,6 @@ files:
description: >-
The community "Threshing Routes" form export as published (headers and rows), with email addresses in
free-text answers redacted. The source of runs_clean.
reddit_comments:
path: data/public/reddit_comments.json
format: application/json
description: >-
Runs described in the r/fourthwing megathread comments, read into the "Report a run" answers: comment id, day
and answers only, no usernames or comment text.
overlap:
path: data/public/overlap.json
format: application/json
description: >-
How many Reddit comment runs may also be in the community form (the same answers within a day), against what
chance alone gives (analysis/overlap/overlap.py). Measured only: no run is removed.
reports:
path: data/public/reports.json
format: application/json
@@ -75,27 +63,24 @@ files:
# The columns of runs_clean. type: text, integer, boolean or date. values: every value the column may take
# (empty cells are always allowed and mean "does not apply" or "not recorded").
columns:
run_id: { type: text, required: true, description: "Unique id of the run, stable when rows are deleted or re-sorted: sheet-<hash of the form row's answers and timestamp>, register-<hash of the register row>, thread-<result id>, comment-<Reddit comment id>, reported-<issue number> or bot-<hash>." }
run_id: { type: text, required: true, description: "Unique id of the run: sheet-<row of the form export>, thread-<result id>, reported-<issue number> or bot-<hash>." }
source:
type: text
required: true
description: >-
Where the run came from. "reddit spreadsheet": the community Threshing Routes form and spreadsheet linked from
the r/fourthwing megathreads. "reddit thread": a dragonkind.com result page posted in a megathread (bonded,
route not recorded). "reddit comment": a run a rider described in a megathread comment, read automatically into
the "Report a run" answers by the threshing-reddit scraper, which delivers them by pull request (hand
corrections in collection/manual/reddit_comments.yaml). "reported": the Atlas's own "Report a run" form. "bot": an attempt logged by the
DragonKind bot. "register": a bonded dragon entered in the community's Unofficial Dragon Register (outcome
only, no route; the same run may also be in the spreadsheet). "reddit pdf": the community route PDF (a
flowchart of the routes, not a log of runs, so it adds no rows today).
values: [reddit spreadsheet, reddit thread, reddit comment, register, reported, bot, reddit pdf]
route not recorded). "reported": the Atlas's own "Report a run" form. "bot": an attempt logged by the
DragonKind bot. "reddit pdf": the community route PDF (a flowchart of the routes, not a log of runs, so it
adds no rows today).
values: [reddit spreadsheet, reddit thread, reported, bot, reddit pdf]
entry:
type: text
description: >-
For spreadsheet runs, the sheet's own row label: "Form" for a form submission (it has a timestamp);
bulk-pasted logs keep the label they were pasted with. Bulk logs record every run of the players who kept
them, so they are the least selectively reported rows. Empty for other sources.
values: [Form, Data Import, BulkUpload3, Manual Upload, Historical import, Unknown import, Unknown]
values: [Form, Data Import, BulkUpload3, Manual Upload, Historical import, Unknown import]
bot_mode:
type: text
description: >-
-977
View File
@@ -1,977 +0,0 @@
{
"schema": 2,
"seed": 20261116,
"lifecycle": {
"research_days": 3,
"retire": true,
"long_lived": {
"every": 10,
"take": 2
}
},
"record": [
"accountSeq",
"accountAttempt",
"accountCreatedAt",
"wing",
"section",
"squad",
"sawShadowBefore"
],
"scripts": {
"shadow": [
{
"step": "the tree top",
"take": "shadow",
"never": "green|descend"
},
{
"step": "asked to turn back",
"take": "stay the course|certain you saw",
"never": "second thought|green"
},
{
"step": "asked again",
"take": "intriguing|even if this kills",
"never": "second thought|green"
},
{
"step": "the Blue lands",
"take": "freeze and lower",
"never": "approach|run"
},
{
"step": "another cadet arrives",
"take": "hold (completely )?still",
"never": "warn|turn while|approach"
},
{
"step": "the Blue burns the cadet",
"take": "hold (your )?position",
"never": "interven|approach|warn"
},
{
"step": "the Blue judges",
"take": "head lowered|await.*judg",
"never": "approach|sure"
},
{
"step": "the Blue has left",
"take": "help the .*cadet",
"never": ""
},
{
"step": "the cadet's burns",
"take": "wrap|cut .*sleeve|dagger to cut",
"never": ""
},
{
"step": "moving on",
"take": "head south",
"never": ""
},
{
"step": "a branch snaps",
"take": "turn to face",
"never": "ignore"
},
{
"step": "the Black",
"take": "hold (its|it's|the) gaze|lift your chin",
"never": "lower your eyes"
}
]
},
"screenPicks": [
{
"where": "after the shadow shows",
"use": "script",
"script": "shadow"
},
{
"where": "bonding the target dragon",
"use": "thompson"
},
{
"where": "experiment mapping",
"use": "least-tried"
}
],
"experiments": [
{
"id": "fresh-replicate",
"status": "running",
"question": "On a fresh account, does one exact path always show the shadow, sometimes, or never?",
"attempts": {
"from": 1,
"to": 1
},
"unit": "account",
"share": 1,
"exclusive": true,
"target": "Black",
"objective": "eventually",
"sampling": "best",
"seed": 20261116,
"measures": {
"roll": "shadow",
"rare": "yes"
},
"burn": {
"reason": "TREE_NO_SHADOW_AUTO_BURN",
"when": "no shadow at the tree"
},
"arms": [
{
"id": "all",
"fix": {
"company": "Alone",
"direction": "West",
"react": "Hold still",
"scream": "Investigate the scream",
"clearing": "Help your squadmate",
"fight": "Pause to assess",
"dagger": "Engage the smaller cadet",
"fate": "Squadmate's revenge",
"post": "West",
"hour": "Tree"
},
"progress": {
"runs": 0,
"observed": 0,
"rare": 0,
"planned": 60
}
}
],
"progress": {
"runs": 0,
"observed": 0,
"rare": 0,
"unknownArms": []
}
},
{
"id": "fresh-ablate",
"status": "waiting",
"note": "starts when fresh-replicate is complete",
"question": "Which choices on that path does the shadow need?",
"attempts": {
"from": 1,
"to": 1
},
"unit": "account",
"share": 1,
"exclusive": true,
"target": "Black",
"objective": "eventually",
"sampling": "best",
"seed": 20261116,
"measures": {
"roll": "shadow",
"rare": "yes"
},
"burn": {
"reason": "TREE_NO_SHADOW_AUTO_BURN",
"when": "no shadow at the tree"
},
"arms": [
{
"id": "with one squadmate",
"change": {
"company": "1 Squadmate",
"leave": "Stay together"
},
"fix": {
"company": "1 Squadmate",
"direction": "West",
"react": "Hold still",
"scream": "Investigate the scream",
"clearing": "Help your squadmate",
"fight": "Pause to assess",
"dagger": "Engage the smaller cadet",
"fate": "Squadmate's revenge",
"post": "West",
"hour": "Tree",
"leave": "Stay together"
},
"progress": {
"runs": 0,
"observed": 0,
"rare": 0,
"planned": 15
}
},
{
"id": "with two squadmates",
"change": {
"company": "2 Squadmates",
"leave": "Stay together"
},
"fix": {
"company": "2 Squadmates",
"direction": "West",
"react": "Hold still",
"scream": "Investigate the scream",
"clearing": "Help your squadmate",
"fight": "Pause to assess",
"dagger": "Engage the smaller cadet",
"fate": "Squadmate's revenge",
"post": "West",
"hour": "Tree",
"leave": "Stay together"
},
"progress": {
"runs": 0,
"observed": 0,
"rare": 0,
"planned": 15
}
},
{
"id": "leave the squad",
"change": {
"company": "2 Squadmates",
"leave": "Leave them"
},
"fix": {
"company": "2 Squadmates",
"direction": "West",
"react": "Hold still",
"scream": "Investigate the scream",
"clearing": "Help your squadmate",
"fight": "Pause to assess",
"dagger": "Engage the smaller cadet",
"fate": "Squadmate's revenge",
"post": "West",
"hour": "Tree",
"leave": "Leave them"
},
"progress": {
"runs": 0,
"observed": 0,
"rare": 0,
"planned": 15
}
},
{
"id": "east first",
"change": {
"direction": "East"
},
"fix": {
"company": "Alone",
"direction": "East",
"react": "Hold still",
"scream": "Investigate the scream",
"clearing": "Help your squadmate",
"fight": "Pause to assess",
"dagger": "Engage the smaller cadet",
"fate": "Squadmate's revenge",
"post": "West",
"hour": "Tree"
},
"progress": {
"runs": 0,
"observed": 0,
"rare": 0,
"planned": 15
}
},
{
"id": "centre first",
"change": {
"direction": "Center"
},
"fix": {
"company": "Alone",
"direction": "Center",
"react": "Hold still",
"scream": "Investigate the scream",
"clearing": "Help your squadmate",
"fight": "Pause to assess",
"dagger": "Engage the smaller cadet",
"fate": "Squadmate's revenge",
"post": "West",
"hour": "Tree"
},
"progress": {
"runs": 0,
"observed": 0,
"rare": 0,
"planned": 15
}
},
{
"id": "face the first dragon",
"change": {
"react": "Respect / face it"
},
"fix": {
"company": "Alone",
"direction": "West",
"react": "Respect / face it",
"scream": "Investigate the scream",
"clearing": "Help your squadmate",
"fight": "Pause to assess",
"dagger": "Engage the smaller cadet",
"fate": "Squadmate's revenge",
"post": "West",
"hour": "Tree"
},
"progress": {
"runs": 0,
"observed": 0,
"rare": 0,
"planned": 15
}
},
{
"id": "charge the smaller cadet",
"change": {
"fight": "Charge the smaller cadet"
},
"fix": {
"company": "Alone",
"direction": "West",
"react": "Hold still",
"scream": "Investigate the scream",
"clearing": "Help your squadmate",
"fight": "Charge the smaller cadet",
"dagger": "Engage the smaller cadet",
"fate": "Squadmate's revenge",
"post": "West",
"hour": "Tree"
},
"progress": {
"runs": 0,
"observed": 0,
"rare": 0,
"planned": 15
}
},
{
"id": "charge the bigger cadet",
"change": {
"dagger": "Charge the bigger cadet anyway"
},
"fix": {
"company": "Alone",
"direction": "West",
"react": "Hold still",
"scream": "Investigate the scream",
"clearing": "Help your squadmate",
"fight": "Pause to assess",
"dagger": "Charge the bigger cadet anyway",
"fate": "Squadmate's revenge",
"post": "West",
"hour": "Tree"
},
"progress": {
"runs": 0,
"observed": 0,
"rare": 0,
"planned": 15
}
},
{
"id": "kill the bullies",
"change": {
"fate": "Killed the bullies yourself"
},
"fix": {
"company": "Alone",
"direction": "West",
"react": "Hold still",
"scream": "Investigate the scream",
"clearing": "Help your squadmate",
"fight": "Pause to assess",
"dagger": "Engage the smaller cadet",
"fate": "Killed the bullies yourself",
"post": "West",
"hour": "Tree"
},
"progress": {
"runs": 0,
"observed": 0,
"rare": 0,
"planned": 15
}
},
{
"id": "leave the bullies",
"change": {
"fate": "Left bullies to the dragons"
},
"fix": {
"company": "Alone",
"direction": "West",
"react": "Hold still",
"scream": "Investigate the scream",
"clearing": "Help your squadmate",
"fight": "Pause to assess",
"dagger": "Engage the smaller cadet",
"fate": "Left bullies to the dragons",
"post": "West",
"hour": "Tree"
},
"progress": {
"runs": 0,
"observed": 0,
"rare": 0,
"planned": 15
}
},
{
"id": "fork to the forest",
"change": {
"post": "Forest"
},
"fix": {
"company": "Alone",
"direction": "West",
"react": "Hold still",
"scream": "Investigate the scream",
"clearing": "Help your squadmate",
"fight": "Pause to assess",
"dagger": "Engage the smaller cadet",
"fate": "Squadmate's revenge",
"post": "Forest",
"hour": "Tree"
},
"progress": {
"runs": 0,
"observed": 0,
"rare": 0,
"planned": 15
}
},
{
"id": "fork east",
"change": {
"post": "East"
},
"fix": {
"company": "Alone",
"direction": "West",
"react": "Hold still",
"scream": "Investigate the scream",
"clearing": "Help your squadmate",
"fight": "Pause to assess",
"dagger": "Engage the smaller cadet",
"fate": "Squadmate's revenge",
"post": "East",
"hour": "Tree"
},
"progress": {
"runs": 0,
"observed": 0,
"rare": 0,
"planned": 15
}
}
],
"progress": {
"runs": 0,
"observed": 0,
"rare": 0,
"unknownArms": []
}
},
{
"id": "shadow-again",
"status": "running",
"question": "Does an account that saw the shadow, and died, see it again on the same path?",
"attempts": {
"from": 2,
"to": 4
},
"unit": "account",
"share": 1,
"exclusive": true,
"when": {
"sawShadowBefore": true
},
"target": "Black",
"objective": "eventually",
"sampling": "best",
"seed": 20261116,
"measures": {
"roll": "shadow",
"rare": "yes"
},
"burn": {
"reason": "TREE_NO_SHADOW_AUTO_BURN",
"when": "no shadow at the tree"
},
"arms": [
{
"id": "all",
"fix": {
"company": "Alone",
"direction": "West",
"react": "Hold still",
"scream": "Investigate the scream",
"clearing": "Help your squadmate",
"fight": "Pause to assess",
"dagger": "Engage the smaller cadet",
"fate": "Squadmate's revenge",
"post": "West",
"hour": "Tree"
},
"progress": {
"runs": 0,
"observed": 0,
"rare": 0,
"planned": 12
}
}
],
"progress": {
"runs": 0,
"observed": 0,
"rare": 0,
"unknownArms": []
}
},
{
"id": "second-attempt-same-path",
"status": "running",
"question": "Does an account that missed on its first attempt miss again on the same path?",
"attempts": {
"from": 2,
"to": 2
},
"unit": "account",
"share": 1,
"accounts": {
"every": 2,
"take": 1,
"offset": 0
},
"exclusive": true,
"when": {
"sawShadowBefore": false
},
"target": "Black",
"objective": "eventually",
"sampling": "best",
"seed": 20261116,
"measures": {
"roll": "shadow",
"rare": "yes"
},
"burn": {
"reason": "TREE_NO_SHADOW_AUTO_BURN",
"when": "no shadow at the tree"
},
"arms": [
{
"id": "all",
"fix": {
"company": "Alone",
"direction": "West",
"react": "Hold still",
"scream": "Investigate the scream",
"clearing": "Help your squadmate",
"fight": "Pause to assess",
"dagger": "Engage the smaller cadet",
"fate": "Squadmate's revenge",
"post": "West",
"hour": "Tree"
},
"progress": {
"runs": 0,
"observed": 0,
"rare": 0,
"planned": 60
}
}
],
"progress": {
"runs": 0,
"observed": 0,
"rare": 0,
"unknownArms": []
}
},
{
"id": "veteran-repeat",
"status": "running",
"question": "Does an older account open up by repeating one path?",
"attempts": {
"from": 3,
"to": null
},
"unit": "account",
"share": 1,
"accounts": {
"every": 10,
"take": 1,
"offset": 0
},
"exclusive": true,
"when": {
"sawShadowBefore": false
},
"target": "Black",
"objective": "eventually",
"sampling": "best",
"seed": 20261116,
"measures": {
"roll": "shadow",
"rare": "yes"
},
"burn": {
"reason": "TREE_NO_SHADOW_AUTO_BURN",
"when": "no shadow at the tree"
},
"arms": [
{
"id": "all",
"fix": {
"company": "Alone",
"direction": "West",
"react": "Hold still",
"scream": "Investigate the scream",
"clearing": "Help your squadmate",
"fight": "Pause to assess",
"dagger": "Engage the smaller cadet",
"fate": "Squadmate's revenge",
"post": "West",
"hour": "Tree"
},
"progress": {
"runs": 0,
"observed": 0,
"rare": 0,
"planned": 300
}
}
],
"progress": {
"runs": 0,
"observed": 0,
"rare": 0,
"unknownArms": []
}
},
{
"id": "veteran-variety",
"status": "running",
"question": "Does an older account open up by varying its choices?",
"attempts": {
"from": 3,
"to": null
},
"unit": "account",
"share": 1,
"accounts": {
"every": 10,
"take": 1,
"offset": 1
},
"exclusive": true,
"when": {
"sawShadowBefore": false
},
"target": "Black",
"objective": "eventually",
"sampling": "best",
"seed": 20261116,
"measures": {
"roll": "shadow",
"rare": "yes"
},
"burn": {
"reason": "TREE_NO_SHADOW_AUTO_BURN",
"when": "no shadow at the tree"
},
"arms": [
{
"id": "all",
"fix": {
"scream": "Investigate the scream",
"clearing": "Help your squadmate",
"hour": "Tree"
},
"cycle": {
"company": [
"Alone",
"1 Squadmate",
"2 Squadmates"
],
"direction": [
"West",
"East",
"Center"
],
"fight": [
"Pause to assess",
"Charge the smaller cadet",
"Charge between the bigger cadet and your squadmate"
],
"dagger": [
"Engage the smaller cadet",
"Charge the bigger cadet anyway"
],
"fate": [
"Killed the bullies yourself",
"Squadmate's revenge",
"Left bullies to the dragons"
],
"post": [
"Forest",
"West",
"East"
]
},
"progress": {
"runs": 0,
"observed": 0,
"rare": 0,
"planned": 300
}
}
],
"progress": {
"runs": 0,
"observed": 0,
"rare": 0,
"unknownArms": []
}
},
{
"id": "meadow-blue-route",
"status": "running",
"question": "Does anything before the meadow change how often the Blue waits there?",
"attempts": {
"from": 2,
"to": null
},
"unit": "attempt",
"share": 0.5,
"target": "Blue",
"objective": "eventually",
"sampling": "best",
"seed": 20261116,
"measures": {
"roll": "meadow",
"rare": "Blue"
},
"burn": {
"reason": "MEADOW_NO_BLUE_AUTO_BURN",
"when": "no Blue in the meadow"
},
"arms": [
{
"id": "scream=Investigate the scream / direction=West",
"levels": {
"scream": "Investigate the scream",
"direction": "West"
},
"fix": {
"hour": "Valley",
"valley": "Pass the Red (meadow)",
"scream": "Investigate the scream",
"direction": "West"
},
"progress": {
"runs": 0,
"observed": 0,
"rare": 0,
"planned": 70
}
},
{
"id": "scream=Investigate the scream / direction=East",
"levels": {
"scream": "Investigate the scream",
"direction": "East"
},
"fix": {
"hour": "Valley",
"valley": "Pass the Red (meadow)",
"scream": "Investigate the scream",
"direction": "East"
},
"progress": {
"runs": 0,
"observed": 0,
"rare": 0,
"planned": 70
}
},
{
"id": "scream=Investigate the scream / direction=Center",
"levels": {
"scream": "Investigate the scream",
"direction": "Center"
},
"fix": {
"hour": "Valley",
"valley": "Pass the Red (meadow)",
"scream": "Investigate the scream",
"direction": "Center"
},
"progress": {
"runs": 0,
"observed": 0,
"rare": 0,
"planned": 70
}
},
{
"id": "scream=Keep walking / direction=West",
"levels": {
"scream": "Keep walking",
"direction": "West"
},
"fix": {
"hour": "Valley",
"valley": "Pass the Red (meadow)",
"scream": "Keep walking",
"direction": "West"
},
"progress": {
"runs": 0,
"observed": 0,
"rare": 0,
"planned": 70
}
},
{
"id": "scream=Keep walking / direction=East",
"levels": {
"scream": "Keep walking",
"direction": "East"
},
"fix": {
"hour": "Valley",
"valley": "Pass the Red (meadow)",
"scream": "Keep walking",
"direction": "East"
},
"progress": {
"runs": 0,
"observed": 0,
"rare": 0,
"planned": 70
}
},
{
"id": "scream=Keep walking / direction=Center",
"levels": {
"scream": "Keep walking",
"direction": "Center"
},
"fix": {
"hour": "Valley",
"valley": "Pass the Red (meadow)",
"scream": "Keep walking",
"direction": "Center"
},
"progress": {
"runs": 0,
"observed": 0,
"rare": 0,
"planned": 70
}
}
],
"progress": {
"runs": 0,
"observed": 0,
"rare": 0,
"unknownArms": []
}
},
{
"id": "mapping",
"status": "running",
"question": "What does every option on every screen lead to?",
"attempts": {
"from": 2,
"to": null
},
"unit": "attempt",
"share": 0.35,
"target": "Blue",
"objective": "eventually",
"sampling": "uniform",
"seed": 20261116,
"measures": null,
"burn": {
"reason": "NOT_TARGET_AUTO_BURN",
"when": "the encounter is not a Blue or a Black"
},
"arms": [
{
"id": "all",
"fix": {},
"progress": {
"runs": 0,
"observed": 0,
"rare": 0,
"planned": 1000
}
}
],
"progress": {
"runs": 0,
"observed": 0,
"rare": 0,
"unknownArms": []
}
},
{
"id": "sentinel",
"status": "running",
"question": "Have the game's odds changed?",
"attempts": {
"from": 2,
"to": null
},
"unit": "attempt",
"share": 0.15,
"target": "Blue",
"objective": "eventually",
"sampling": "best",
"seed": 20261116,
"measures": {
"roll": "meadow",
"rare": "Blue"
},
"burn": {
"reason": "MEADOW_NO_BLUE_AUTO_BURN",
"when": "no Blue in the meadow"
},
"arms": [
{
"id": "all",
"fix": {
"company": "Alone",
"direction": "Center",
"scream": "Keep walking",
"wounded": "Tourniquet",
"hour": "Valley",
"valley": "Pass the Red (meadow)"
},
"progress": {
"runs": 0,
"observed": 0,
"rare": 0,
"planned": null
}
}
],
"progress": {
"runs": 0,
"observed": 0,
"rare": 0,
"unknownArms": []
}
}
],
"id": "a7b307abeaaa"
}
-1
View File
File diff suppressed because one or more lines are too long
+27
View File
@@ -0,0 +1,27 @@
{
"bot": {
"sha256": "fc3fbf23e39d29985d73a4693824c9b9bbadfc5b86361f8f5bd160aad094b1df",
"bytes": 11742294,
"changed": "2026-11-10"
},
"reddit_pdf": {
"sha256": "3778ece486c7fca9b38f1738e7065ba20d7b1fd739bcd1b845d46e7520e3a22e",
"bytes": 641363,
"changed": "2026-11-10"
},
"reddit_spreadsheet": {
"sha256": "97377c3c3cfc9756a3520580441111d5154642e224441e35754f021c701a46fd",
"bytes": 4695125,
"changed": "2026-11-12"
},
"register": {
"sha256": "1a4e98f3a140015f8849c2ff5f3c1635def12614ad60461b8213dcb3b3b420a2",
"bytes": 50431,
"changed": "2026-11-12"
},
"reported": {
"sha256": "4f53cda18c2baa0c0354bb5f9a3ecbe5ed12ab4d8e11ba873c2f11161202b945",
"bytes": 2,
"changed": "2026-11-04"
}
}
-134
View File
@@ -1,134 +0,0 @@
{
"schema": 1,
"rule": {
"min_answers": 4,
"window_days": 1,
"baseline_shifts_days": [
-28,
-21,
-14,
14,
21,
28
]
},
"comment_runs": 82,
"comparable": 36,
"matched": 9,
"expected_by_chance": 7.3,
"likely_double": 1.7,
"matches": [
{
"comment": "comment-pdjr7gm",
"form": [
"sheet-e42d078df15a",
"sheet-d930d7c3533d"
]
},
{
"comment": "comment-pdq6tsw",
"form": [
"sheet-e588ea82d6f9",
"sheet-410e2db3f2df",
"sheet-af47d3ca8ef8"
]
},
{
"comment": "comment-pe0kwol",
"form": [
"sheet-bea7c3c25e85"
]
},
{
"comment": "comment-pe2l6mz",
"form": [
"sheet-7a526f9f5956",
"sheet-8191a69798de",
"sheet-0d56c45763b7",
"sheet-c51873588c6d",
"sheet-b8d6d0a2ce4c",
"sheet-34e592789d1b",
"sheet-66e8fda4be49",
"sheet-1922bb0d7397",
"sheet-37f31b85732d"
]
},
{
"comment": "comment-pe2n3j1",
"form": [
"sheet-807397c3d7e2",
"sheet-ff44440c3570"
]
},
{
"comment": "comment-pev3uge",
"form": [
"sheet-9c848ba4c9a9",
"sheet-65c505bb553d",
"sheet-93077866d5b5",
"sheet-f4ba657cd34c",
"sheet-2fa18d22a1eb",
"sheet-4602a99ee254",
"sheet-5320d71ea890",
"sheet-55b901b0c666",
"sheet-94b17052d8c3",
"sheet-8924c5206376",
"sheet-81124318fbca",
"sheet-1346c5ddbeb6",
"sheet-c8670abfd8b3",
"sheet-913d430db3ed",
"sheet-2fa9c70f091d",
"sheet-19e5e9069e3b",
"sheet-19ecd172b18a",
"sheet-62484835c1c0",
"sheet-86e585f7994e",
"sheet-ad2265128708",
"sheet-f65261b3b1f7",
"sheet-cead6ddb0272",
"sheet-dd7216ed25e8",
"sheet-60a2410b997e",
"sheet-93303aaac8a1",
"sheet-aac64def431c",
"sheet-a62003707841",
"sheet-76d43e939528",
"sheet-ca945bc0e4f7",
"sheet-83270750d93e",
"sheet-7cb7c22a757e",
"sheet-1598950786a0",
"sheet-0d44ea821771",
"sheet-cc3275c111d3",
"sheet-899c141a899c"
]
},
{
"comment": "comment-pf22tpj",
"form": [
"sheet-3fdbb179c709",
"sheet-08a79a6ae907",
"sheet-73d9e41fee8d",
"sheet-172fec1dedc4",
"sheet-792cc1632e55",
"sheet-e97b3363e32f",
"sheet-d81d1b4b8c65",
"sheet-bcb8e109f973",
"sheet-8d6f20b09b5e",
"sheet-3848c3443c4e",
"sheet-ff87178ef296",
"sheet-5819e3882bec",
"sheet-aba89201ba1e"
]
},
{
"comment": "comment-pfhmw5d",
"form": [
"sheet-b03b79966bdb"
]
},
{
"comment": "comment-pgzz9hc",
"form": [
"sheet-344751923fc3"
]
}
]
}
-737
View File
@@ -1,737 +0,0 @@
{
"_about": "The answers inside each bonding encounter, transcribed by hand from the community route PDF (see source). Data, not the flowchart: each option's answer (say), the guide's printed rate (pct), whether it is on the guide's recommended dark-tile path (best), whether the guide marks it untested or unconfirmed (unconfirmed), and what follows (then) or how it ends (end); roll marks a step the guide calls an unknown chance or decision. route_encounters: which encounters each bonding encounter of the route model shows. Edit this file when the PDF changes (the daily check opens a pull request on the bot's repo when it does).",
"version": 1,
"source": {
"title": "Threshing Options (community route PDF)",
"authors": [
"u/ClumsyBadger",
"u/Old_Regular3018",
"u/Smart_Trifle_2099"
],
"version": "2026-11-16",
"link": "https://drive.google.com/file/d/17o72ehHsSPW4UdsKF-sXTxMLEuinWeEg/view",
"note": "Percentages are the guide's, from documented runs; options off the recommended path often rest on fewer than three records."
},
"encounters": {
"valley-Red": {
"title": "The valley Red",
"scene": "You're moved by an instinctual feeling that this...",
"options": [
{
"say": "Is your dragon",
"best": true,
"then": [
{
"say": "You're sure",
"best": true,
"then": [
{
"say": "Continue approach",
"best": true,
"then": [
{
"say": "Touch its talon",
"best": true,
"pct": "93%",
"end": "Bonded"
},
{
"say": "Run to mount its foreleg",
"end": "Bonded"
}
]
},
{
"say": "Exit gracefully",
"end": "That was close (on to the meadow)"
}
]
},
{
"say": "On second thought…",
"end": "That was close (on to the meadow)"
}
]
},
{
"say": "Is not your dragon, leave",
"end": "That was close (on to the meadow)"
}
]
},
"tree-Red": {
"title": "The Red below the tree",
"scene": "A red dragon prowls ten feet beneath you.",
"warning": "The guide gives a 98% chance of dying if you engage this dragon.",
"options": [
{
"say": "Jump on its back, or jump to land by its tail",
"then": [
{
"roll": "Some unknown chance or decision roll"
},
{
"say": "Hold the Red's gaze",
"then": [
{
"say": "Jump off and hope",
"end": "Incinerated"
},
{
"say": "Drop to your stomach",
"then": [
{
"say": "Hang tight",
"end": "Incinerated"
},
{
"say": "Crawl to the seat",
"pct": "2%",
"end": "Bonded"
}
]
}
]
},
{
"say": "Lower your eyes",
"end": "Incinerated"
}
]
},
{
"say": "Wait and pursue the Green",
"end": "On to the two Greens"
}
]
},
"tree-Greens": {
"title": "The two Greens",
"scene": "You enter a clearing with two Green dragons.",
"options": [
{
"say": "Turn to the right dragon",
"best": true,
"then": [
{
"say": "Glance to the left dragon",
"end": "Incinerated"
},
{
"say": "Don't move a muscle",
"best": true,
"then": [
{
"say": "Stay still",
"best": true,
"then": [
{
"say": "Decapitation isn't scary",
"best": true,
"then": [
{
"say": "You respect their nature",
"best": true,
"end": "Bonded (Right Green)"
},
{
"say": "You don't know",
"end": "Incinerated"
},
{
"say": "Greens have the best magic",
"best": true,
"end": "Bonded (Left Green)"
},
{
"say": "Intellect match",
"best": true,
"end": "A Brown saves you: Bonded (Brown)"
}
]
},
{
"say": "Sidestep out of its mouth",
"end": "Incinerated"
}
]
},
{
"say": "Sidestep out of its mouth",
"end": "Incinerated"
}
]
}
]
},
{
"say": "Turn to the left dragon",
"best": true,
"then": [
{
"say": "Glance to the right dragon",
"end": "Incinerated"
},
{
"say": "Don't move a muscle",
"best": true,
"then": [
{
"say": "Hold your ground",
"best": true,
"then": [
{
"say": "You always overextend",
"best": true,
"end": "Bonded (Right Green)"
},
{
"say": "You lack flaws",
"end": "Incinerated"
},
{
"say": "You struggle with temper",
"best": true,
"end": "Bonded (Left Green)"
},
{
"say": "You're always right",
"best": true,
"end": "An Orange saves you: Bonded (Orange)"
}
]
},
{
"say": "Step back",
"end": "Incinerated"
}
]
}
]
},
{
"say": "Stay neutral",
"end": "Incinerated"
}
]
},
"meadow-Orange": {
"title": "The meadow Orange",
"scene": "You approach the Orange dragon.",
"options": [
{
"say": "Absolutely sure, Orange",
"best": true,
"pct": "90%",
"then": [
{
"say": "Roar right back at it",
"best": true,
"pct": "69%",
"then": [
{
"say": "Flee",
"end": "Incinerated"
},
{
"say": "Attempt to mount",
"best": true,
"end": "Bonded"
},
{
"roll": "Possibly an unknown decision or chance mechanic (20%)"
},
{
"say": "Hit the ground",
"best": true,
"then": [
{
"say": "Run to mount its foreleg",
"best": true,
"end": "Bonded"
},
{
"say": "Look it in the eye",
"then": [
{
"say": "Run to mount",
"end": "Bonded"
},
{
"say": "Maintain eye contact",
"end": "Incinerated"
}
]
}
]
},
{
"say": "Run at the claw",
"then": [
{
"say": "Hold tight for balance",
"end": "Incinerated"
},
{
"say": "Climb with strength",
"end": "Bonded"
}
]
}
]
},
{
"say": "Run, this was a mistake",
"end": "Incinerated"
}
]
},
{
"say": "On second thought…",
"pct": "10%",
"end": "Incinerated"
}
]
},
"meadow-Brown": {
"title": "The meadow Brown",
"scene": "You approach the Brown dragon.",
"options": [
{
"say": "Run after the Brown",
"best": true,
"then": [
{
"say": "On second thought…",
"end": "Incinerated"
},
{
"say": "Your heart is sure",
"best": true,
"then": [
{
"say": "Shout at it to stop",
"pct": "50%",
"then": [
{
"say": "Apologise immediately",
"pct": "50%",
"end": "Incinerated"
},
{
"say": "Await judgment, or pray",
"pct": "90%",
"then": [
{
"say": "Mud fight!",
"then": [
{
"say": "Wipe off the mud",
"pct": "90%",
"then": [
{
"say": "The dragon speaks",
"then": [
{
"say": "Defend the kingdom",
"end": "Death 50/50"
},
{
"say": "Defend the powerless",
"end": "Bonded"
},
{
"say": "Seek revenge",
"end": "Incinerated"
}
]
}
]
},
{
"say": "Throw mud at the dragon",
"pct": "60%",
"end": "Bonded"
},
{
"say": "Find a better dragon",
"end": "Not recorded"
}
]
}
]
}
]
},
{
"say": "Indecisively chase it",
"end": "Incinerated"
},
{
"say": "Mount the Brown's tail",
"best": true,
"then": [
{
"say": "Throw your weight",
"best": true,
"then": [
{
"say": "You'll charm it",
"best": true,
"end": "Bonded"
},
{
"say": "Hope for a clean death",
"end": "Incinerated"
},
{
"say": "It's already talking to you",
"end": "Bonded"
}
]
},
{
"say": "Wait for a better angle",
"end": "Incinerated"
}
]
}
]
}
]
},
{
"say": "Turn to the Orange",
"end": "Incinerated"
}
]
},
"meadow-Blue": {
"title": "The meadow Blue",
"scene": "You approach the Blue dragon.",
"options": [
{
"say": "Change to Orange",
"pct": "?",
"unconfirmed": true,
"end": "Not tested"
},
{
"say": "Change to Brown",
"pct": "?",
"unconfirmed": true,
"end": "Not tested"
},
{
"say": "Absolutely, Blue Dragon",
"best": true,
"pct": "90%",
"then": [
{
"say": "Hold glare and advance",
"best": true,
"pct": "80%",
"then": [
{
"say": "Do nothing",
"best": true,
"pct": "83%",
"then": [
{
"say": "Lower your eyes",
"pct": "?",
"unconfirmed": true,
"end": "Incinerated"
},
{
"say": "Help the cadet",
"pct": "0%",
"end": "Incinerated"
},
{
"say": "Hold glare and watch",
"best": true,
"pct": "80%",
"then": [
{
"say": "Straighten your spine",
"best": true,
"pct": "82%",
"then": [
{
"say": "Hold steady",
"pct": "0%",
"unconfirmed": true,
"end": "Incinerated"
},
{
"say": "Launch yourself right",
"best": true,
"pct": "85%",
"then": [
{
"say": "You already know",
"pct": "?",
"unconfirmed": true,
"end": "Not tested"
},
{
"say": "Bring down an empire",
"best": true,
"pct": "80%",
"then": [
{
"say": "Seize the chance to mount",
"pct": "50%",
"end": "Incinerated"
},
{
"say": "Move slowly forward",
"best": true,
"pct": "80%",
"end": "Bonded"
},
{
"say": "Hold still",
"pct": "50%",
"end": "Incinerated"
}
]
},
{
"say": "I want revenge",
"pct": "?",
"unconfirmed": true,
"end": "Not tested"
},
{
"say": "Defend the helpless",
"pct": "?",
"unconfirmed": true,
"end": "Not tested"
}
]
}
]
},
{
"say": "Speak first",
"pct": "20%",
"end": "Incinerated"
},
{
"say": "Do nothing",
"pct": "?",
"end": "Incinerated"
}
]
}
]
},
{
"say": "Intervene and help",
"pct": "?",
"end": "Incinerated"
}
]
},
{
"say": "Lower gaze, halt advance",
"pct": "0%",
"end": "Incinerated"
},
{
"say": "Lower gaze, advance",
"pct": "0%",
"end": "Incinerated"
}
]
}
]
},
"shadow": {
"title": "The shadow",
"scene": "You've seen a shadow, where will it lead...",
"options": [
{
"say": "A green sounds good",
"unconfirmed": true,
"end": "Not tested"
},
{
"say": "Stay the course",
"best": true,
"then": [
{
"say": "Well this is intriguing",
"best": true,
"then": [
{
"say": "Curiosity sated, retreat",
"then": [
{
"say": "Find that Green",
"end": "On to the two Greens"
},
{
"say": "Go towards the valley",
"unconfirmed": true,
"end": "Not tested"
}
]
},
{
"say": "Freeze and lower your eyes",
"best": true,
"then": [
{
"say": "Warn the cadet",
"end": "Incinerated"
},
{
"say": "Hold still",
"best": true,
"then": [
{
"say": "Aid the cadet",
"unconfirmed": true,
"end": "Not tested"
},
{
"say": "Hold position",
"best": true,
"then": [
{
"say": "Approach the Blue",
"then": [
{
"say": "On second thought…",
"unconfirmed": true,
"end": "Not tested"
},
{
"say": "You're sure",
"unconfirmed": true,
"end": "Incinerated?"
}
]
},
{
"say": "Await judgement",
"best": true,
"then": [
{
"say": "Help the cadet",
"best": true,
"then": [
{
"say": "Use your dagger",
"best": true,
"then": [
{
"say": "Head south and hope",
"best": true,
"end": "On to the Black"
}
]
},
{
"say": "Take them to cold water",
"end": "Head back for the Greens, or explore other dragons"
},
{
"say": "Clean their uniform",
"end": "Head back for the Greens, or explore other dragons"
}
]
},
{
"say": "Leave to find your dragon",
"end": "Head back for the Greens, or explore other dragons"
}
]
},
{
"say": "Run towards the other cadet",
"unconfirmed": true,
"end": "Not tested"
}
]
},
{
"say": "Last chance to escape",
"end": "Head back for the Greens, or explore other dragons"
}
]
},
{
"say": "Leave while it's distracted",
"end": "Head back for the Greens, or explore other dragons"
}
]
}
]
},
{
"say": "Too big, you're out",
"end": "Head back for the Greens, or explore other dragons"
}
]
}
]
},
"black": {
"title": "The Black",
"scene": "A branch snaps behind you...",
"note": "Lowering your eyes has frequently ended in incineration; what follows it is unconfirmed.",
"options": [
{
"say": "Ignore it, keep walking",
"end": "Incinerated"
},
{
"say": "Turn to face the threat",
"best": true,
"then": [
{
"say": "Lower your eyes",
"end": "Incinerated"
},
{
"say": "Hold its gaze",
"best": true,
"end": "Bonded"
}
]
}
]
}
},
"route_encounters": {
"valley-Red": [
"valley-Red"
],
"tree-Red": [
"tree-Red"
],
"tree-Greens": [
"tree-Greens"
],
"meadow-Orange": [
"meadow-Orange"
],
"meadow-Brown": [
"meadow-Brown"
],
"meadow-Blue": [
"meadow-Blue"
],
"shadow-Blue": [
"shadow"
],
"shadow-Black": [
"shadow",
"black"
]
}
}
-1
View File
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+10
View File
@@ -0,0 +1,10 @@
{
"repo": "https://git.kenschiano.net/YOUR-GITEA-USERNAME/threshing-atlas",
"repo_label": "git.kenschiano.net/YOUR-GITEA-USERNAME/threshing-atlas",
"host": "git.kenschiano.net",
"kind": "gitea",
"visibility": "limited",
"report": "https://git.kenschiano.net/YOUR-GITEA-USERNAME/threshing-atlas/issues/new?template=.github/ISSUE_TEMPLATE/report-a-run.yml",
"form": "https://forms.gle/DRpj9tG8gb5E4Hcu7",
"sheet": "https://docs.google.com/spreadsheets/d/1gnw1AdRg1XT4JsOfRM6QTA0jSaS3n9ZF-rPWnYewzv0"
}
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+1
View File
@@ -0,0 +1 @@
{"source":"Runs reported on the Atlas (\"Report a run\", a GitHub issue form)","reports":[]}
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
-11303
View File
File diff suppressed because it is too large Load Diff
-1
View File
File diff suppressed because one or more lines are too long
-2610
View File
File diff suppressed because it is too large Load Diff
-97
View File
@@ -1,97 +0,0 @@
/*
* Rolls of the dice. Wherever the page shows a step the game decides at random (not the rider's choice), a pair of
* dice sits next to it. Clicking the dice shows the odds of every outcome of that roll.
*
* Dice.html(roll) an inline button for HTML text
* Dice.svg(parent, x, y, roll) the same glyph inside an SVG map
* Dice.legend(text?) the legend line ("a roll: the game decides ...")
*
* roll = { title, options: [[label, p], ...], note?, n? } (p between 0 and 1; options may be empty with a note)
*/
(function () {
"use strict";
const NS = "http://www.w3.org/2000/svg";
// two dice, the back one showing two, the front one five
const GLYPH = `<svg class="dice-glyph" viewBox="0 0 22 16" width="22" height="16" aria-hidden="true">
<rect x="1" y="1.5" width="10" height="10" rx="2.2" transform="rotate(-12 6 6.5)" fill="var(--raised)" stroke="currentColor" stroke-width="1.2"/>
<circle cx="4" cy="4.8" r="1.05" fill="currentColor" transform="rotate(-12 6 6.5)"/><circle cx="8" cy="8.6" r="1.05" fill="currentColor" transform="rotate(-12 6 6.5)"/>
<rect x="9.5" y="4.5" width="10.5" height="10.5" rx="2.2" fill="var(--raised)" stroke="currentColor" stroke-width="1.2"/>
<circle cx="12.4" cy="7.4" r="1.05" fill="currentColor"/><circle cx="17.1" cy="7.4" r="1.05" fill="currentColor"/>
<circle cx="14.75" cy="9.75" r="1.05" fill="currentColor"/>
<circle cx="12.4" cy="12.1" r="1.05" fill="currentColor"/><circle cx="17.1" cy="12.1" r="1.05" fill="currentColor"/></svg>`;
const TIP = "A roll: the game decides, not you. Click for the odds of each outcome.";
const esc = (s) => String(s).replace(/[&<>"]/g, (c) => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;" }[c]));
const pack = (roll) => encodeURIComponent(JSON.stringify(roll || {}));
const pct = (p) => (p == null ? "–" : p < 0.001 && p > 0 ? "<0.1%" : `${(100 * p).toFixed(p < 0.1 ? 1 : 0)}%`);
function html(roll) {
return `<button type="button" class="dice" data-roll="${pack(roll)}" title="${TIP}" aria-label="${esc((roll && roll.title) || "A roll")}: show the odds">${GLYPH}</button>`;
}
function svg(parent, x, y, roll) {
const g = document.createElementNS(NS, "g");
g.setAttribute("class", "dice dice-svg");
g.setAttribute("data-roll", pack(roll));
g.setAttribute("transform", `translate(${x - 11},${y - 8})`);
g.setAttribute("tabindex", "0");
g.setAttribute("role", "button");
g.setAttribute("aria-label", `${(roll && roll.title) || "A roll"}: show the odds`);
const t = document.createElementNS(NS, "title");
t.textContent = TIP;
g.appendChild(t);
const halo = document.createElementNS(NS, "rect");
for (const [k, v] of Object.entries({ x: -3, y: -3, width: 28, height: 22, rx: 6, fill: "var(--map-halo, var(--bg))", "fill-opacity": 0.9 })) halo.setAttribute(k, v);
g.appendChild(halo);
g.insertAdjacentHTML("beforeend", GLYPH.replace(/^<svg[^>]*>/, "").replace(/<\/svg>$/, ""));
parent.appendChild(g);
return g;
}
function legend(text) {
return `<span class="dice-legend">${GLYPH.replace('class="dice-glyph"', 'class="dice-glyph legend" style="display:inline-block;vertical-align:-3px"')} ${text || "= a roll: the game decides at random, not your choice. Click any dice for the odds of each outcome."}</span>`;
}
// ---- the popover
let pop = null;
function hide() { if (pop) pop.hidden = true; }
function show(roll, x, y) {
if (!pop) {
pop = document.createElement("div");
pop.id = "dice-pop";
pop.setAttribute("role", "dialog");
document.body.appendChild(pop);
}
const opts = (roll.options || []).filter(([, p]) => p != null).sort((a, b) => b[1] - a[1]);
pop.innerHTML = `<b>${esc(roll.title || "A roll")}</b>
${opts.length ? `<ul>${opts.map(([k, p]) => `<li><span>${esc(k)}</span><span class="bar"><i style="width:${Math.max(1, 100 * p).toFixed(1)}%"></i></span><span class="p">${pct(p)}</span></li>`).join("")}</ul>` : ""}
<p>${esc(roll.note || "The game decides this at random. Your earlier choices can change the odds, but not the outcome.")}${roll.n ? ` From ${Number(roll.n).toLocaleString()} runs.` : ""}</p>`;
pop.hidden = false;
const r = pop.getBoundingClientRect();
pop.style.left = `${Math.max(8, Math.min(window.innerWidth - r.width - 8, x - r.width / 2))}px`;
pop.style.top = `${y + 14 + r.height > window.innerHeight ? Math.max(8, y - r.height - 14) : y + 14}px`;
}
function open(e, t) {
e.preventDefault();
e.stopPropagation();
let roll = {};
try { roll = JSON.parse(decodeURIComponent(t.getAttribute("data-roll"))); } catch { /* an empty roll */ }
const b = t.getBoundingClientRect();
show(roll, b.left + b.width / 2, b.bottom - 6);
}
// capture phase: a dice inside a map or a card must not also select what is under it
document.addEventListener("click", (e) => {
const t = e.target.closest && e.target.closest("[data-roll]");
if (t) return open(e, t);
if (pop && !pop.hidden && !pop.contains(e.target)) hide();
}, true);
document.addEventListener("keydown", (e) => {
if (e.key === "Escape") return hide();
const t = (e.key === "Enter" || e.key === " ") && e.target.closest && e.target.closest(".dice-svg[data-roll]");
if (t) open(e, t);
}, true);
window.addEventListener("scroll", hide, { passive: true });
window.Dice = { html, svg, legend };
})();
+152
View File
@@ -0,0 +1,152 @@
# Bot data protocol
How the DragonKind bot should run and log its threshing attempts so that the Threshing Atlas can
estimate route probabilities, including history effects, and find the best route to each dragon colour.
Goal: bond a Blue and bond a Black, and know the best route for every colour.
## 1. Why the bot matters
Community data are observational. People copy routes from guides, so most choices are correlated
with each other and with what people chose to report. That correlation is copied behaviour, not game
mechanics. Only the bot can choose at random, and random assignment is what tells us that an earlier
choice *causes* a later dragon to appear. The bot is the experiment. The community data are the prior.
Two facts shape everything below:
- **An attempt is the scarce resource.** Each one costs a cooldown, and a bond is permanent for that
account. A run must never risk bonding the wrong colour.
- **Seeing a dragon is usually not the same as bonding it.** If the colour is visible before the step
where the player commits, the bot can record what appeared and then burn deliberately. Spawn rates
for every colour can then be learned without using up an account. Only the final "does this choice
actually bond?" step needs real bonds, and that step is close to deterministic.
## 2. What to log
`src/runhistory.js` already records one structured record per attempt. That is the right shape. These
additions turn it into data the solver can use. The most important ones come first.
| # | Field | Why |
|---|-------|-----|
| 1 | `steps[].offered`: every option on screen, as `[{text, norm, hash}]`, plus the index that was picked | Shows "every option at every point", and detects options that only appear after certain earlier choices (that is itself history dependence) |
| 2 | `steps[].observed`: what the scene showed, e.g. `{dragons: ["red"], shadow: false, cadetWounded: true}` | Chance outcomes are the core data. Today a burned run has `dragonColor: null`, and the tree check does not say whether the shadow was there |
| 3 | `steps[].propensity`: the probability with which the bot picked this option (1.0 for a fixed rule, 0.5 for a coin flip) | Lets runs from different policies be pooled without bias (inverse-propensity weighting) |
| 4 | `policyId` / `experimentId` / `arm` per run, plus `botCommit` (git short hash) | Says which policy or experiment produced the run. The learner changes over time, so this is not optional |
| 5 | `burn: {reason, stage, nodeId}` for intentional burns | A deliberate burn cuts the run short on purpose (censoring). The model must know where and why |
| 6 | `accountKey`: a salted hash of the account id, plus `accountAttempt` (that account's attempt number) | Separates account effects from route effects. Never log the account name or email |
| 7 | `startedAt` in UTC, plus the in-game hour if the scene shows one | Time-of-day and patch effects |
| 8 | `manual: true` on any step a human picked, and `decisionMode` on every step (not only the run) | `ai_pilot` and manual picks have no known propensity, so they are analysed separately |
| 9 | `ABORTED` runs kept, with `abortReason` | Dropping failures biases rates |
| 10 | `sceneFp` (the existing sha1 node id) and a short `label` | The public data carry fingerprints and labels only, never the game's prose |
A step would then look like this:
```json
{
"nodeId": "bc4ee4754b9c", "stage": "FIRST_SIGHTING", "label": "first sighting, forest centre",
"observed": { "dragons": ["brown"] },
"offered": [
{ "norm": "lower your eyes in respect", "hash": "9a1c…" },
{ "norm": "meet its gaze", "hash": "41fe…" }
],
"picked": 0, "propensity": 0.5, "decisionMode": "explore", "rule": "EXP-03:arm-A",
"outcome": "SCENE", "toKey": "84780dab01e3", "at": "2026-11-01T21:03:11Z"
}
```
Parsing `observed` from the prose can start as simple keyword rules (colour words, "shadow", "wounded")
kept in one table. The atlas will flag scenes where the rules return nothing.
## 3. How to run the accounts
### Two kinds of account
- **Goal accounts** (the ones meant to bond Blue or Black) run the current best policy for their target
colour from `policy.json`, with the existing Account Lock Guard and intentional-burn protection.
They still log everything. Their runs are data too, with propensity 1.0.
- **Research accounts** run experiments. They also never accept a non-target bond. They observe and
then burn. If one reaches a genuine Blue or Black bonding choice, that is a real result: let it bond
and log it.
### Freeze the policy during an experiment
`auto_learn` rewrites its own rules from its own results. While an experiment is running, that mixes up
the effect of the experiment with the bot's learning, and makes the data non-stationary. For research
runs, use `explore` with a fixed experiment file, and record `policyId`. Update the policy between
batches, not during them.
### Randomize one decision point against a fixed baseline
- The **baseline** is the community guide route (the PDF route) for the target colour.
- In an experiment, exactly one decision point (or two, in a 2×2 design) is chosen by a coin flip with
a known probability. Everything else follows the baseline.
- Assign arms in **balanced blocks per account** (for example A, B, B, A, …), so every account
contributes equally to both arms.
- Use **pre-set run counts**. Do not stop because the results look good: stopping early on a good run
inflates the effect.
- Do not use `ai_pilot` for research runs. If it is used, the runs are tagged and kept out of the
causal estimates.
### Phases
1. **Mapping (first week or two).** At every decision point, try each option a few times (about 5 to 10)
so that every branch has at least been seen. This finds hidden options, dead ends and death scenes.
It uses few runs, because the bot can burn as soon as a branch has been recorded.
2. **Spawn rates (ongoing, nearly free).** Every run records which dragon appeared at the first
sighting, the meadow and the valley, and whether the shadow was at the tree. This builds the
colour-by-location table for all six colours as a by-product.
3. **Targeted experiments.** The atlas produces an experiment list (`experiments.json`), ranked by how
much each result could change the best route for each colour. That ranking is a value-of-information
calculation. The bot runs the top items.
### Blue and Black need different strategies
**Blue (meadow, roughly 10% of meadow visits).** The question is whether anything earlier changes the
Blue rate at the meadow: company, direction, how you met the first dragon, what happened with the
cadets. Each research run goes to the meadow, records the colour, and burns unless it is Blue. Telling a
10% rate from a 20% rate needs about **200 runs per arm**. That is achievable across a few accounts over
a few weeks.
**Black (tree shadow, roughly 1%).** Too rare for full factorial experiments. Instead:
- Take the **shortest route to the tree check**, and burn immediately when there is no shadow. This is
what the bot already does, and it maximizes tree visits per day.
- At the same time, randomize **one** earlier factor 50/50 on every run, so each tree visit also counts
towards a test. Run that one test until it reaches its planned count, then move on to the next factor.
- Log the tree scene's fingerprint and options carefully even when there is no shadow. A change in the
prose or options may be an early sign.
- Telling 1% from 2% needs thousands of runs per arm. This is where pooling with community logs, and
later Discord, will matter most.
### Other colours
Red, Brown, Orange and Green come mostly from the spawn-rate logging in phase 2. Green also needs the
rescue branch (the wounded cadet) to be tried in both directions in phase 1.
## 4. Getting data to the atlas
- The atlas repo already has the exporter: `DRAGONKIND_BOT_DIR=/path/to/DragonKind python -m collection update --source bot`. It reads
`data/knowledge.json`, `data/runs.jsonl` and `logs/encounters.jsonl` from the bot folder and writes
`data/bot/scenes.json` and `data/bot/trajectories-<date>.jsonl`, with:
- prose removed (scene fingerprints, short labels, choice text and outcomes only). The importer
refuses to write any field or string that looks like prose,
- account ids replaced by salted hashes. Set `DK_ACCOUNT_SALT` in your environment; never commit it,
- nothing read from `.browser-profile*/`, `data/accounts.json`, `data/integrations.json` or
`data/state.json`.
- Its scene fingerprints are computed exactly as the bot's `computeSceneFingerprint()` does, so they
match the bot's node ids. If the bot's `normalize()` or fingerprint changes, the importer must change too.
- Commit the result to `threshing-atlas` by pull request. CI rebuilds the graph and runs the tests.
- In return, the atlas publishes `policy.json` (the best decision tree per colour, under both goals)
and `experiments.json`. The bot reads them as a strategy source. The bot's own guards still have the
final say.
## 5. Checklist for Ken
- [ ] Add `offered`, `picked`, `observed`, `propensity` and per-step `decisionMode` to `noteChoice()`.
- [ ] Add `policyId`, `experimentId`, `arm`, `botCommit`, `accountKey` and `accountAttempt` to `beginRun()`.
- [ ] Add `burn.reason` and `abortReason` to `endRun()`.
- [ ] Write the keyword table that fills `observed` (dragon colours, shadow, wounded cadet).
- [ ] Add an `explore` mode that reads an experiment file, assigns arms in balanced blocks per account, and freezes learning.
- [ ] Add the export script, with the account salt in `.env`.
- [ ] Split the accounts into goal accounts and research accounts.
- [ ] Run phase 1 (mapping). Then keep phase 2 logging on for every run, goal accounts included.
+209
View File
@@ -0,0 +1,209 @@
# Connecting the DragonKind bot to the atlas
Data flows both ways:
```
community sources, reports ─────┐
├─► threshing-atlas ──► policy.json + solver.js ──► bot (advice per screen)
bot runs (anonymised) ──────────┘ ▲ │
└──────────── collection --source bot + PR ◄┘
```
## From the Atlas's Gitea repository
Both repositories live on git.kenschiano.net. The bot can read the atlas files straight from the repository with a
Gitea token that can read it (the repository is "limited": signed-in users only), instead of a zip:
```
https://git.kenschiano.net/<owner>/threshing-atlas/raw/branch/main/data/public/policy.json
https://git.kenschiano.net/<owner>/threshing-atlas/raw/branch/main/core/solver.js
https://git.kenschiano.net/<owner>/threshing-atlas/raw/branch/main/core/graph.js
```
(header `Authorization: token <token>`). Keep the three files together: solver.js reads the game from policy.json.
## Without a shared repository: swapping zips
When GitHub Pages is not available, the same files travel as zips:
- **Atlas → bot:** `python -m collection export-bot-kit` writes `exports/atlas-for-bot-<date>-<policy id>.zip`
(`policy.json`, `solver.js`, `graph.js`, a README with checksums). Unzip it into the bot's `vendor/threshing-atlas/`.
- **Bot → atlas:** zip the bot's `data/` and `logs/` folders (folder names kept; a zip of the whole repo works too;
screenshots are not needed) and send it. The importer reads `data/knowledge.json` and, for every account,
`data/accounts/<account>/runs.jsonl` and `logs/accounts/<account>/encounters.jsonl` (with one folder per
account, the top-level `data/runs.jsonl` and `logs/encounters.jsonl` mirror the first account and are skipped).
Run records that carry their own steps (the bot's schema 2) are used as they are, including what the bot saw
(shadow, meadow dragons), its decision mode and the policy id; older runs are rebuilt from the decision log.
Account names become salted hashes. Put it in the atlas's `inbox/` and run
`python -m collection refresh --bot inbox/<the zip>`: it imports the runs (anonymised: no prose, no account names),
rebuilds everything, and then `export-bot-kit` makes the new zip to send back.
## 1. From the atlas to the bot
### What is published
GitHub Pages serves these files (they update whenever new data is merged):
| File | What it is |
|---|---|
| `https://ekcschiano.github.io/threshing-atlas/data/policy.json` | The model: count tables, fitted shrinkage, allowed options, and for every colour the recommended decision tree under both objectives, with credible intervals. About 400 KB. Has an `id` (content hash). |
| `https://ekcschiano.github.io/threshing-atlas/solver.js` | The solver and the bot helper (`advisor`, `recommendOption`, `solverHistory`). No dependencies, CommonJS or browser. |
| `https://ekcschiano.github.io/threshing-atlas/graph.js` | `trajectoryVariables()`: turns the bot's step trail into the community form's variables. |
### Getting them into the bot
Keep a pinned local copy, so a bad publish can never change the bot mid-run. A small sync script in the bot
repo (for example `scripts/sync-atlas.js`):
```js
// node scripts/sync-atlas.js -> vendor/threshing-atlas/{solver.js,graph.js,policy.json}
const fs = require('node:fs');
const path = require('node:path');
const BASE = 'https://ekcschiano.github.io/threshing-atlas/';
const OUT = path.join(__dirname, '..', 'vendor', 'threshing-atlas');
(async () => {
fs.mkdirSync(OUT, { recursive: true });
for (const f of ['solver.js', 'graph.js', 'data/policy.json']) {
const res = await fetch(BASE + f);
if (!res.ok) throw new Error(`${f}: HTTP ${res.status}`);
const body = await res.text();
if (f.endsWith('.json')) JSON.parse(body); // refuse a broken file
fs.writeFileSync(path.join(OUT, path.basename(f)), body);
}
const { id } = JSON.parse(fs.readFileSync(path.join(OUT, 'policy.json'), 'utf8'));
console.log('atlas policy', id);
})();
```
Run it by hand, or once a day before the first attempt. Commit `vendor/threshing-atlas/` in the bot repo if you
want the exact policy in its history.
### What changed in November 2026
The calls above are unchanged, but `solver.js` is now a small advisor (about 250 lines) that reads the game itself
from `policy.json` (`samples.*.model.game`, from `core/spec/game.yaml`) instead of having it written into the code.
For the bot that means:
- Histories (`h`) use the game's step names: `company`, `leave`, `direction`, `fs`, `react`, `scream`, `clearing`,
`fight`, `dagger`, `fate` or `wounded`, `post`, `hour`, `shadow`, `shadowColour`, `descend`, `red`, `valley`,
`meadow`, `encounter`. `solverHistory()` already produces these; the old `cadet` and `left` keys are no longer read.
- New choices the bot will be asked about: leaving your squadmates (`leave`), how you react to the first dragon
(`react`), and, below the tree, jumping onto the Red or letting it pass (`red`). The text the bot sees for each
option is in `game.yaml` under `bot_text`, so new screens can be matched by editing that file.
- If a history skips a decision but already has a later step (an older record, say), the recommended option is
assumed for the skipped one.
- Re-sync `solver.js`, `graph.js` and `policy.json` together: the new `solver.js` needs the game inside the new
`policy.json`.
### Asking for advice on a screen
```js
const Solver = require('../vendor/threshing-atlas/solver.js');
const Graph = require('../vendor/threshing-atlas/graph.js');
const policy = require('../vendor/threshing-atlas/policy.json');
// once per attempt: target colour from settings, "eventually" because the bot burns on purpose
const advisor = Solver.advisor(policy.samples.all, 'Black', 'eventually');
// on every decision screen
function atlasAdvice(run, offeredChoiceTexts, seen) {
const { vars } = Graph.trajectoryVariables({ steps: run.steps, outcome: {} });
const h = Solver.solverHistory(vars, seen); // seen: { shadow: 'yes'|'no', shadowColour, meadow }
return Solver.recommendOption(advisor, h, offeredChoiceTexts);
}
```
`recommendOption` returns `null` when the next step is chance (nothing to decide), or
`{ index, decision, choice, margin, options, reason }`:
- `index` is the option to click, or `null` when the advice cannot be matched to this screen. Then use the bot's own rules.
- `decision === 'encounter'` comes without an index: `choice` is `"Attempt the bond"` or `"Die on purpose"`, and the
bot already knows which of its options do each.
- `margin` is the gap in P(target) between the best and second-best option. `options` has every option's value.
`seen` is what only the bot can observe: whether the shadow was at the treetop (`shadow: 'yes' | 'no'`), its colour
(`shadowColour`), and the colour waiting in the meadow (`meadow`), all from the scene tint.
The advisor re-solves the model on the bot's machine (a few milliseconds), so it gives advice from any history,
including runs that have already left the recommended route.
### Where it goes in the decision order
The atlas is advice. The bot's own safety rules stay in charge:
1. Account Lock Guard and the intentional-burn protection (never risk a non-target bond).
2. Atlas advice, when `index` is not null and the margin is clear (see ties below).
3. The bot's PDF strategy and learned rules.
Log every atlas pick with `rule: 'ATLAS_POLICY'`, `source: 'atlas'`, and the run-level `policyId: policy.id`
(see `docs/BOT_DATA_PROTOCOL.md`), so we can tell which policy produced which runs.
### Learning: goal accounts follow the best route, research accounts sample
The atlas learns from the bot's own runs: every zip of the bot's data that is imported adds its rolls (first dragon,
deaths, the shadow, the meadow dragon, bond results) to the route model, and the next `atlas-for-bot` zip carries
the updated model. Deliberate burns (Malek, "no shadow", "no Blue") never count as failed bond attempts.
How the bot should choose depends on the account's role:
- **Goal accounts** (`accountRole: "goal"`): the best route under the model, as before:
`Solver.advisor(policy.samples.all, target, 'eventually')`.
- **Research accounts** (`accountRole: "research"`): Thompson sampling. Make a new advisor for every attempt with a
new seed:
```js
const adv = Solver.advisor(policy.samples.all, target, 'eventually', { sampling: 'thompson', seed: attemptNumber });
```
Each attempt follows the best route of one plausible version of the odds, drawn from the model's uncertainty. An
option that might be the best one gets tried about as often as it is likely to be the best, so the attempts go
where the model is least sure; as the data firm up, sampling settles on the best route by itself.
`recommendOption()` then returns a `propensity` (the chance this option was picked, from 40 other draws; set
`draws` to change that). Log it on the step with `decisionMode: "atlas_thompson"`, so the runs can be re-weighted.
Making the advisor takes a few seconds per attempt (it solves the game once per draw).
The tie rule below still works for goal accounts; research accounts don't need it.
### Ties are free experiments
### Which numbers to trust
`policy.json` has two samples:
- `samples.all`: every run. Use it for the advisor (more data, decisions are about relative differences).
- `samples.lowBias`: bulk logs and riders not chasing a rare dragon. Use it for absolute expectations, such as how
many attempts a Blue should take. Rare sightings are over-reported in form posts, so `all` is optimistic for Blue.
Current headline, with the bot's runs and the reporting-bias correction (November 2026): Black about 0.03% per
attempt (90% range 0–0.15%: the bot and bulk logs have never seen the shadow in about 700 tree runs), Blue about
1.8–2.5% per attempt (40–55 attempts), depending on the sample.
The shadow is gated: it can only appear on runs that investigated the scream and helped the squadmate (the
"Black Dragon Gates" of the community route PDF, and the runs agree). The model knows this
(`core/spec/game.yaml`, `requires`), so it never sends a Black attempt off the gate.
Form submissions over-report rare sightings: riders report a meadow Blue about 4 times more readily than a meadow
without one. The model estimates that bias for each kind of source and corrects for it (`planner/policy.yaml`,
`reporting_bias`; the estimates are in `policy.json` under `model.reportingBias`).
## 2. From the bot to the atlas
Already in place: `DRAGONKIND_BOT_DIR=/path/to/DragonKind python -m collection update --source bot` in the atlas repo converts the bot's
`knowledge.json`, `runs.jsonl` and `logs/encounters.jsonl` into anonymised files under `data/bot/`, and refuses to
write prose or account names. Commit them by pull request; CI rebuilds the graph and checks everything.
What would make the bot's data far more useful (details in `docs/BOT_DATA_PROTOCOL.md`):
- record the options on screen, what was seen (tint, shadow), `policyId`, `propensity` and `decisionMode` on every step;
- split goal accounts (follow the advisor) from research accounts (run the tie experiments and the
experiment list);
- add `accountKey` (salted hash), and the reason for every deliberate burn.
## 3. Limits to keep in mind
- The community form does not record the answers inside each bonding encounter, so the bond chance at an encounter is
the community average. The bot's own scene-level data will refine that over time.
- The model learns how much history matters from the data. Today it finds that the meadow colour does not depend on
earlier choices at all, and the shadow only weakly. The bot's randomised runs are what can confirm or overturn that.
- The policy is only as good as the crosswalk between the bot's screen text and the form's variables. If the game
changes its wording, `OPTION_PATTERNS` in `solver.js` and the crosswalk in `collection/specs/bot.yaml` (written into `graph.js` by `python -m collection build`) need updating.
+32
View File
@@ -0,0 +1,32 @@
# Dragon colours
Two palettes, one per background. Both were chosen so that every pair of dragon colours stays distinguishable for
readers with the common colour-vision deficiencies, not only with normal vision. Check them with:
```
python site/qa/check_colours.py
```
It reports CIEDE2000 colour differences for every pair under normal vision and simulated protanopia, deuteranopia and
tritanopia (Machado et al. 2009, full severity), and the contrast of each colour against its background.
| Dragon | Map ink (on the painted valley), `valley.js` `INK` | Page colour (on the dark page), `index.html` `--dr-*` |
|---|---|---|
| Red | `#cc3346` | `#e8435e` |
| Orange | `#e08a2a` | `#ff9533` |
| Brown | `#4e3020` | `#d1a47a` |
| Green | `#2f8f6f` (a blue-leaning green) | `#3fc0a8` |
| Blue | `#2a58b8` | `#7ea6ff` |
| Black | `#22182a` | `#e0d8ea` (silver, so it shows on the dark page) |
**Before this check**, the map's Red and Green were nearly identical under deuteranopia (difference 1.4), and on the dark
page Orange and Brown were too close even for normal vision (9.7). The worst pair is now about 12–13 on both palettes
(roughly "clearly different side by side").
What still relies on more than colour, on purpose:
- every dragon also has its own pose and sits in its own place on the map, and every route and card is labelled with
the dragon's name;
- text on the map is always dark ink; the dragon colour is used for lines, silhouettes and label borders only
(Orange and Green are too light to read as text on the paper background);
- silhouettes carry a paper-coloured halo so dark dragons stay visible on the dark canopy.
+44
View File
@@ -0,0 +1,44 @@
# Privacy and licences
Rules every part of the project follows. If a change would break one, stop and ask first.
## What may be published
- **Code** is MIT (`LICENSE`). **Data this project produces** is CC BY 4.0 (`DATA_LICENSE.md`). Third-party
sources keep their own terms.
- **Community form responses:** published as exported, with email addresses in free-text answers redacted by
the coding rules (`core/spec/form.yaml`, `core/atlas/coding.py`).
- **Dragon Register:** only `data/public/register.json`. The raw export has rider names and stays local
(`data/raw/register/` is git-ignored).
- **The community route PDF:** never committed or redistributed. Only a fingerprint
(`data/derived/pdf_fingerprint.json`) so we can tell when it changes, and a link to the original.
- **Bot data:** only scene fingerprints, short labels, choice text and outcomes. Never game prose, never account
names. The importer (`collection/etl/transform/bot.py`, rules in `collection/pipeline.yaml`) refuses to write anything that looks like either.
## The bot
- Ken's bot repository stays private. Only the anonymised import comes here.
- Account ids are salted and hashed. The salt (`DK_ACCOUNT_SALT`) lives in the environment and is never
committed.
- The bot's browser profiles, `.env` and credential files are never committed or shared.
## Sources we do not scrape
- **Discord:** not without the server admins' consent; never with a personal account token.
- **Reddit:** only through Reddit's official API with an app key (`REDDIT_CLIENT_ID` / `REDDIT_CLIENT_SECRET`),
never by page scraping. Only dragonkind.com result links are taken from the threads; usernames and comment text
are never kept, and each result page is read and added by hand (`collection/manual/reddit_results.yaml`).
## Run reports
"Report a run" creates an issue on the Atlas's repository (forge.yaml), visible to everyone who can see it. The pipeline keeps only the issue number, the date and the answers
(`data/public/reports.json`); GitHub usernames are dropped. The form asks people not to include account names. A
report closed as "not planned" or labelled `invalid` or `duplicate` is left out of the data.
## Secrets
- `ATLAS_BOT_TOKEN` (repository secret) lets the daily data update open and auto-merge its pull request
(`docs/REPO_SETTINGS.md`).
- `RAW_ARCHIVE_KEY` encrypts the raw store (the current and previous raw file of each source, which include the
register's rider names) in the Actions cache between daily runs. Without it nothing is archived.
- `REDDIT_CLIENT_ID` / `REDDIT_CLIENT_SECRET` let the daily update read the megathreads through the Reddit API. Tokens go in secrets only: never in a file, issue, chat or commit.
+262
View File
@@ -0,0 +1,262 @@
# Threshing Atlas: project context
A briefing for picking this project up in a new conversation. Written 2026-11-12 from the working state on
Kathleen's Mac (`~/PycharmProjects/threshing-atlas`, latest commit `4837332`).
---
## 1. What this is
**Dragonkind** is a browser game set in the world of *Fourth Wing*. Its centrepiece, **the threshing**, is a short
choose-your-path run: a cadet walks into a valley, makes a series of choices, the game rolls dice at certain points,
and the run ends with the cadet either **bonded to a dragon** (Red, Orange, Brown, Green, Blue or Black) or
**incinerated**. There's a cooldown of about four hours between attempts, Blue and Black are rare, and players want
to know which choices give the best odds of the dragon they want.
The **Threshing Atlas** is a hobby, non-commercial, open-data project by **Kathleen Schiano (GitHub: ekcSchiano)**
that:
1. **collects** every logged run it can find (a community Google Form and spreadsheet, Reddit, a bot, direct reports),
2. **codes** them into one clean table, one run per row (`data/public/runs_clean.csv`),
3. **analyses** them (factor tables, models, route rankings) for a public page,
4. **plans** routes: a Bayesian model of the game's dice, solved as a decision tree, that recommends the best
choice at every step for each target colour, and
5. **feeds a bot**: Ken's DragonKind bot plays the game, uses the Atlas's route model to choose, and sends its runs
back, so the model keeps learning.
Kathleen is a PhD researcher (informatics); she prefers **Python**, **declarative specs (YAML, data dictionaries,
Croissant metadata)**, and JavaScript only where it must run in a browser or in Ken's Node bot.
## 2. People, places and accounts
| What | Where | Notes |
|---|---|---|
| The Atlas repo (canonical copy) | `~/PycharmProjects/threshing-atlas` on Kathleen's Mac | Python venv at `.venv` (Python 3.9); PyCharm. Has `scipy`; **Node is not installed** (so `graph.json` can't be rebuilt there; `brew install node` fixes it). |
| GitHub repo | `github.com/ekcSchiano/threshing-atlas` (public) | **Account suspended** (flagged by GitHub's abuse detection, probably bursts of automated API activity from an AI assistant). Reinstatement request open with GitHub Support; they asked how she plans to use GitHub (answered: pet projects). GitHub Pages site paused. The Mac copy's `origin` still points here. |
| Gitea | `git.kenschiano.net` (Ken's server) | The Atlas is prepared to move there (under Kathleen's own account, visibility "limited"), but **Ken's Gitea has a problem; skipped for now**. |
| Ken | Gitea `kschiano`; GitHub issues author | Collaborator. Runs the **DragonKind bot** (private repo, now on his Gitea at `kschiano/DragonKind`). Kathleen has a local clone at `~/Desktop/DragonKind`: **read-only for us, never modify it** without asking. |
| The page | Claude artifact "Threshing Route Atlas": https://claude.ai/artifact/Amr4D5Av7sBHkWvjJuXM8A | Last republished 2026-11-04 (older data). Kathleen will view new builds locally / as an artifact while GitHub Pages is paused. |
| Community sources | u/ClumsyBadger's "Threshing Routes" Google Form (https://forms.gle/DRpj9tG8gb5E4Hcu7) and its responses spreadsheet; the "Unofficial Dragon Register"; the community route PDF; r/fourthwing Dragonkind megathreads (Part 3 `1wvwfp9`, Part 4 `1wz5cnj`) | Linked from the megathread post. u/Old_Regular3018 computes the PDF's percentages from the same spreadsheet; u/Smart_Trifle_2099 posted "precise Blue pathways" and Black theories. |
| Backups | `threshing-atlas.bundle` sent in chat (git bundle of all branches) | `git clone threshing-atlas.bundle threshing-atlas` |
## 3. The game, as the Atlas models it
The game is written down declaratively in **`core/spec/game.yaml`** (the single source of truth for the route
model, the advisor and the bot). In order:
1. **Company**: enter alone, with 1 or with 2 squadmates. **Leave** your squadmates or stay together.
2. **First direction**: East, West or Center (the forest).
3. **First dragon** (roll): Red, Brown, Green or Orange. **React**: hold still, respect/face it, run, hide, weapon,
meet its gaze, protect squadmate (which reactions exist depends on the dragon). **Survive the first dragon** (roll).
4. **The scream**: investigate it or keep walking.
- **Investigate → the clearing** (your squadmate attacked by two bully cadets): help, or walk away.
Help → **the fight**: pause to assess (then the dagger: engage the smaller cadet or charge the bigger one
anyway), charge the smaller cadet ("even the numbers"), or charge the bigger one ("put yourself in the middle").
**Survive the fight** (roll). Then **the bullies' fate**: kill them yourself, squadmate's revenge, or leave them
to the dragons. Then a **fork**: Forest, West or East.
- **Keep walking → the wounded cadet**: tourniquet, leave them to die, or take their weapons.
5. **Survive the hour** (roll). **After an hour**: climb the tallest tree, or go to the valley centre.
6. **Tree**: the **shadow** may appear (roll; **gated**, see below) → the shadow's colour (Black or Blue) → bonding
encounter. If no shadow: **climb down quickly** (the Red below the tree: jump on it, or let it pass → the two
Greens) or **slowly** (the two Greens).
7. **Valley**: **face the Red**, or pass it into the **meadow**, where a dragon waits (roll: Orange, Brown, or a Blue).
8. **Bonding encounters** (`encounters` in game.yaml): valley Red, tree Red, the two Greens (an Orange or Brown can
swoop in and rescue/bond you), meadow Orange/Brown/Blue, the Blue at the redwood (shadow), the Black (shadow).
A rider can attempt the bond or **die on purpose** ("seek Malek") rather than bond the wrong dragon.
Key modelling facts now in game.yaml:
- **The shadow is gated**: it can only appear if you **investigated the scream and helped your squadmate** (the route
PDF's "Black Dragon Gates"; data agree: 78 shadows in 4,199 gated tree runs vs 2 in 646 others, both likely
mis-entered). A closed gate fixes the roll at "no" and those runs aren't counted for it.
- **Possible bonds per encounter**: each encounter gives only its own colour (the two Greens also Orange/Brown).
Anything else in the data is treated as a data-entry error (a form row once claimed a Green at the shadow's Blue,
which broke the Green recommendation).
## 4. The four prongs + core (repo layout)
```
core/ spec/form.yaml (how each form answer is coded), spec/game.yaml (the game)
atlas/ (Python): coding.py (form → runs), model.py (counts, back-off, Params), solver.py (decision
tree, posterior draws, policy export), bias.py (reporting bias), runs.py (read runs_clean.csv), spec.py
solver.js (the small JS advisor), graph.js (route graph helpers + the bot crosswalk, generated block)
collection/ pipeline.yaml (every source, declaratively), run.py (`python -m collection ...`),
etl/ (extract, transform/*, validate, load, runs.py coders, metadata.py (Croissant), codegen.py,
report_form.py, handoff.py (zips, local refresh), forge.py (Gitea/GitHub API)),
specs/bot.yaml (bot labels + crosswalk), specs/report_form.yaml, manual/reddit_results.yaml
analysis/ stats/measures.yaml (what the page measures), site_stats.py, stats_core.py;
network/build-graph.js (graph.json); reports/POLICY.md (written by policy_report.py)
planner/ policy.yaml (which runs the model learns from, low-bias sample, reporting-bias settings),
build_policy.py, policy_report.py
site/ atlas/ (index.html, app.js, ui.js, explorer.js (valley map), valley.js, dragons.js, register.js),
build.js (→ dist/), qa/ (crawl.js, mapcheck.js: Playwright checks)
data/ public/ (everything published: runs_clean.csv, form_responses.json, register.json, reports.json,
stats.json, policy.json, graph.json, links.json), dictionary.yaml, croissant.json, manifest.json,
bot/ (scenes.json, trajectories-*.jsonl: anonymised bot runs), derived/pdf_fingerprint.json,
raw/ (git-ignored: current + previous raw file per source; never published)
tests/ core/ (coding rules, game, solver, stats, bias + JS advisor/graph tests), collection/ (pipeline),
fixtures/, parity/
docs/ BOT_INTEGRATION.md, BOT_DATA_PROTOCOL.md, PRIVACY.md, REPO_SETTINGS.md, ROADMAP.md, COLOURS.md
forge.yaml where the repo is hosted (gitea, git.kenschiano.net, repo: YOUR-GITEA-USERNAME/threshing-atlas placeholder)
.gitea/workflows/ CI + daily update for Gitea .github/workflows/ CI, daily update, Pages for GitHub (paused)
```
### 4a. Data collection: ETL (`collection/`)
`collection/pipeline.yaml` declares every source: how to **extract** it, which **transform**, its **privacy** rules,
where it **loads**, and which **coder** turns it into runs.
- **extract** only fetches into `data/raw/<source>/current.<ext>` (the replaced one becomes `previous.<ext>`;
nothing older is kept). `data/manifest.json` records the current raw checksum and change date.
- **transform** is pure (no network, no clock) → the public source file.
- **validate** checks runs against `data/dictionary.yaml` (types, every allowed value, unique ids). A new answer the
rules don't know **stops the load** and is reported (add it to `core/spec/form.yaml`).
- **load** is the only stage that writes; byte-stable.
- **build** codes every public source file into `data/public/runs_clean.csv` and writes generated files: the
"Report a run" issue form, the crosswalk block in `core/graph.js`, `data/public/links.json`, `data/croissant.json`.
| `source` in runs_clean | Pipeline source | Runs now | Notes |
|---|---|---|---|
| reddit spreadsheet | `reddit_spreadsheet` (the Threshing Routes form + sheet) | 8,132 | coded by `core/spec/form.yaml`; `entry` column keeps the sheet's own label ("Form" = form submission; others = bulk-pasted logs) |
| bot | `bot` (Ken's bot, imported from a folder or zip) | 421 | per-account folders; account names salted-hashed (salt in `data/raw/bot/account-salt.txt` on the Mac, never committed); `bot_mode` column |
| reddit thread | `reddit_thread` | 12 | dragonkind.com result pages read by hand (`collection/manual/reddit_results.yaml`); Reddit API extractor ready but needs `REDDIT_CLIENT_ID/SECRET` |
| reported | `reported` ("Report a run" issue form) | 0 | GitHub issues; switched to Gitea via forge.yaml (currently 404s: GitHub suspended, Gitea not set up) |
| reddit pdf | `reddit_pdf` | 0 | the route PDF is a flowchart, not runs: only its **fingerprint** is kept (never redistributed); changes are reported line by line |
| (none) | `register` (Unofficial Dragon Register) | 0 | bonded dragons without routes; names and photos dropped |
Every column is described in `data/dictionary.yaml`; `data/croissant.json` is Croissant 1.0 metadata built from it.
### 4b. Data analysis (`analysis/`)
`analysis/stats/site_stats.py` reads runs_clean (sources in `measures.yaml`: **spreadsheet only** for now) and writes
`data/public/stats.json`: every number the page shows, for six fixed filter presets (all, form only, bulk only, not
chasing Blue/Black, chasing, unflagged). Factor tables (Fisher/Mantel–Haenszel, BH q-values), ridge-logistic models,
route rankings at thresholds 5/10/20/30, per-stage route map counts. The page computes nothing itself.
`analysis/network/build-graph.js` writes `graph.json` (route graph per source + the bot's scene graph).
### 4c. Route planner (`planner/` + `core/atlas/`)
- **Model**: each roll (first dragon, survive sighting/fight/hour, shadow, shadow colour, meadow dragon) is a
categorical with a **hierarchical Dirichlet back-off** over its context (earlier choices); the shrinkage strength
(alpha) is fitted by empirical Bayes. Bond outcomes per encounter likewise. Malek/deliberate burns are not counted
as failed bonds.
- **Learns from** (`planner/policy.yaml`): reddit spreadsheet + reported + **bot** runs.
- **Reporting-bias correction** (`core/atlas/bias.py`): form submitters over-report rare sightings. For each rare roll
and each group, rho = odds(rare | group) / odds(rare | complete logs), where complete logs = **bot + bulk logs**.
Rare outcomes from biased groups count 1/rho. Current estimates (meadow Blue): **form, chasing Blue/Black rho 3.85
[2.98–5.14]; form, other 3.17 [2.33–4.41]**. For the shadow, complete logs have **0 shadows in 579 gated tree runs**,
so the bias can't be estimated and the shadow is learned from complete logs only. A roll seen only one way is pooled
fully (alpha max). Caveats: assumes the bias is the same on every route; intervals don't include rho's uncertainty.
- **Solver** (`core/atlas/solver.py`): walks game.yaml as a decision tree; two goals per colour: "this attempt"
(maximise P(colour)) and "eventually" (Dinkelbach ratio: P(X) / (P(X)+P(other bond)), i.e. dying on purpose
otherwise). 200 posterior draws give intervals and **stillBest** (share of draws where the recommended choice is best).
Two samples: **all** and **lowBias** (bot + bulk + riders not chasing rare dragons).
- **Output**: `data/public/policy.json` (game, count tables, alphas, reportingBias, support, trees per colour).
- **JS advisor** (`core/solver.js`): reads policy.json, re-solves, `advisor(sample, colour, objective, opts)`,
`recommendOption()` maps on-screen text to options (game.yaml `bot_text`). **Thompson sampling**:
`{ sampling: 'thompson', seed }` follows one posterior draw per attempt and returns a **propensity**.
Current odds per attempt (sample "all", latest build `538bc1e3d694`):
| Colour | Per attempt (90% range) | Low-bias sample | stillBest of first choice |
|---|---|---|---|
| Red | 93.1% (86.9–97.4) | 94.1% | 0.30 |
| Green | 25.2% (21.7–28.8) | 24.2% | 0.42 |
| Orange | 13.5% (11.3–15.7) | 16.7% | 0.55 |
| Brown | 9.3% (7.7–11.2) | 10.7% | 0.52 |
| Blue | 2.5% (2.1–3.0) | 1.9% | 0.45 |
| Black | 0.05% (0.00–0.25) | 0.04% | 0.31 |
(Before the bot data and bias correction, the model said Blue 7.3% and Black 2.1%: inflated by reporting bias.)
### 4d. Data visualisation (`site/`)
A single static page (tabs: Valley map, Odds, Dragons, Deep dive, Data & Methods, **Report a run**). The **valley
map** (`explorer.js`) uses progressive disclosure: key moments only, a point's options appear when selected, picking
a dragon shows its best path and choices; later choices keep the path you picked. The page shows precomputed
`stats.json` and runs the JS advisor on `policy.json`. Links come from `data/public/links.json` (filled in by
`site/build.js`). Build: `node site/build.js` → `dist/`. QA: `site/qa/crawl.js` (needs a local server on :8765),
`site/qa/mapcheck.js`. Published so far as the Claude artifact above.
## 5. The bot loop (Ken)
- **Atlas → bot**: `python3 -m collection export-bot-kit` → `exports/atlas-for-bot-<date>-<policy id>.zip`
(policy.json, solver.js, graph.js, README with checksums). Ken unzips into the bot's `vendor/threshing-atlas/`.
Latest: `atlas-for-bot-2026-11-12-538bc1e3d694.zip`.
- **Bot → atlas**: Ken zips the bot's `data/` and `logs/` folders; save in `inbox/` and run
`python3 -m collection refresh --bot inbox/<zip>`. The importer reads `data/knowledge.json` and every
`data/accounts/<acct>/runs.jsonl` + `logs/accounts/<acct>/encounters.jsonl` (top-level files mirror the first
account and are skipped). Bot **schema-2** run records carry steps, what was seen (shadow, dragons), propensity,
decisionMode, policyId. No game prose or account names are published (`check_public` refuses them).
- **How the bot should choose** (docs/BOT_INTEGRATION.md): goal accounts follow the best route
(`advisor(policy.samples.all, target, 'eventually')`); **research accounts use Thompson sampling** with a new seed
per attempt and log `propensity` with `decisionMode: "atlas_thompson"`.
- Ken's data so far: 13 accounts, 415 attempts (to 2026-11-10); research accounts burn on purpose when no shadow at
the tree / no Blue in the meadow (`TREE_NO_SHADOW_AUTO_BURN`, `MEADOW_NO_BLUE_AUTO_BURN`).
## 6. Findings so far
- **Reporting bias is large.** Meadow Blue: complete logs ~10% (bot 16/126, bulk 30/328) vs form ~33%.
- **Black is very rare.** 0 shadows in 579 gated tree runs from complete logs; form data show ~2% (inflated). Model:
~0.05% per attempt. Fits Smart_Trifle_2099's guess of 1/500–1/1000 tree runs for a Black sighting.
- **Route doesn't seem to move the rare rolls.** Shadow rate doesn't differ across routes (chi² 44 on 40 df); the
"precise Blue pathways" (Smart_Trifle_2099 and the megathread post's ~47%/~63% routes) did no better than other
meadow routes (23–30% vs 30% in the spreadsheet). Reaching the meadow seems to be the "unlock".
- **The gate is real**: the shadow needs investigate + help.
- **Tree Red is the hardest bond**: 1.7% (38/2,207), matching the post's "2%".
- **First attempts** see the meadow Blue less often (16% vs 31%), surviving adjustment in the site's model.
- Weekly swings in rates (and "the game was patched" claims) are confounded by who reports when.
## 7. How to run things (on the Mac, PyCharm terminal, venv active)
```
python3 -m collection refresh # the daily update locally (~3 min): sources → runs → graph* → model → stats → build
python3 -m collection refresh --bot inbox/x.zip # same, importing a bot zip
python3 -m collection update --source NAME # one source; --file NAME=PATH to use a local file
python3 -m collection build [--check] # rebuild runs_clean + generated files (CI uses --check)
python3 -m collection export-bot-kit # zip for Ken
python3 planner/build_policy.py # route model (~30–75 s); python3 planner/policy_report.py
python3 analysis/stats/site_stats.py # page statistics (needs scipy)
node analysis/network/build-graph.js # graph.json (*needs Node)
node site/build.js # the page → dist/
npm test # = build --check + Python unit tests + JS tests
```
Reports land in `exports/last-report.md`. If a refresh stops with "values not in the dictionary", add the new form
answer to `core/spec/form.yaml` (or the value to `data/dictionary.yaml`) and run `python3 -m collection build`.
## 8. Conventions and constraints (keep these)
- **Python first; declarative specs** (YAML for the form, game, pipeline, measures, planner, bot crosswalk, report
form; dictionary + Croissant). JS only for the browser page and Ken's Node bot (`solver.js`, `graph.js`).
- **Generated files are generated**: don't hand-edit `runs_clean.csv`, `croissant.json`, `links.json`, the
crosswalk block in `core/graph.js`, `.github/ISSUE_TEMPLATE/report-a-run.yml`. Edit the spec, then build.
- **Privacy**: no game prose, no account names/ids, no emails (redacted), no rider names (register), no Reddit or
GitHub usernames; the route PDF is never redistributed (fingerprint only). Never commit `data/raw/`, `.env`,
`.browser-profile/`, salts or tokens; tokens only in repository secrets. Don't scrape Discord with a personal token;
Reddit only via the official API.
- **Don't write to Ken's bot repo** (`~/Desktop/DragonKind`) without asking.
- **Commits** as `ekcSchiano` / Kathleen's email, ending with `Co-Authored-By: Claude …` and `Claude-Session: …`
lines. On GitHub, main was protected (PR + required `test` check, auto-merge). **Go easy on automated API
activity** (that's the likely cause of the GitHub suspension).
- Kathleen likes: progressive disclosure on the map, honest uncertainty, explaining what changed and why.
## 9. Status and open threads
- **Uncommitted / pending**: nothing important; Mac repo is clean at `4837332` (plus `.idea/`, `exports/`, `inbox/`
ignored). The artifact page is older than the data; rebuild with `node site/build.js` (needs Node) and republish.
- **GitHub**: suspended; reinstatement in progress. When back: `git push` to a branch + PR (main is protected);
GitHub Pages resumes from `.github/workflows/pages.yml`; set `forge.yaml` `kind: github` (or keep Gitea + mirror).
- **Gitea**: ready but on hold (Ken's server has a problem). Steps in `docs/REPO_SETTINGS.md`; set your username in
`forge.yaml`; the `.gitea/workflows/` are untested (runner label assumed `ubuntu-latest`).
- **"Report a run"** button points at a Gitea URL that doesn't exist yet; the Google Form is the working intake.
- **Not done yet / ideas**:
- Include bot and reported runs in the page's statistics (currently spreadsheet only; bot choices follow a strategy).
- Propagate the bias estimate's uncertainty (rho) into the route model's intervals; consider a per-source
reporting-bias model inside the posterior draws.
- Inverse-propensity weighting of bot runs using logged propensities.
- Port `build-graph.js` to Python; Reddit extractor live once API secrets exist; "Community claims, checked"
section (claims YAML recomputed against data); a "random run?" question on the report form.
- Reviews still pending from the original plan: analysis, planner (experiments.json, encounter answers), site.
- **Environment gotchas** (for Claude sessions): the cloud workspace and the Mac's Linux helper can't reach Google,
Gitea or PyPI; Kathleen's own Terminal can. The helper lacks `scipy`. Git in the helper needs delete permission
for its lock files.
+19
View File
@@ -0,0 +1,19 @@
# I ran the numbers on 2,573 logged threshing runs. Here's what holds up (and what doesn't)
*Per the megathread rules, anything that names a specific route is behind spoiler tags.*
Data: the community Threshing Routes form/spreadsheet (thanks u/ClumsyBadger, u/Old_Regular3018, u/Smart_Trifle_2099 and everyone who logged runs). 1946 form submissions, 83 Historical import, 348 Data Import, 196 Manual Upload; form dates 2026-10-04 to 2026-10-19. Every rate below has a 95% confidence interval.
**TL;DR**
* **The meadow Blue shows up a lot less than the spreadsheet suggests.** Runs logged by Blue-chasers show it 50.1% of the time, but bulk logs (people who recorded *every* run) show 11.0% (21/191). The game can't know what you're chasing, so that gap is reporting bias. Expect something closer to the bulk-log number.
* **No recorded route choice changed the Blue's odds** once you account for that bias (direction, first dragon, how you handled the cadet, company). 0 of 25 full routes beat the rest after correcting for multiple testing. The "precise pathways" might still matter through choices the form doesn't record (like how you react to the first dragon), but the form can't confirm them.
* **Getting the Blue to show up is only half of it.** Only 23.1% (92/398) of Blue attempts bonded, which matches the PDF's step-by-step numbers (~25%). Dying with the "right" answer is normal.
* **The tree shadow (→ Black) is rarer than the spreadsheet suggests.** All rows: 2.2% (24/1089), but bulk logs show 0/364 (upper 95% bound 1.0%). Plan on roughly 1 in 100 climbs at best. Once you get the Black, it bonds 86.7% (13/15) of the time.
* **Leads worth testing (not proven):** >!Fork in the road = Forest: shadow in 3.7% (19/514) vs the rest; Attempt = First attempt: shadow in 7.0% (8/114) vs the rest!<. If you bulk-log your tree climbs *including the boring ones*, we can settle this.
**How to help:** log every run in the form, including the ones where nothing rare happened. Those dull runs are what make the rates trustworthy.
Interactive route map, full methods, and code to reproduce every number: [Threshing Route Atlas](LINK)
*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.*
+119
View File
@@ -0,0 +1,119 @@
# Repository settings
The Atlas is hosted on Gitea (`forge.yaml`: git.kenschiano.net). The GitHub repository and its GitHub Pages site are
paused while that account is suspended; their workflows stay in `.github/workflows/` for when it is back.
## Gitea: setting up the repository (once)
1. **Your account** on git.kenschiano.net (ask Ken), with 2FA on and your SSH key added (Settings → SSH / GPG Keys).
2. **Create the repository** `threshing-atlas` under your account, visibility **limited** (only people signed in to
the server), empty (no README or licence: they come from the push). Put your username in `forge.yaml` (`repo:`),
then `python -m collection build` and commit.
3. **Push** from your Mac copy:
```
cd ~/PycharmProjects/threshing-atlas
git remote rename origin github # keep the GitHub address for later
git remote add origin git@git.kenschiano.net:<you>/threshing-atlas.git
git push -u origin main
```
4. **Turn on Actions** (repository Settings → Units → Actions) and ask Ken which runner label the server has. The
workflows use `ubuntu-latest`; change `runs-on:` in `.gitea/workflows/*.yml` if it is different.
5. **Secrets** (Settings → Actions → Secrets):
| Secret | What it is | How to make it |
|---|---|---|
| `ATLAS_BOT_TOKEN` | lets the daily update push its branch, open the pull request and issues | your Settings → Applications → Generate token; permissions: repository read and write, issue read and write |
| `RAW_ARCHIVE_KEY` | encrypts the private raw store kept in the Actions cache between runs | any long random string (`openssl rand -base64 32`); keep a copy |
| `REDDIT_CLIENT_ID`, `REDDIT_CLIENT_SECRET` | optional: read the megathreads through the Reddit API | see "Data collection secrets" below |
6. **Protect main** (Settings → Branches → Add rule for `main`): require a pull request, enable status checks and
require the check from the CI workflow (it shows up as `CI / test` after its first run), and allow
"merge when checks succeed". Leave required approvals at 0 so the daily update can merge itself.
7. **The label** for reports: `python -m collection forge ensure-label --name "run report"` (with
`ATLAS_BOT_TOKEN` set), or create it under Issues → Labels.
The daily update then runs at 10:23 UTC; run it by hand from the Actions tab (workflow "Check sources for new data").
Locally, `python -m collection refresh` does the same.
## The page
The page is built by `node site/build.js` and viewed locally or published as a Claude artifact; Gitea has no Pages.
Its links (the repository, "Report a run") come from `forge.yaml` through `data/public/links.json`.
## GitHub (paused)
# Repository settings
Some settings live on GitHub, not in the code. Only the repository owner (ekcSchiano) can change them.
They go together: the ruleset makes CI a gate on `main`, auto-merge lets a pull request merge itself once
it passes, and the token lets the daily data update do that on its own.
## 1. Allow auto-merge (issue #4)
Settings → General → Pull Requests:
- tick **Allow auto-merge**
- tick **Automatically delete head branches**
## 2. Require CI to pass on `main` (issue #5)
Settings → Rules → Rulesets → New ruleset → New branch ruleset:
| Field | Value |
|---|---|
| Ruleset name | `main: CI must pass` |
| Enforcement status | Active |
| Bypass list | leave empty |
| Target branches | Add target → Include default branch |
| Restrict deletions | on |
| Block force pushes | on |
| Require a pull request before merging | on, required approvals **0** |
| Require status checks to pass | on → Add checks → `test` (GitHub Actions) |
`test` is the job in `.github/workflows/ci.yml`. It runs the JS and Python tests, the JS/Python parity
checks, checks that `data/public/graph.json` is up to date, and builds the site.
From then on every change, including ours, goes through a pull request. Nothing can be pushed straight to
`main`. To merge without waiting, open the PR and turn on auto-merge; it merges when `test` passes.
## 3. Access token for automation (issue #6)
The daily source check (`.github/workflows/update-sources.yml`) opens a pull request when the community data
change. If it uses the built-in `GITHUB_TOKEN`, GitHub does not start other workflows from what it does. CI
still runs on the PR, but after the merge the site would not redeploy. With a token it opens the PR, turns on
auto-merge, and the merge redeploys the site.
Create the token at github.com → Settings → Developer settings → Personal access tokens → Fine-grained tokens →
Generate new token:
| Field | Value |
|---|---|
| Token name | `threshing-atlas automation` |
| Resource owner | ekcSchiano |
| Expiration | 90 days, with a calendar reminder to renew |
| Repository access | Only select repositories → `ekcSchiano/threshing-atlas` |
| Repository permissions | **Contents: Read and write**, **Pull requests: Read and write** (Metadata: Read-only is added automatically) |
Then store it as a secret, never in a file, issue, chat or commit: repository Settings → Secrets and
variables → Actions → New repository secret, name **`ATLAS_BOT_TOKEN`**.
Without the secret the workflow still works. It falls back to `GITHUB_TOKEN` and the PR waits for a manual
merge.
If Ken's bot should also open pull requests here (for example to send new bot runs), create a **second** token
with the same settings and store it as a secret in the bot's own repository. Separate tokens can be revoked
separately, and a leak in one place does not expose the other.
## Data collection secrets (optional)
Both are repository secrets (Settings → Secrets and variables → Actions → New repository secret). Without them the
daily update still runs and says in its report what it skipped.
| Secret | What it is for | How to make it |
|---|---|---|
| `RAW_ARCHIVE_KEY` | Encrypts the private raw store (current and previous raw file of each source) kept in the Actions cache between runs. | Any long random string, e.g. the output of `openssl rand -base64 32`. Keep a copy somewhere safe: without it the archive cannot be read. |
| `REDDIT_CLIENT_ID`, `REDDIT_CLIENT_SECRET` | Reading the r/fourthwing megathreads through the official Reddit API. | reddit.com/prefs/apps → "create another app…" → type **script**, any name, redirect uri `http://localhost`. The id is under the app name; the secret is labelled "secret". |
The "Report a run" form adds the label `run report` to each report; the label must exist (Issues → Labels).
+56
View File
@@ -0,0 +1,56 @@
# Roadmap
The aim is to move from summary statistics to path finding: for each dragon colour, the decision
policy that maximises the chance of bonding it, with honest uncertainty.
1. **Repo and packaging** (done): monorepo, CI, GitHub Pages, JS/Python parity tests.
2. **Graph format** (`core/`, first version done): typed scene, chance and terminal nodes; history-context keys;
per-source counts (bot, form, PDF, Discord); fingerprints and short labels only, no game prose.
Importers in `collection/bot` for the bot's `knowledge.json`, `runs.jsonl` and `encounters.jsonl`
(done), the form (done, via the crosswalk in `graph.js`), and a PDF scene crosswalk (to do).
Daily source checks for the form, the register and the PDF (done).
3. **Context learning** (`analysis/`): tests of history dependence (G-tests, BH); variable-order
Markov / context tree with BIC; temporal-tiered DAG structure learning (BDeu/BIC); latent
"character" model vs specific triggers vs memoryless baseline, compared on held-out likelihood;
hierarchical Dirichlet back-off pooling.
4. **Solver** (first version done: `core/solver.js`, `analysis/reports/POLICY.md`; still to do: richer history models from step 3): backward induction on the augmented state (scene, history summary), i.e. an influence
diagram with perfect recall. Two objectives side by side per colour:
- P(target colour on this attempt);
- eventual success when deliberate deaths are free: maximise p_X / (p_X + p_other bond),
solved by Dinkelbach iteration.
Monte Carlo credible intervals, top-k routes, required steps and bottlenecks.
5. **Valley graph UI**: every option at every point, with P(survive) and P(bond) per colour, the
policy overlay for a chosen colour, and untested branches marked.
6. **Bot loop** (advisor and sync published, see `docs/BOT_INTEGRATION.md`; experiments.json to do): the atlas publishes `policy.json` and `experiments.json` (ranked by value of
information); the private DragonKind bot consumes them and returns anonymised runs.
## Python first, declarative rules (November 2026)
The repo is moving to Python, with the rules and the game written as declarative spec files. JavaScript stays
only where it has to run: the site's drawing and interaction, and a small route advisor the site and Ken's bot
share.
1. Coding rules: `core/spec/form.yaml` + `core/atlas/coding.py`, with rule tests. **Done.**
2. Route model in Python, built from `core/spec/game.yaml`. **Done** (the bot's text, `core/spec/crosswalk.yaml`, moves with the bot importer and the JS advisor in step 4).
3. **Done.** Fix the coding bugs found in the core review (letting the Red pass, "left your squadmates" before the
redesigned form, missing bot text), each with a rule test.
4. **Done.** The site shows precomputed statistics with fixed filter presets (`analysis/stats/site_stats.py`,
`measures.yaml`, `data/public/stats.json`); the upload button and the click-to-select route map are gone; a
small JS advisor (`core/solver.js`, about 250 lines) reads the game and the Python-built model from `policy.json`
and replaces the 900-line JS solver; `engine.js` is gone.
5. **Done.** `data/dictionary.yaml` describes every published file and every column of the coded runs (type, meaning,
allowed values); `collection/etl/metadata.py` writes `data/croissant.json` (Croissant 1.0) from it, with a
sha256 for every file. `tests/core/test_dictionary.py` fails when a column or value is undescribed or the metadata
is stale. It also caught `attempt` being written as `1.0`, `2.0`: now a whole number.
## Data collection review (November 2026)
Collection is an extract → transform → load pipeline declared in `collection/pipeline.yaml` (`python -m collection`).
`data/public/runs_clean.csv` holds every run from every source with a `source` column (reddit spreadsheet, reddit
thread, reported, bot, reddit pdf). The bot importer is Python (`collection/etl/transform/bot.py`, identical output to
the old `bot.js`), and its crosswalk is `collection/specs/bot.yaml`, written into `core/graph.js` for the bot.
Reddit goes through the official API; "Report a run" is a GitHub issue form generated from
`collection/specs/report_form.yaml`. Only the previous raw version is kept, encrypted, in the Actions cache.
Still to do: decide which non-spreadsheet sources join the statistics and the route model (`analysis/stats/measures.yaml`
`sources`); the bot follows a strategy, so its runs need weighting rather than pooling.
-252
View File
@@ -1,252 +0,0 @@
/* dragons.js — the dragon silhouettes of the valley map (traced from the pose reference sheet) and its cadets.
* Each pose is built from simple parts (tapered tubes, a scalloped wing membrane, a head with horns, spines,
* a spaded tail), so every dragon is drawn the same way but stands differently. Drawn facing right in a
* 200 x 160 box; flip with scale(-1, 1). Works in the browser (window.DragonArt) and in Node. */
(function (root, factory) {
if (typeof module === "object" && module.exports) module.exports = factory();
else root.DragonArt = factory();
})(typeof self !== "undefined" ? self : this, function () {
"use strict";
const f = (n) => Math.round(n * 10) / 10;
const lerp = (a, b, t) => a + (b - a) * t;
/** Points along a cubic Bezier given as [p0, c1, c2, p1] (each [x, y]). */
function bez(P, n = 28) {
const out = [];
for (let i = 0; i <= n; i++) {
const t = i / n, u = 1 - t;
out.push([
u * u * u * P[0][0] + 3 * u * u * t * P[1][0] + 3 * u * t * t * P[2][0] + t * t * t * P[3][0],
u * u * u * P[0][1] + 3 * u * u * t * P[1][1] + 3 * u * t * t * P[2][1] + t * t * t * P[3][1],
]);
}
return out;
}
/** A tube along a Bezier whose half-width goes from r0 to r1 (r can also be a function of t). */
function tube(P, r0, r1, n = 28) {
const pts = bez(P, n), L = [], R = [];
pts.forEach((p, i) => {
const a = pts[Math.max(0, i - 1)], b = pts[Math.min(pts.length - 1, i + 1)];
let dx = b[0] - a[0], dy = b[1] - a[1];
const len = Math.hypot(dx, dy) || 1;
dx /= len; dy /= len;
const t = i / n, r = typeof r0 === "function" ? r0(t) : lerp(r0, r1, t);
L.push([p[0] - dy * r, p[1] + dx * r]);
R.push([p[0] + dy * r, p[1] - dx * r]);
});
const ring = L.concat(R.reverse());
return "M" + ring.map((p) => `${f(p[0])} ${f(p[1])}`).join(" L") + " Z";
}
const poly = (pts) => "M" + pts.map((p) => `${f(p[0])} ${f(p[1])}`).join(" L") + " Z";
const ell = (cx, cy, rx, ry, rot = 0) => {
const pts = [];
for (let i = 0; i < 36; i++) {
const a = (i / 36) * Math.PI * 2, x = rx * Math.cos(a), y = ry * Math.sin(a), c = Math.cos(rot), s = Math.sin(rot);
pts.push([cx + x * c - y * s, cy + x * s + y * c]);
}
return poly(pts);
};
/**
* Wing membrane: a leading-edge bone shoulder -> wrist -> tip, finger tips along the trailing edge, and
* scalloped membrane between them, back to the root on the body.
*/
function wing({ shoulder, wrist, tip, fingers, root, bow = 0.28, bone = 4 }) {
const d = [tube([shoulder, [lerp(shoulder[0], wrist[0], 0.4), lerp(shoulder[1], wrist[1], 0.4) - 6], [lerp(shoulder[0], wrist[0], 0.8), lerp(shoulder[1], wrist[1], 0.8)], wrist], bone, bone * 0.8),
tube([wrist, [lerp(wrist[0], tip[0], 0.3), lerp(wrist[1], tip[1], 0.3)], [lerp(wrist[0], tip[0], 0.7), lerp(wrist[1], tip[1], 0.7)], tip], bone * 0.8, 0.8)];
const edge = [tip].concat(fingers, [root]);
let m = `M${f(shoulder[0])} ${f(shoulder[1])} L${f(wrist[0])} ${f(wrist[1])} L${f(tip[0])} ${f(tip[1])}`;
for (let i = 1; i < edge.length; i++) {
const a = edge[i - 1], b = edge[i];
// scallop: control point pulled toward the wrist
const mx = (a[0] + b[0]) / 2, my = (a[1] + b[1]) / 2;
const cx = lerp(mx, wrist[0], bow), cy = lerp(my, wrist[1], bow);
m += ` Q${f(cx)} ${f(cy)} ${f(b[0])} ${f(b[1])}`;
}
m += ` L${f(shoulder[0])} ${f(shoulder[1])} Z`;
d.push(m);
// finger bones from the wrist (thin, add texture at the edge)
fingers.forEach((p) => d.push(tube([wrist, [lerp(wrist[0], p[0], 0.33), lerp(wrist[1], p[1], 0.33)], [lerp(wrist[0], p[0], 0.66), lerp(wrist[1], p[1], 0.66)], p], 1.6, 0.6, 10)));
return d;
}
/** Head pointing along `ang` (radians, 0 = right) from the neck end, with horns and an open or closed jaw. */
function head({ at, ang = 0, size = 1, open = 0, horns = 2 }) {
const c = Math.cos(ang), s = Math.sin(ang);
const T = (x, y) => [at[0] + (x * c - y * s) * size, at[1] + (x * s + y * c) * size];
const d = [];
// skull and upper snout
d.push(poly([T(-8, 2), T(-6, -9), T(4, -12), T(14, -8), T(26, -5), T(31, -2), T(30, 1), T(18, 2 + open * 0.3), T(8, 6)]));
// jaw (drops when open)
d.push(poly([T(-6, 3), T(10, 4), T(28, 3 + open), T(26, 6 + open), T(12, 10 + open * 0.4), T(-4, 9)]));
// horns sweeping back
for (let i = 0; i < horns; i++) {
const y0 = -9 + i * 4, len = 18 - i * 6;
d.push(tube([T(2 - i * 3, y0), T(-6 - i * 2, y0 - 6), T(-14 - i * 3, y0 - 8 - i), T(-12 - len * 0.6 - i * 3, y0 - 14 + i * 3)], 2.6 * size - i * 0.4, 0.4, 10));
}
// brow spike and cheek frill
d.push(poly([T(-4, 4), T(-14, 8), T(-5, 8)]));
return { d, eye: T(8, -5), eyeR: 1.9 * size };
}
/** Small triangular spines along a list of points (pointing away from `side` normal). */
function spines(pts, size, side = -1, every = 2) {
const d = [];
for (let i = 1; i < pts.length - 1; i += every) {
const a = pts[i - 1], b = pts[i + 1], p = pts[i];
let dx = b[0] - a[0], dy = b[1] - a[1];
const len = Math.hypot(dx, dy) || 1;
dx /= len; dy /= len;
const nx = -dy * side, ny = dx * side, k = typeof size === "function" ? size(i / pts.length) : size;
d.push(poly([[p[0] - dx * k * 0.6, p[1] - dy * k * 0.6], [p[0] + nx * k * 1.5 - dx * k * 0.5, p[1] + ny * k * 1.5 - dy * k * 0.5], [p[0] + dx * k * 0.6, p[1] + dy * k * 0.6]]));
}
return d;
}
/** Tail as a tapering tube ending in a spade. */
function tail(P, r0) {
const d = [tube(P, (t) => Math.max(0.9, r0 * (1 - t) ** 1.1), null, 36)];
const pts = bez(P, 36), a = pts[pts.length - 3], b = pts[pts.length - 1];
let dx = b[0] - a[0], dy = b[1] - a[1];
const len = Math.hypot(dx, dy) || 1;
dx /= len; dy /= len;
const nx = -dy, ny = dx, k = Math.max(4, r0 * 0.9);
d.push(poly([[b[0] - dx * k * 0.6, b[1] - dy * k * 0.6], [b[0] + nx * k, b[1] + ny * k], [b[0] + dx * k * 1.6, b[1] + dy * k * 1.6], [b[0] - nx * k, b[1] - ny * k]]));
return { d, pts };
}
/** Leg: hip -> knee -> foot with three claws. */
function leg(hip, knee, foot, r, toe = 1) {
const d = [tube([hip, [lerp(hip[0], knee[0], 0.6), lerp(hip[1], knee[1], 0.6)], knee, [lerp(knee[0], foot[0], 0.5), lerp(knee[1], foot[1], 0.5)]], r, r * 0.6, 14),
tube([[lerp(knee[0], foot[0], 0.4), lerp(knee[1], foot[1], 0.4)], [lerp(knee[0], foot[0], 0.6), lerp(knee[1], foot[1], 0.6)], [lerp(knee[0], foot[0], 0.85), lerp(knee[1], foot[1], 0.85)], foot], r * 0.6, r * 0.45, 10)];
for (let i = -1; i <= 1; i++) d.push(poly([[foot[0] - 2, foot[1] - 2], [foot[0] + toe * (6 + i * 1.5), foot[1] + 1 + i * 2.2], [foot[0] + 1, foot[1] + 2.5]]));
return d;
}
/* ---------- poses ---------- */
/* Six silhouettes traced from the project's pose reference sheet (all facing right, in the 200 x 160 box;
* flying and diving poses centred, the others standing on the bottom edge), each with the sheet's interior lines
* (wing ribs, folds, the rock's edges) drawn over the colour, for depth; gaps the sheet leaves open (between the
* perched dragon's legs and the rock, under the sleeping one's wing) are holes. Names keep the old
* pose keys: coiled is the diving dragon, resting the sleeping one, sitting the one perched on a rock. */
const TRACED = {
"flying": {
"body": "M6.0 55.5 L6.0 56.9 L6.7 56.9 L7.4 55.5 L10.0 53.1 L14.0 51.5 L16.8 51.0 L22.3 51.3 L28.4 52.7 L31.2 54.1 L32.9 55.7 L34.0 59.5 L33.8 62.3 L31.0 68.0 L30.7 69.9 L31.4 69.9 L32.9 67.7 L36.2 65.4 L41.1 63.7 L48.2 63.7 L56.2 65.9 L60.9 68.7 L63.2 71.0 L64.7 74.1 L64.4 76.5 L63.5 78.8 L61.6 81.2 L61.6 81.9 L62.5 81.9 L65.6 79.5 L68.7 77.9 L73.6 76.5 L77.9 76.5 L80.9 77.4 L83.7 79.3 L84.0 80.7 L84.7 80.7 L87.0 79.1 L89.9 78.4 L94.3 78.4 L96.2 79.1 L95.8 80.2 L93.2 82.6 L89.2 83.3 L89.2 83.8 L89.9 84.2 L89.4 84.7 L84.5 85.4 L84.5 85.9 L84.9 85.9 L85.4 86.4 L80.9 87.3 L80.7 88.0 L81.9 88.2 L81.4 88.7 L78.1 89.0 L77.1 89.4 L76.9 90.4 L73.8 90.6 L73.8 91.8 L68.7 92.0 L68.7 92.7 L69.6 93.0 L69.4 93.4 L66.1 93.4 L65.8 94.1 L62.3 93.9 L62.1 95.1 L58.8 94.8 L58.5 96.0 L55.2 95.5 L54.8 96.5 L51.0 96.5 L50.8 97.4 L45.8 97.4 L45.3 97.7 L45.8 98.6 L40.4 99.8 L39.5 101.0 L35.0 102.6 L34.5 103.1 L35.0 104.0 L32.4 106.2 L30.0 110.6 L30.0 113.5 L31.2 117.5 L31.0 120.1 L31.9 120.1 L32.6 118.4 L33.8 112.5 L34.3 112.3 L34.7 112.7 L35.7 112.7 L35.2 110.6 L35.2 108.0 L35.7 107.1 L38.0 105.0 L41.6 103.1 L46.3 101.7 L52.6 100.5 L62.5 99.6 L70.1 98.4 L77.9 96.5 L84.5 94.4 L84.7 94.6 L82.8 96.3 L81.6 96.5 L80.7 98.4 L80.7 99.3 L81.6 100.5 L83.5 100.7 L86.1 99.3 L92.5 92.7 L93.6 92.3 L97.4 92.0 L100.9 90.1 L100.9 91.1 L96.2 94.1 L94.3 94.1 L91.0 98.4 L88.9 100.0 L88.0 100.0 L87.5 100.5 L87.5 102.9 L88.5 103.6 L90.6 103.6 L93.2 101.7 L96.5 97.4 L99.1 96.5 L102.8 96.3 L105.2 95.3 L108.2 92.5 L109.4 90.6 L109.9 89.0 L110.6 88.2 L113.7 87.3 L117.7 84.7 L122.4 85.4 L124.5 86.1 L126.9 87.5 L128.3 89.9 L127.1 93.4 L128.3 93.2 L130.6 91.1 L134.9 88.5 L139.6 86.6 L144.5 86.4 L147.6 87.3 L149.5 88.5 L152.3 91.5 L153.5 94.8 L153.5 97.4 L153.9 97.4 L156.5 92.7 L159.4 90.1 L162.0 88.7 L167.4 87.3 L173.5 87.5 L182.9 90.4 L186.9 92.5 L189.1 94.1 L191.6 97.2 L192.6 99.3 L192.6 101.9 L193.1 101.9 L193.8 100.7 L193.8 97.2 L190.9 90.6 L188.6 86.8 L183.2 80.2 L181.0 78.1 L169.7 72.5 L163.8 70.3 L158.4 68.9 L158.0 68.2 L159.1 67.0 L161.0 66.3 L160.8 65.6 L158.2 65.9 L156.3 66.8 L153.7 69.2 L150.4 71.3 L141.7 74.8 L136.5 75.3 L132.0 76.5 L122.6 76.2 L122.4 75.8 L124.7 73.4 L126.9 72.0 L129.2 71.0 L130.6 71.0 L130.9 71.8 L131.8 72.0 L135.1 71.5 L135.8 72.2 L136.5 72.2 L137.0 71.0 L138.2 71.0 L139.3 71.5 L139.6 72.2 L140.8 72.2 L141.9 71.3 L142.2 69.4 L141.2 68.0 L139.1 67.5 L137.5 65.9 L136.3 65.4 L134.6 64.0 L127.3 61.2 L124.7 59.5 L123.8 59.5 L123.8 60.0 L127.1 64.2 L126.9 64.7 L124.7 64.2 L124.7 65.4 L121.0 65.2 L118.8 65.6 L118.8 66.1 L121.2 66.1 L121.4 66.6 L121.0 67.0 L118.1 67.0 L115.8 67.7 L115.8 68.2 L117.4 68.2 L117.7 68.7 L117.2 69.2 L113.2 69.4 L113.0 70.3 L111.3 70.6 L111.1 71.0 L106.4 69.2 L98.4 64.9 L95.8 64.0 L93.9 62.3 L92.5 59.5 L91.3 55.5 L90.8 49.8 L89.4 47.5 L88.0 46.1 L85.9 44.9 L85.2 44.9 L85.2 45.6 L87.3 47.7 L88.0 49.4 L87.7 50.6 L74.6 45.8 L63.2 42.8 L58.1 40.9 L55.9 39.7 L53.1 39.7 L52.9 40.2 L43.9 40.9 L32.2 42.8 L18.3 46.8 L9.3 51.3 L7.2 53.4 Z",
"lines": "M37.8 102.4 L36.9 102.4 L35.9 102.9 L35.4 104.5 L35.9 104.5 L37.6 103.3 Z M40.2 101.2 L42.5 100.7 L42.5 100.3 L40.9 100.3 L40.2 100.7 Z M46.3 99.3 L48.9 98.8 L48.9 98.1 L46.5 97.9 Z M193.1 97.7 L193.1 100.3 L193.5 100.3 L193.5 97.7 Z M81.6 97.7 L81.6 98.8 L82.3 98.8 L83.0 98.4 L83.0 97.9 Z M51.5 97.4 L51.5 97.9 L53.4 97.9 L53.4 97.2 L52.9 97.0 L51.9 97.0 Z M55.5 97.2 L57.1 97.0 L57.1 96.3 L55.7 96.0 Z M59.2 96.5 L60.9 96.3 L60.9 95.5 L59.5 95.3 Z M62.8 94.4 L62.8 95.8 L64.7 95.3 L64.7 94.8 Z M88.0 92.5 L84.7 93.4 L84.7 93.9 L85.6 94.1 L85.2 94.4 L85.2 95.1 L86.6 94.6 L88.0 93.2 Z M70.1 92.5 L70.1 93.7 L71.0 93.7 L71.7 93.2 L71.7 92.7 L71.3 92.5 Z M74.6 91.1 L74.6 92.3 L76.2 91.8 L76.2 91.1 Z M80.0 89.4 L77.9 89.7 L77.6 90.8 L80.0 90.1 Z M102.6 88.7 L101.6 88.7 L100.9 89.2 L100.9 89.7 L101.6 89.9 L101.6 90.8 L102.1 90.8 Z M82.3 89.0 L83.7 88.5 L84.0 87.8 L82.6 87.5 Z M85.9 85.7 L85.9 87.1 L87.5 86.4 L87.5 85.7 Z M90.3 83.8 L90.3 84.9 L91.8 84.5 L91.8 83.8 Z M110.8 71.5 L110.8 72.0 L111.5 72.2 L113.2 72.0 L113.0 71.0 L111.8 71.0 L111.5 71.5 Z M130.9 70.1 L131.3 71.3 L132.7 71.0 L132.7 70.6 Z M113.7 71.0 L115.1 71.3 L116.3 70.6 L116.3 69.9 L114.6 69.6 L114.6 70.1 L115.1 70.3 L113.7 70.6 Z M118.1 67.7 L118.1 69.2 L118.8 69.2 L119.6 68.7 L119.3 68.0 Z M121.9 65.6 L121.9 67.0 L123.8 66.8 L123.8 66.1 Z M125.9 61.4 L125.9 61.9 L127.8 63.7 L127.1 65.6 L125.7 64.9 L125.4 66.1 L127.1 66.1 L127.3 65.6 L129.4 65.9 L129.7 64.9 L130.4 65.4 L132.7 65.6 L132.5 64.5 L131.3 63.5 L127.3 61.6 Z M128.7 63.5 L129.2 63.3 L131.1 64.5 L130.6 64.7 Z M53.6 39.7 L53.6 40.7 L55.5 40.4 L55.2 39.7 Z"
},
"prowling": {
"body": "M193.7 72.8 L191.0 69.2 L189.0 69.8 L187.0 68.8 L185.3 66.8 L182.0 64.5 L180.0 64.5 L174.7 61.5 L170.7 57.5 L170.0 57.8 L170.0 58.8 L173.0 63.2 L172.7 64.2 L168.0 62.2 L164.7 59.8 L163.1 57.5 L162.1 57.5 L162.1 59.5 L163.4 61.8 L167.7 66.2 L166.7 66.8 L159.7 66.8 L159.7 67.8 L162.1 68.2 L162.4 68.8 L157.1 70.1 L155.4 71.1 L155.4 72.1 L158.7 71.8 L159.1 72.5 L155.1 74.8 L152.7 77.1 L153.1 78.1 L156.1 76.8 L156.4 77.1 L153.4 81.5 L152.7 84.8 L153.7 84.8 L155.7 82.5 L156.4 82.8 L155.4 85.1 L155.1 89.4 L156.1 89.8 L157.4 87.5 L158.1 87.8 L157.7 91.8 L157.1 92.1 L151.1 89.4 L150.1 89.4 L150.1 90.1 L149.4 90.4 L145.1 88.8 L144.1 89.1 L144.1 89.8 L144.8 90.1 L144.4 90.8 L136.1 86.5 L131.8 81.8 L130.1 78.1 L130.1 75.5 L132.4 71.1 L135.1 68.5 L137.8 69.2 L139.8 70.8 L139.8 71.5 L140.8 71.5 L140.8 69.2 L138.1 66.5 L124.8 61.2 L117.1 59.5 L113.1 59.5 L113.5 60.5 L116.8 61.2 L117.5 61.8 L95.5 62.2 L82.9 64.2 L74.2 66.8 L62.6 71.5 L53.2 76.1 L42.6 82.8 L29.3 93.1 L22.3 100.1 L19.0 104.4 L18.0 108.4 L19.0 108.4 L20.6 106.1 L24.6 102.4 L31.3 98.1 L39.6 94.4 L49.6 91.8 L53.2 91.8 L54.2 93.1 L54.2 94.4 L52.6 98.8 L47.6 105.8 L46.3 109.1 L47.3 109.1 L52.6 104.4 L58.2 101.1 L64.9 98.4 L70.2 97.4 L77.9 97.8 L83.9 100.1 L87.5 103.8 L89.5 108.7 L89.2 114.7 L90.2 114.7 L91.8 111.4 L95.2 108.1 L98.2 106.1 L101.5 104.8 L108.2 104.1 L113.1 105.4 L113.8 106.8 L109.5 108.4 L109.2 109.7 L107.5 109.7 L105.2 110.7 L105.2 111.4 L107.2 111.4 L107.2 112.4 L100.2 114.1 L99.8 115.1 L101.8 115.7 L101.2 116.4 L94.8 117.7 L94.5 118.7 L96.5 118.7 L96.5 119.7 L89.2 120.4 L89.5 121.4 L91.2 122.1 L90.5 122.7 L83.9 121.7 L83.5 122.7 L85.2 124.1 L84.9 124.4 L83.2 124.4 L78.2 122.7 L78.2 123.7 L79.2 124.7 L78.5 125.4 L74.5 123.1 L73.5 123.1 L74.2 125.1 L72.9 125.4 L69.2 122.7 L67.9 122.7 L68.9 124.7 L68.2 125.4 L63.9 122.4 L62.9 122.4 L62.9 124.7 L57.9 121.4 L57.2 121.4 L57.2 122.4 L57.9 123.1 L56.6 123.4 L51.6 120.1 L50.3 120.1 L50.6 121.7 L49.9 122.1 L43.6 119.4 L41.9 119.4 L41.9 121.1 L36.9 119.7 L33.3 119.7 L34.0 121.1 L33.6 121.4 L28.0 121.1 L27.6 122.4 L22.0 122.7 L22.0 124.1 L21.3 124.7 L19.0 124.7 L14.7 126.4 L14.7 127.4 L15.3 127.7 L15.0 128.4 L11.0 130.0 L6.0 134.4 L6.0 135.7 L8.3 134.4 L8.7 134.7 L7.0 137.7 L6.7 142.7 L7.7 143.0 L9.0 147.3 L12.0 151.0 L13.7 151.3 L13.0 149.7 L14.0 149.3 L19.3 153.7 L21.3 153.7 L21.6 152.7 L24.0 153.7 L27.0 153.7 L27.6 151.7 L29.6 151.3 L35.9 148.3 L38.9 146.0 L38.9 145.0 L36.9 145.3 L32.0 147.7 L27.6 148.7 L24.3 148.7 L24.0 148.0 L25.0 146.3 L21.6 147.0 L17.6 146.7 L15.6 145.7 L14.0 144.0 L13.0 142.0 L13.0 139.0 L14.7 136.0 L19.3 132.0 L25.6 129.0 L34.9 127.0 L43.3 127.0 L52.3 128.7 L67.6 132.7 L81.5 133.4 L89.2 132.4 L94.2 131.0 L105.2 127.0 L116.5 122.1 L116.5 124.1 L114.1 124.4 L109.8 128.0 L105.8 129.4 L102.2 140.0 L101.2 141.4 L100.2 141.4 L98.5 142.7 L97.8 144.0 L98.2 145.7 L99.8 144.7 L102.2 144.7 L103.5 145.7 L107.2 145.7 L109.2 145.0 L112.1 145.7 L112.5 144.7 L113.5 144.7 L114.8 146.3 L115.8 146.3 L116.1 144.0 L115.1 142.0 L113.5 140.4 L109.2 140.0 L108.5 139.4 L109.5 136.4 L111.5 134.0 L123.1 131.4 L125.1 130.4 L128.8 126.7 L129.1 127.0 L128.1 128.7 L123.5 132.7 L123.8 135.4 L129.8 141.7 L128.1 143.4 L127.8 145.3 L129.8 145.0 L134.4 146.0 L139.1 145.7 L139.8 146.3 L141.8 145.7 L142.4 147.3 L143.4 147.3 L143.8 144.0 L140.8 141.0 L137.4 141.0 L135.4 140.0 L132.1 136.0 L131.8 134.4 L138.1 130.7 L140.1 128.7 L143.4 122.1 L147.7 122.1 L148.1 122.7 L147.4 124.1 L148.4 125.1 L148.1 127.0 L153.4 135.7 L155.1 140.4 L154.7 143.0 L151.7 145.7 L151.4 148.0 L156.7 147.0 L159.4 148.3 L162.7 148.0 L164.1 149.0 L164.1 149.7 L165.4 149.7 L165.7 147.0 L167.4 147.0 L168.4 148.3 L169.4 148.3 L169.7 146.7 L169.0 144.7 L167.7 143.0 L166.4 142.4 L162.4 142.0 L160.7 140.0 L159.7 137.7 L157.7 125.1 L161.4 121.7 L161.7 124.4 L160.7 126.4 L160.7 127.7 L161.7 128.0 L161.7 130.0 L162.7 130.7 L163.7 132.7 L170.0 140.7 L171.4 143.7 L171.0 147.3 L174.4 146.7 L175.0 147.3 L178.7 147.3 L179.7 148.3 L180.7 148.3 L181.4 147.0 L183.0 147.7 L183.0 147.0 L183.7 146.7 L184.4 148.0 L185.3 148.0 L185.3 145.3 L183.4 142.7 L182.0 142.0 L178.0 142.0 L175.4 139.7 L172.7 134.7 L169.7 125.4 L171.0 122.1 L174.0 117.4 L174.4 113.7 L175.0 113.1 L176.0 113.1 L178.4 108.7 L178.7 105.4 L179.0 105.1 L179.7 106.4 L180.7 106.4 L181.0 101.4 L179.7 99.1 L180.0 98.4 L181.0 98.4 L181.0 96.8 L179.0 93.8 L179.0 91.8 L176.7 89.4 L176.7 87.8 L173.4 84.8 L174.0 84.1 L174.0 83.1 L173.0 82.1 L173.0 78.1 L174.0 77.5 L174.7 79.1 L176.7 79.5 L179.7 78.1 L182.7 77.8 L185.3 78.5 L188.0 80.1 L189.0 80.1 L189.3 80.8 L190.7 80.8 L191.3 77.1 L193.0 77.1 L193.7 76.5 Z",
"lines": "M24.0 151.3 L24.0 152.0 L24.6 152.3 L24.6 153.3 L26.3 153.3 L26.6 151.3 Z M19.3 151.0 L19.0 152.0 L20.0 152.7 L20.0 153.7 L20.6 153.7 L21.0 151.3 Z M21.0 148.3 L21.0 149.0 L21.6 149.3 L23.3 149.3 L23.3 147.7 L22.0 147.7 Z M11.3 146.7 L11.7 149.3 L12.3 149.3 L12.7 148.7 L14.0 148.7 L14.0 148.0 Z M8.7 139.0 L8.0 139.0 L7.3 140.4 L7.3 142.0 L8.7 142.0 L9.0 140.0 Z M11.7 132.0 L10.7 132.0 L8.7 133.0 L8.7 133.7 L9.7 134.0 L9.3 135.0 L10.0 135.0 L11.7 133.0 Z M19.0 126.4 L16.3 126.7 L16.0 128.4 L18.3 127.7 Z M79.9 124.4 L79.9 126.0 L81.5 126.0 L81.5 125.4 L80.5 124.4 Z M63.9 124.1 L63.9 125.7 L65.2 126.0 L65.6 125.7 L65.2 124.4 Z M85.9 123.4 L85.9 125.1 L87.5 124.7 L86.9 123.4 Z M57.6 124.1 L57.6 124.7 L58.9 125.1 L59.9 124.7 L59.2 123.4 Z M22.6 125.1 L25.3 124.4 L25.3 123.7 L23.0 123.4 Z M28.6 121.7 L28.6 123.4 L31.0 123.1 L31.0 122.1 Z M132.1 121.4 L131.4 121.4 L128.1 125.4 L128.1 126.0 L129.4 125.7 L129.8 126.7 L130.8 126.4 L130.8 124.4 L132.1 122.4 Z M91.8 121.4 L91.8 123.1 L93.5 122.4 L93.5 121.4 Z M51.3 121.4 L51.3 123.1 L52.9 123.4 L52.9 122.4 L52.3 121.4 Z M42.9 120.4 L42.9 122.1 L44.9 122.1 L44.6 120.7 Z M34.6 120.4 L34.6 122.1 L37.3 122.1 L37.3 121.1 L35.9 120.4 Z M97.5 118.4 L97.5 120.1 L99.2 119.4 L99.2 118.4 Z M153.7 115.1 L153.1 115.1 L152.1 116.1 L150.4 119.7 L148.7 121.1 L148.7 123.1 L149.4 123.1 L150.4 122.1 L152.4 117.7 L153.7 116.1 Z M102.5 114.4 L102.5 116.4 L103.5 116.4 L104.8 115.4 L104.8 114.7 L104.2 114.4 Z M108.2 110.7 L108.2 112.4 L109.8 112.1 L109.8 111.1 Z M176.0 110.1 L175.0 110.1 L174.4 112.4 L175.4 112.4 Z M114.1 108.4 L112.8 108.1 L111.5 108.7 L110.8 109.7 L110.1 109.7 L110.1 110.4 L113.1 110.1 L114.1 109.1 Z M176.7 106.1 L176.7 108.7 L177.4 108.7 L177.7 106.1 Z M177.7 101.8 L178.0 104.4 L180.0 104.4 L179.7 102.8 L178.7 101.8 Z M136.1 100.1 L132.1 100.1 L124.8 101.4 L123.1 103.1 L119.8 103.4 L119.1 104.8 L115.5 105.8 L114.5 105.4 L114.5 107.7 L115.5 108.1 L118.1 107.4 L118.5 106.4 L120.8 106.1 L122.8 105.1 L123.5 103.8 L127.8 103.4 L129.1 102.8 L128.8 101.8 L129.1 101.4 L133.1 101.8 L134.4 101.1 L136.1 101.1 Z M177.7 96.1 L178.4 98.8 L179.0 98.8 L179.0 98.1 L180.0 97.8 L180.0 97.1 L178.7 96.1 Z M176.0 91.1 L176.0 92.1 L177.7 94.1 L178.4 94.1 L178.4 92.8 L177.4 91.4 Z M149.7 91.1 L149.7 91.8 L152.7 93.4 L153.7 93.1 L153.7 92.4 L152.1 90.8 L151.4 90.8 L151.1 91.4 Z M145.8 90.1 L146.1 91.1 L145.1 91.4 L145.1 92.1 L147.4 93.1 L149.1 93.1 L149.1 92.4 L146.8 90.1 Z M154.7 92.1 L154.7 92.8 L157.1 94.4 L158.1 94.4 L158.7 93.8 L160.4 95.1 L161.1 95.1 L161.7 94.1 L161.7 92.1 L160.7 91.4 L160.4 89.4 L159.4 89.4 L158.4 90.4 L158.4 91.4 L159.4 91.1 L160.1 92.4 L159.4 93.1 L158.1 92.8 L157.7 93.4 Z M173.7 87.1 L173.7 88.1 L175.4 89.8 L176.0 89.8 L176.0 88.8 L174.7 87.1 Z M171.4 79.5 L171.4 81.8 L172.4 82.1 L172.0 79.5 Z M174.4 76.1 L175.4 78.5 L176.7 78.5 L177.4 77.8 L177.4 77.1 L176.4 77.1 L175.7 76.1 Z M184.0 73.8 L184.7 75.1 L188.3 76.8 L189.3 76.8 L190.0 77.5 L190.7 77.5 L191.0 76.1 L192.0 76.1 L191.7 75.1 L190.0 75.1 L189.0 74.5 L186.0 73.8 Z M192.7 73.5 L192.7 75.8 L193.7 75.8 L193.7 73.5 Z M161.1 71.1 L159.7 71.1 L159.7 73.1 L161.1 72.5 Z M163.1 67.8 L163.1 70.1 L165.4 69.5 L165.4 68.5 Z M128.8 67.8 L127.1 67.8 L120.8 70.8 L111.8 77.8 L104.2 86.1 L99.2 93.1 L97.8 96.4 L98.5 96.4 L105.5 86.5 L114.5 77.1 L121.5 71.8 L125.8 69.5 L128.8 68.5 Z M127.5 65.8 L121.1 66.2 L112.8 67.8 L101.8 71.1 L95.2 73.8 L87.2 77.8 L79.5 82.5 L68.2 90.8 L67.6 92.1 L68.2 92.1 L82.9 81.8 L94.5 75.5 L108.5 70.1 L119.5 67.5 L127.5 66.5 Z M180.0 65.2 L180.0 65.8 L181.0 66.5 L182.7 66.8 L182.7 66.2 L181.4 65.2 Z M166.7 67.5 L166.7 68.2 L167.7 68.5 L169.4 68.2 L169.7 67.5 L172.7 68.2 L172.7 67.2 L169.0 65.2 L168.4 65.2 L168.7 67.2 Z M173.7 63.2 L174.0 64.2 L173.7 65.5 L176.7 66.2 L176.7 65.2 L174.7 63.2 Z M118.1 60.8 L118.5 61.8 L118.1 63.2 L124.5 63.8 L124.5 62.8 L119.5 60.8 Z"
},
"roaring": {
"body": "M8.5 59.6 L6.0 63.9 L6.0 66.1 L7.1 66.1 L8.5 63.6 L14.9 57.5 L24.6 51.8 L27.4 51.1 L32.8 51.4 L36.4 53.2 L38.5 55.4 L40.7 60.4 L40.7 66.4 L38.2 76.1 L36.0 81.4 L34.6 90.4 L36.0 90.4 L36.4 88.2 L38.9 83.9 L46.7 76.1 L56.0 69.7 L62.8 66.8 L66.4 67.1 L68.2 68.9 L68.5 70.4 L68.2 73.9 L63.9 85.0 L63.2 88.6 L64.3 88.6 L67.5 84.7 L71.4 82.2 L75.0 81.1 L79.3 81.8 L83.6 85.4 L85.0 87.9 L86.8 94.0 L87.1 100.4 L88.2 100.0 L90.0 96.1 L93.6 92.2 L96.4 90.0 L101.1 87.9 L106.1 86.8 L111.1 87.5 L112.9 88.6 L113.2 91.5 L120.7 87.9 L121.4 88.2 L120.4 89.7 L117.2 90.7 L116.1 92.5 L111.1 94.3 L108.9 95.7 L108.9 96.5 L112.5 96.5 L106.4 99.7 L106.4 100.7 L108.9 101.1 L103.6 104.3 L103.6 105.4 L105.4 105.0 L105.7 106.1 L102.1 108.3 L100.7 110.0 L100.7 111.1 L102.5 110.8 L102.9 111.5 L97.1 114.3 L97.1 115.0 L98.9 115.4 L98.6 116.1 L92.1 117.2 L92.1 118.3 L93.9 119.0 L92.9 120.0 L86.4 119.0 L86.1 120.0 L87.8 121.5 L86.4 121.8 L81.8 119.3 L80.3 119.3 L80.3 120.4 L81.4 121.5 L81.1 122.2 L75.0 117.9 L73.9 117.9 L75.3 120.4 L75.0 121.1 L67.1 116.8 L66.0 117.2 L66.0 117.9 L66.8 118.3 L66.4 119.0 L61.4 117.2 L55.3 117.2 L55.0 118.6 L49.6 119.0 L43.5 120.8 L36.4 125.0 L33.2 129.3 L33.2 130.4 L33.9 130.8 L32.8 134.3 L33.5 140.4 L34.6 140.4 L35.0 139.0 L37.1 143.3 L41.0 147.6 L44.2 149.7 L48.5 151.5 L50.7 151.5 L51.0 150.1 L54.6 150.4 L58.9 149.7 L60.7 149.0 L60.7 147.9 L53.9 147.9 L50.0 146.9 L47.8 145.4 L48.5 144.7 L48.2 143.3 L42.8 141.8 L40.0 139.0 L38.5 135.1 L38.9 132.2 L41.4 128.3 L46.7 125.0 L54.6 123.6 L59.6 124.0 L67.5 126.1 L80.0 131.1 L86.1 132.2 L90.3 132.2 L96.4 131.1 L101.8 129.3 L113.9 121.8 L117.2 124.3 L117.2 125.8 L115.4 129.3 L112.5 132.6 L112.5 135.1 L118.2 140.4 L118.6 141.8 L117.9 144.3 L121.8 144.3 L123.6 146.5 L122.9 149.0 L123.2 150.8 L124.7 150.8 L127.5 149.4 L131.1 150.4 L134.3 149.7 L135.7 151.1 L136.1 153.6 L137.5 153.6 L138.2 151.9 L138.2 148.3 L139.3 148.3 L141.1 151.1 L142.2 151.1 L142.5 150.4 L142.2 147.2 L140.4 144.7 L136.8 142.9 L131.8 143.3 L129.0 142.2 L122.9 136.5 L121.4 134.0 L128.2 127.9 L130.0 123.6 L131.1 123.3 L133.6 120.4 L140.0 115.0 L140.7 113.3 L140.7 110.8 L138.2 105.0 L144.7 101.1 L146.1 101.8 L147.2 104.7 L148.3 105.7 L152.2 105.7 L158.6 104.0 L162.2 103.6 L165.4 106.1 L165.4 109.3 L164.3 110.0 L164.7 111.5 L167.2 111.5 L169.0 109.7 L169.7 109.7 L170.8 111.8 L170.1 114.7 L171.8 114.7 L172.9 114.0 L174.3 111.1 L175.1 111.8 L175.1 114.7 L175.8 114.7 L177.6 112.5 L177.6 110.0 L176.8 107.9 L174.7 105.4 L165.8 99.0 L154.7 97.2 L154.3 96.5 L158.3 91.8 L160.4 91.8 L162.9 92.9 L166.1 92.5 L169.7 89.0 L173.6 82.5 L176.5 79.3 L181.8 77.5 L184.3 77.5 L185.8 79.7 L185.1 81.8 L187.2 81.8 L188.3 81.1 L189.4 78.9 L190.4 79.7 L190.4 81.1 L191.9 81.1 L192.6 79.3 L192.2 77.2 L190.1 74.3 L190.8 73.9 L192.6 75.7 L193.6 75.7 L193.6 73.2 L191.9 71.1 L190.1 70.4 L184.0 70.0 L178.6 72.9 L172.6 74.3 L168.3 78.9 L163.3 82.2 L161.8 81.4 L161.8 77.2 L160.0 71.8 L153.3 63.2 L152.9 58.2 L154.0 57.5 L154.3 54.3 L156.1 53.9 L157.2 51.8 L159.7 49.6 L160.8 50.0 L160.4 52.1 L161.1 52.1 L162.9 50.3 L164.7 50.7 L166.5 50.0 L169.0 50.0 L173.3 51.4 L175.1 52.9 L175.1 53.9 L175.8 54.3 L179.0 53.9 L180.4 52.1 L180.1 50.0 L179.3 48.9 L177.6 48.9 L177.2 47.5 L175.8 47.5 L173.6 45.7 L173.3 42.5 L175.1 41.1 L179.3 40.3 L181.1 40.7 L181.5 39.6 L182.6 39.6 L183.3 38.9 L183.3 36.1 L181.8 34.6 L177.9 33.9 L174.7 35.0 L171.8 35.0 L170.8 34.3 L166.8 33.9 L162.2 31.0 L161.1 31.0 L161.5 32.8 L162.9 34.3 L162.5 35.0 L158.6 33.2 L155.8 30.3 L154.7 30.3 L154.7 31.4 L156.1 33.6 L155.8 34.3 L151.5 34.3 L148.6 35.7 L148.6 37.5 L144.7 37.8 L140.7 39.3 L140.4 40.3 L146.8 40.3 L146.1 41.1 L138.6 43.2 L135.4 45.3 L135.4 46.4 L139.0 45.3 L140.7 45.7 L134.7 49.3 L131.8 52.1 L131.8 52.9 L133.2 52.9 L136.5 51.1 L136.8 51.4 L132.2 56.8 L130.7 59.6 L130.7 60.7 L131.8 60.7 L134.0 58.2 L134.7 58.6 L131.8 63.9 L131.8 66.1 L132.5 66.1 L134.0 64.3 L134.7 64.6 L134.3 67.9 L133.2 68.2 L127.9 66.1 L126.8 66.1 L126.8 67.5 L125.7 67.9 L121.4 65.4 L113.2 57.9 L116.1 47.8 L122.2 36.1 L122.5 30.7 L121.1 27.1 L116.1 21.8 L115.4 21.8 L115.4 23.5 L118.6 28.2 L118.6 30.0 L108.9 25.0 L97.5 21.4 L90.7 18.5 L85.7 18.9 L85.7 20.0 L90.7 21.4 L91.1 22.1 L90.3 22.8 L77.1 24.3 L64.6 26.4 L56.4 28.5 L44.6 32.8 L36.4 37.1 L23.2 45.7 L14.6 52.9 Z M149.0 37.1 L149.7 36.4 L153.6 36.4 L156.1 37.5 L152.2 37.8 Z",
"lines": "M46.4 148.3 L46.4 149.0 L47.5 150.1 L50.0 150.8 L50.0 149.0 Z M45.0 144.3 L45.0 145.1 L46.0 146.1 L47.1 146.1 L47.1 144.3 Z M34.6 134.7 L33.9 136.5 L33.9 138.3 L35.7 138.3 L35.7 135.8 L35.3 134.7 Z M37.1 127.2 L36.0 127.2 L34.6 128.6 L34.6 131.1 L35.3 131.1 Z M88.6 120.8 L88.6 122.5 L90.3 122.2 L89.6 120.8 Z M76.1 120.4 L76.1 122.2 L77.5 122.5 L77.1 120.8 Z M67.5 118.3 L67.5 120.0 L70.0 120.8 L70.0 119.7 L68.9 118.6 Z M94.6 117.9 L94.6 120.0 L95.7 120.0 L97.1 119.0 L97.1 118.3 Z M56.0 118.6 L56.0 119.3 L61.0 119.3 L61.0 118.6 L59.6 117.9 L57.8 117.9 L57.5 118.6 Z M101.4 114.3 L99.6 114.3 L99.6 116.1 L100.4 116.1 L101.4 115.0 Z M131.5 112.2 L130.7 112.2 L130.0 113.3 L129.3 122.5 L130.4 122.5 L131.1 121.5 Z M106.1 107.9 L102.9 109.0 L103.6 111.5 L105.0 110.8 L106.1 109.0 Z M108.6 104.0 L107.9 103.6 L106.4 104.0 L106.4 104.7 L107.1 105.0 L106.4 106.5 L107.1 106.5 L108.6 105.0 Z M111.8 99.3 L109.3 99.3 L109.7 101.8 L110.4 101.8 L111.8 100.4 Z M144.7 96.8 L145.0 98.6 L144.7 100.4 L146.5 100.4 L146.1 98.2 L145.4 96.8 Z M115.4 95.0 L113.2 95.0 L113.6 96.1 L113.2 97.2 L113.9 97.2 L115.4 95.7 Z M119.7 91.1 L117.9 91.5 L117.2 92.9 L118.9 92.5 Z M125.7 86.1 L121.8 86.4 L122.2 89.0 L123.2 89.0 L125.7 86.8 Z M127.5 67.1 L127.2 69.3 L130.7 69.7 L130.7 68.9 L129.3 67.5 Z M136.1 65.7 L135.0 67.1 L135.0 68.2 L136.1 67.9 L136.5 68.6 L133.6 68.9 L133.6 69.7 L135.0 69.7 L137.5 70.7 L136.8 65.7 Z M136.1 61.8 L134.7 61.8 L133.6 62.9 L133.6 63.6 L135.7 63.6 Z M151.5 59.3 L151.5 61.4 L151.8 62.1 L152.5 62.1 L152.2 59.3 Z M135.4 56.1 L134.3 56.8 L134.3 57.5 L135.0 57.5 L135.4 58.6 L136.1 58.6 L136.5 56.1 Z M152.9 55.4 L151.8 55.4 L151.5 57.9 L152.9 57.1 Z M156.5 50.7 L155.8 50.7 L154.0 52.5 L154.0 53.2 L155.8 52.9 Z M139.3 49.6 L137.5 49.6 L137.5 51.8 L138.2 51.8 L139.3 50.7 Z M160.0 48.2 L160.0 48.9 L161.5 49.3 L162.5 48.9 L162.9 49.6 L165.0 49.6 L165.0 48.6 L162.9 48.9 L162.5 47.8 Z M144.3 43.6 L140.7 43.9 L140.7 44.6 L141.5 45.0 L141.5 46.1 L142.5 46.1 L144.3 44.6 Z M147.5 39.3 L147.9 40.3 L147.5 41.4 L151.1 40.7 L150.8 39.6 Z M182.2 37.8 L180.8 37.8 L180.4 38.9 L179.0 38.6 L178.6 39.6 L180.4 39.6 L180.8 38.9 L181.8 38.9 Z M105.7 37.8 L103.9 38.2 L100.0 40.3 L90.3 47.1 L80.7 56.4 L77.1 60.7 L76.8 62.1 L77.5 62.1 L81.1 57.9 L90.3 48.9 L95.7 44.6 L105.7 38.6 Z M156.8 36.4 L156.8 38.6 L159.7 38.2 L159.3 37.1 Z M163.6 33.9 L163.6 36.4 L165.4 36.4 L165.8 35.0 Z M156.8 34.3 L157.2 35.3 L159.3 35.3 L159.3 34.6 L158.3 33.9 Z M86.8 18.5 L86.8 19.3 L90.0 19.6 L90.0 18.9 L89.3 18.5 Z"
},
"sitting": {
"body": "M6.0 119.8 L6.0 131.0 L6.6 132.2 L7.5 132.2 L7.5 127.4 L9.0 121.7 L11.4 116.5 L14.8 111.4 L18.7 106.5 L25.3 100.2 L32.0 95.4 L35.9 93.5 L38.3 93.5 L41.1 96.0 L42.3 99.3 L42.3 102.6 L41.1 107.2 L41.1 109.9 L41.7 109.9 L45.0 102.6 L47.7 99.0 L51.9 94.8 L56.5 91.4 L64.9 87.2 L70.7 85.7 L74.3 85.7 L77.6 86.6 L80.7 88.1 L83.7 91.1 L85.5 94.5 L86.7 99.9 L86.4 105.0 L87.3 105.0 L89.4 98.4 L93.4 92.6 L95.8 90.5 L99.7 88.4 L103.6 87.5 L106.3 87.5 L111.8 89.6 L113.9 91.7 L114.5 94.2 L115.1 94.8 L112.1 96.6 L107.3 96.6 L107.0 97.5 L108.2 97.8 L108.2 98.7 L103.6 99.6 L103.6 100.5 L105.1 100.8 L104.5 101.7 L100.0 102.9 L99.7 104.1 L101.8 104.4 L100.9 105.3 L97.3 106.8 L97.3 107.8 L98.8 108.1 L98.5 108.7 L94.9 110.2 L94.9 111.1 L96.1 111.1 L96.4 111.7 L92.7 113.5 L92.7 114.4 L94.0 114.4 L94.3 115.0 L93.0 115.9 L90.0 116.8 L90.0 117.7 L91.2 117.7 L91.5 118.3 L90.6 119.2 L86.7 120.8 L86.7 121.4 L87.9 122.0 L86.7 123.5 L84.6 123.5 L83.1 124.1 L83.1 124.7 L84.6 125.3 L84.3 125.9 L82.5 126.8 L78.5 126.8 L78.5 127.7 L80.1 128.6 L79.1 129.5 L74.9 129.2 L74.6 130.4 L75.8 131.0 L75.2 131.9 L70.1 131.6 L70.1 132.5 L71.3 133.4 L71.0 134.1 L69.2 134.4 L65.2 133.7 L65.2 134.7 L66.1 135.3 L65.5 136.2 L60.4 135.6 L61.3 137.1 L61.0 137.7 L56.8 136.5 L56.5 137.4 L57.1 138.3 L56.2 138.6 L52.2 137.1 L51.9 138.0 L52.5 138.9 L51.6 139.2 L48.3 137.4 L47.4 137.4 L47.7 138.9 L47.1 139.2 L44.1 136.8 L43.2 136.8 L43.2 137.7 L42.6 138.0 L41.4 136.8 L40.5 134.7 L39.9 134.7 L39.5 135.6 L38.9 135.3 L38.6 134.1 L39.2 133.1 L39.2 131.6 L38.3 131.6 L38.0 131.0 L38.6 129.5 L39.2 129.2 L39.2 128.3 L42.3 125.6 L47.7 123.5 L53.2 123.5 L57.4 124.7 L60.1 126.2 L61.0 126.2 L61.0 125.3 L58.0 122.6 L53.8 121.4 L53.5 120.5 L52.5 120.1 L47.1 120.1 L45.6 120.8 L43.8 120.5 L38.6 122.6 L37.7 123.8 L36.8 123.8 L35.0 125.9 L34.1 128.9 L33.5 129.5 L32.3 129.2 L32.3 132.2 L33.2 134.4 L32.0 134.4 L31.7 135.3 L32.9 137.4 L36.8 141.3 L43.2 144.0 L47.1 144.6 L56.2 144.6 L61.0 144.0 L72.5 140.7 L82.5 136.2 L90.0 131.6 L102.7 122.6 L103.0 124.4 L101.5 128.3 L97.9 131.0 L96.1 134.4 L94.6 135.6 L92.4 135.6 L90.0 136.8 L88.2 138.6 L85.5 143.1 L81.6 144.3 L77.6 149.2 L74.3 151.3 L74.3 152.2 L76.4 152.2 L89.1 149.8 L90.3 150.4 L93.7 150.4 L95.5 149.5 L103.0 147.7 L106.6 147.7 L108.8 148.3 L113.6 147.7 L116.6 148.3 L120.6 147.4 L126.0 147.4 L129.9 146.7 L131.1 145.5 L134.2 144.3 L136.3 144.3 L140.8 146.4 L141.4 147.7 L145.0 148.9 L160.5 148.9 L164.4 149.5 L169.8 151.3 L171.0 151.3 L171.9 150.1 L173.7 149.8 L180.1 151.3 L181.0 152.2 L188.0 152.5 L190.7 153.7 L193.7 153.7 L193.7 152.5 L191.3 150.7 L190.4 148.9 L188.9 147.4 L186.7 146.4 L184.6 143.1 L183.4 142.2 L182.5 137.4 L181.6 135.9 L179.2 134.1 L175.6 132.8 L173.4 130.1 L171.6 128.9 L170.7 125.3 L166.8 121.1 L165.0 120.8 L164.1 119.8 L160.5 113.2 L154.1 107.8 L152.0 107.8 L150.8 107.2 L147.8 103.2 L145.9 99.6 L145.6 97.8 L149.0 94.2 L150.5 90.2 L151.7 89.9 L151.4 85.1 L152.3 84.8 L152.3 83.3 L151.4 80.9 L152.0 79.3 L149.6 75.7 L150.2 74.5 L147.5 71.2 L148.1 70.0 L146.5 68.2 L147.2 67.6 L147.2 66.6 L146.2 64.5 L147.5 64.2 L147.2 63.0 L148.1 62.7 L148.1 61.2 L148.7 60.6 L152.6 60.6 L153.8 59.7 L158.6 60.9 L159.2 62.1 L160.1 62.1 L161.4 60.6 L161.1 58.5 L159.5 58.2 L158.6 57.0 L156.8 56.4 L156.5 55.5 L159.8 54.9 L162.6 55.8 L162.9 55.2 L162.9 52.7 L162.0 51.5 L160.8 50.9 L157.4 50.9 L148.1 47.0 L147.2 47.0 L148.1 48.5 L147.8 49.1 L142.9 47.9 L142.3 47.9 L142.0 48.5 L140.5 48.5 L134.5 46.1 L134.5 47.3 L135.4 48.2 L140.5 51.2 L140.2 52.7 L134.5 53.0 L134.5 54.0 L137.5 54.3 L137.8 54.9 L132.9 57.0 L132.3 58.2 L135.1 58.2 L129.9 62.4 L129.9 63.0 L131.1 63.0 L132.6 62.1 L133.2 62.4 L133.2 63.0 L130.8 65.7 L130.2 67.6 L132.0 67.0 L132.3 67.3 L131.1 70.6 L131.1 72.1 L132.0 72.4 L132.9 70.9 L133.5 71.2 L132.6 73.6 L132.6 75.1 L133.9 75.4 L134.2 76.3 L135.1 76.6 L134.8 77.2 L131.7 76.0 L127.8 75.4 L121.8 73.6 L115.7 70.6 L113.0 68.2 L112.7 64.2 L113.6 60.0 L116.0 53.0 L118.4 48.5 L119.3 47.9 L120.9 48.2 L122.4 49.4 L123.0 51.2 L123.9 51.2 L124.2 50.0 L123.6 47.6 L121.8 45.8 L117.2 44.6 L116.6 44.0 L108.8 44.0 L108.2 44.6 L88.8 47.0 L79.1 48.8 L67.7 52.1 L55.9 57.6 L47.1 63.0 L39.5 68.8 L34.4 73.3 L23.8 84.5 L17.5 92.9 L13.6 99.6 L8.7 110.2 L6.9 116.2 L6.6 119.2 Z M117.5 113.8 L117.8 115.3 L116.0 118.0 L116.0 118.9 L117.2 119.8 L117.2 121.4 L114.8 122.3 L112.1 125.6 L111.5 128.3 L109.7 130.7 L107.9 131.0 L106.6 130.1 L105.7 130.1 L105.7 126.8 L110.0 118.0 L113.9 114.7 L115.7 113.8 Z M130.5 106.5 L132.3 109.3 L132.6 111.1 L133.2 111.1 L133.9 112.0 L134.2 115.3 L132.0 115.9 L130.5 114.7 L129.0 114.7 L126.0 115.9 L123.3 115.9 L123.0 114.4 L127.8 110.2 L129.0 106.8 Z M138.7 100.8 L140.2 100.8 L146.5 107.8 L146.5 109.0 L145.3 110.5 L140.8 112.9 L137.8 112.9 L137.2 112.3 L135.1 106.5 L135.1 103.8 Z",
"lines": "M191.3 152.8 L191.3 153.4 L191.9 153.7 L193.7 153.7 L193.7 153.1 Z M61.9 136.5 L61.9 138.0 L63.1 138.0 L63.4 137.1 Z M66.8 135.0 L66.8 136.5 L68.3 135.9 L68.0 135.0 Z M33.8 134.4 L33.8 135.0 L32.9 135.3 L32.9 135.9 L33.5 136.8 L35.3 137.1 L34.4 134.4 Z M34.4 130.1 L33.8 130.1 L33.2 131.0 L33.5 132.5 L34.1 132.5 Z M40.5 122.9 L39.2 123.2 L38.3 124.4 L37.7 124.4 L36.8 125.6 L36.2 125.6 L35.9 127.4 L36.5 127.4 L38.0 125.3 L40.5 123.5 Z M45.0 121.4 L43.5 121.4 L42.0 122.0 L42.0 122.9 L45.0 122.0 Z M88.5 120.8 L88.8 121.7 L88.5 122.6 L90.3 121.7 L90.3 120.8 Z M50.4 120.8 L50.4 121.7 L52.8 121.7 L52.8 121.1 Z M6.3 120.5 L6.0 129.2 L6.3 130.4 L6.9 130.4 L6.6 129.2 L6.9 120.5 Z M104.5 115.9 L103.9 115.9 L102.7 118.0 L103.0 120.8 L102.4 122.0 L103.9 122.0 L103.9 117.7 L104.5 116.8 Z M98.5 110.2 L97.0 110.2 L97.0 112.3 L97.9 112.0 L98.5 111.1 Z M100.9 106.8 L99.4 106.8 L99.4 108.7 L100.0 108.7 Z M129.6 86.0 L128.4 86.0 L122.4 89.6 L116.0 92.6 L115.4 93.2 L115.4 93.9 L116.3 94.2 L115.7 94.5 L115.7 95.4 L116.9 95.1 L121.5 91.4 L129.6 86.6 Z M149.6 78.4 L150.2 80.6 L150.8 80.6 L150.8 78.7 Z M147.5 73.3 L147.5 74.2 L148.1 75.1 L149.0 75.4 L148.4 73.3 Z M134.2 72.4 L133.5 73.3 L133.5 74.2 L134.2 74.2 L135.1 75.1 L135.1 75.7 L135.7 75.7 L135.1 72.7 Z M145.0 65.4 L145.0 67.6 L145.3 68.2 L145.9 68.2 L145.9 66.0 L145.6 65.4 Z M134.2 65.1 L132.0 65.7 L132.0 66.3 L132.9 66.6 L132.9 67.9 L133.5 67.9 Z M103.6 63.3 L102.7 63.3 L99.7 66.6 L94.6 74.2 L91.2 82.7 L89.7 89.6 L90.3 89.6 L92.4 83.0 L96.7 74.2 L100.9 67.3 L103.6 63.9 Z M133.5 60.9 L133.9 63.0 L134.5 63.0 L135.1 60.9 Z M72.8 60.9 L71.6 61.2 L68.6 63.3 L62.8 68.2 L55.0 76.6 L48.9 86.0 L45.3 94.2 L44.7 97.2 L45.3 97.2 L47.1 92.3 L49.8 86.9 L56.5 76.9 L64.9 67.9 L72.2 62.1 Z M148.4 59.4 L148.4 60.0 L149.6 59.7 L151.4 60.0 L151.4 59.1 L150.2 59.4 L149.9 58.8 L149.3 58.8 Z M137.2 57.0 L135.7 57.0 L135.7 58.8 L136.3 58.8 L137.2 57.9 Z M138.4 54.0 L138.4 55.5 L139.3 55.5 L139.9 54.3 Z M141.1 50.3 L141.1 53.4 L142.3 53.4 L142.9 52.1 L145.3 52.1 L145.0 51.2 Z M148.7 48.2 L148.7 50.0 L150.2 50.3 L150.2 49.1 L149.3 48.2 Z M109.4 44.3 L109.4 45.2 L112.7 44.6 L116.0 44.9 L116.0 44.0 Z"
},
"resting": {
"body": "M193.7 139.7 L185.5 129.8 L178.3 127.8 L180.7 125.1 L182.4 120.3 L181.4 119.9 L180.0 122.0 L179.4 121.6 L180.7 118.2 L181.1 112.1 L179.0 102.9 L178.0 102.9 L178.0 112.1 L177.3 115.2 L176.6 115.9 L176.3 109.0 L174.9 108.7 L173.9 103.6 L171.5 98.8 L170.2 98.5 L171.5 104.3 L171.2 105.0 L168.8 102.9 L168.1 99.5 L166.4 96.4 L165.1 96.4 L165.7 98.5 L165.4 100.2 L162.7 96.4 L160.3 94.4 L159.6 94.4 L159.9 96.4 L159.3 96.8 L155.5 93.0 L154.2 93.0 L154.5 94.4 L153.1 94.7 L149.4 92.4 L148.0 92.4 L148.4 93.7 L147.0 94.1 L143.3 92.4 L140.9 92.0 L141.6 93.4 L141.2 94.4 L130.3 94.7 L130.3 95.8 L131.7 96.1 L132.4 96.8 L128.3 98.5 L124.9 98.5 L124.5 100.2 L123.5 98.5 L123.5 95.1 L124.9 91.7 L128.9 86.9 L133.4 84.2 L137.8 82.8 L142.9 83.2 L150.1 85.9 L153.5 88.9 L154.5 88.9 L154.5 87.9 L153.5 85.9 L150.7 83.2 L144.6 79.8 L139.5 77.7 L129.6 75.3 L128.9 74.6 L117.4 74.6 L116.7 75.3 L91.1 79.1 L75.1 82.8 L61.9 87.6 L43.5 97.1 L27.5 108.7 L16.6 119.6 L12.5 124.7 L6.0 135.9 L6.0 146.8 L9.4 153.7 L10.8 153.7 L9.4 149.2 L9.4 146.2 L11.1 140.7 L14.5 135.3 L19.3 130.5 L21.7 129.1 L24.1 128.8 L25.1 130.5 L25.1 135.9 L25.8 137.7 L26.8 137.7 L27.1 133.9 L31.2 126.4 L36.3 121.3 L41.4 118.6 L44.5 118.6 L45.8 120.3 L45.8 121.6 L40.7 124.0 L40.4 125.4 L41.1 125.4 L41.4 126.1 L40.1 126.4 L40.1 127.1 L37.7 129.1 L37.7 130.2 L38.4 130.2 L38.7 130.8 L37.7 132.5 L37.3 134.6 L38.4 134.9 L39.7 134.2 L43.8 139.7 L46.2 141.4 L51.3 143.4 L54.0 143.1 L53.7 141.4 L51.6 139.4 L52.3 138.7 L58.4 142.1 L63.9 144.1 L73.4 146.2 L82.3 147.2 L99.0 146.8 L120.4 144.1 L134.4 144.5 L141.6 145.8 L148.0 147.9 L152.8 150.6 L155.5 153.7 L156.2 152.6 L155.5 148.6 L152.4 145.1 L147.0 142.1 L146.3 140.7 L142.2 139.4 L138.5 139.0 L138.1 138.0 L139.8 137.3 L142.9 137.3 L147.0 139.0 L149.0 139.0 L149.4 138.3 L154.5 137.7 L155.2 138.3 L155.2 139.7 L157.6 141.1 L159.6 140.0 L167.1 140.4 L174.2 142.4 L179.7 141.7 L182.8 142.1 L184.8 141.1 L187.5 142.1 L187.9 141.4 L189.6 141.4 L192.3 142.8 L193.7 142.8 Z M80.2 131.5 L86.7 130.8 L101.4 130.8 L121.5 132.2 L125.9 133.6 L130.7 133.6 L131.0 136.6 L130.3 137.3 L126.6 137.3 L126.2 135.9 L118.7 136.3 L118.4 134.9 L114.0 135.9 L111.2 135.9 L110.9 134.6 L105.1 136.3 L103.4 136.3 L103.1 134.9 L102.0 134.9 L98.0 136.6 L96.3 136.6 L95.6 134.9 L91.5 136.6 L89.4 136.6 L89.4 134.6 L83.7 135.6 L83.3 133.9 L80.2 133.6 Z M150.1 108.0 L153.1 108.0 L157.6 109.4 L162.0 113.1 L163.3 115.5 L162.7 118.9 L161.0 118.9 L158.9 116.2 L160.3 121.0 L158.9 121.3 L159.6 125.1 L158.6 126.4 L157.2 126.4 L151.8 122.7 L150.1 120.6 L150.7 117.2 L149.7 114.8 L150.1 112.8 L149.0 111.4 L149.0 108.7 Z",
"lines": "M141.9 140.4 L142.2 141.4 L146.0 142.4 L145.6 141.4 Z M6.3 136.6 L6.0 144.8 L6.3 146.2 L7.0 146.2 L7.0 142.4 L6.7 142.1 L7.0 136.6 Z M131.7 138.3 L137.5 139.4 L137.5 138.0 L135.4 137.7 L138.8 137.0 L139.2 135.9 L136.8 136.6 L135.4 135.9 L133.4 136.3 L132.7 135.3 L132.0 135.3 Z M132.7 137.3 L133.0 137.0 L135.4 137.3 L135.1 137.7 Z M41.1 128.8 L39.4 128.8 L39.4 131.2 L40.7 130.5 Z M74.1 128.5 L74.1 129.5 L75.1 130.5 L75.1 131.5 L76.2 132.2 L77.9 132.2 L78.2 133.6 L79.6 133.9 L79.6 131.2 Z M127.9 124.4 L127.9 125.1 L128.9 126.1 L136.1 128.8 L136.8 129.5 L132.4 131.5 L131.7 132.2 L131.7 134.2 L132.4 134.2 L133.4 132.9 L136.1 130.8 L137.1 130.8 L139.2 129.8 L140.9 129.8 L141.9 130.5 L146.3 130.8 L150.1 132.5 L153.1 135.6 L153.8 137.0 L155.5 137.0 L155.9 134.2 L157.6 131.5 L157.6 130.5 L158.9 127.8 L158.9 127.1 L157.2 127.1 L155.9 129.8 L148.7 130.5 L146.0 129.5 L139.2 128.8 Z M151.1 131.2 L154.5 130.8 L156.5 131.2 L155.2 132.9 L154.2 135.3 L153.5 133.9 L150.7 131.5 Z M43.8 124.4 L42.1 124.4 L42.1 126.8 L42.8 126.8 L43.8 125.4 Z M180.4 122.7 L179.0 123.3 L178.7 121.6 L178.0 121.6 L177.7 122.7 L175.9 124.4 L174.9 124.4 L174.2 125.1 L173.2 127.4 L169.5 130.5 L168.5 132.2 L168.5 132.9 L169.5 133.2 L168.8 133.9 L165.1 135.6 L163.0 135.9 L160.3 138.0 L159.6 139.4 L160.6 139.4 L164.7 136.6 L166.8 136.3 L170.8 134.2 L173.9 131.5 L177.0 130.2 L177.7 129.1 L177.7 127.4 L175.9 128.1 L175.3 129.5 L174.2 129.8 L169.8 133.2 L169.1 132.9 L170.8 130.8 L172.2 130.2 L174.2 128.1 L175.3 126.1 L178.3 125.4 L180.4 123.3 Z M149.7 121.6 L148.7 122.0 L147.7 124.4 L148.4 124.4 L149.7 123.0 Z M174.9 109.7 L174.2 109.7 L174.2 111.8 L173.2 113.5 L172.2 117.2 L170.5 119.9 L170.5 121.0 L171.9 120.3 L174.2 114.8 L174.9 115.9 L174.6 116.9 L175.3 117.2 L174.2 120.6 L175.3 120.6 L177.7 117.2 L177.7 116.5 L175.6 116.2 L175.6 114.2 L174.9 114.2 L174.6 114.8 L174.2 114.5 L174.2 113.5 L175.6 111.4 L175.6 110.4 Z M126.2 110.4 L124.2 109.0 L119.1 107.3 L110.9 107.0 L104.4 108.7 L101.4 110.1 L99.0 111.8 L97.6 110.4 L94.2 109.0 L88.4 109.0 L80.9 110.7 L69.7 114.8 L69.3 113.1 L68.7 112.4 L65.3 112.4 L60.2 114.5 L54.0 118.9 L48.6 125.1 L46.2 129.1 L45.8 127.8 L46.9 122.7 L45.8 123.0 L44.1 132.2 L44.5 134.6 L45.5 134.6 L45.8 132.5 L48.6 127.4 L52.0 123.0 L56.1 118.9 L59.8 116.2 L65.9 113.5 L68.0 113.5 L68.7 114.5 L68.7 115.9 L73.1 114.8 L75.1 115.5 L81.6 115.9 L88.1 117.9 L94.2 121.3 L97.6 124.0 L102.4 129.1 L103.7 129.5 L103.7 128.8 L99.0 123.3 L92.5 118.6 L86.4 115.9 L82.3 114.8 L75.5 114.5 L75.1 114.2 L83.0 111.4 L89.8 110.1 L94.6 110.4 L96.3 111.1 L98.3 112.8 L99.3 112.8 L105.1 109.7 L111.9 108.0 L116.7 108.0 L122.5 109.4 L125.5 111.1 L126.2 111.1 Z M168.8 104.3 L169.1 105.6 L170.2 106.0 L171.2 108.7 L170.5 113.1 L168.5 116.5 L168.5 117.2 L169.5 117.2 L171.9 112.4 L172.5 106.3 L172.2 105.6 L171.2 106.0 L170.2 105.6 L169.5 104.3 Z M125.5 99.2 L125.5 100.9 L125.2 101.2 L123.8 100.9 L123.8 101.6 L125.5 103.3 L126.6 103.3 L126.6 102.6 L125.2 101.2 L127.6 100.5 L127.9 99.5 Z M160.6 96.4 L160.6 97.1 L159.6 97.5 L159.6 98.1 L160.6 98.8 L162.0 98.8 L161.3 96.4 Z M153.8 95.4 L153.8 96.1 L156.2 96.4 L155.9 94.7 L155.2 94.7 L154.8 95.4 Z M149.0 93.4 L149.0 95.4 L150.4 95.4 L150.7 94.4 L149.7 93.4 Z M142.2 93.4 L142.2 95.1 L143.9 95.1 L143.9 94.1 Z M123.2 83.5 L119.8 84.9 L112.3 90.7 L105.8 98.1 L103.4 101.9 L102.7 103.9 L104.1 103.3 L106.1 99.8 L110.9 94.1 L117.4 87.9 L123.2 84.2 Z M86.0 83.5 L78.9 85.5 L71.1 88.9 L64.6 92.4 L56.1 97.8 L47.9 104.3 L38.7 113.5 L35.3 117.6 L34.9 118.9 L35.6 118.9 L47.6 106.7 L57.8 98.5 L69.3 91.3 L77.9 87.2 L86.0 84.2 Z M109.5 81.1 L102.7 82.5 L91.8 86.2 L80.9 91.3 L76.5 94.1 L69.3 99.2 L61.9 106.0 L55.7 113.1 L52.0 118.6 L52.0 119.3 L53.3 118.6 L59.8 110.4 L67.6 102.6 L78.5 94.4 L88.8 88.9 L98.0 85.2 L109.5 81.8 Z M118.1 75.0 L118.1 75.7 L121.8 75.7 L122.1 75.3 L128.3 75.7 L128.3 75.0 L127.2 74.6 Z"
},
"coiled": {
"body": "M193.8 52.4 L191.4 49.8 L189.5 48.6 L181.6 45.3 L171.4 42.4 L168.8 41.2 L167.1 41.0 L166.6 40.5 L158.5 40.5 L158.1 41.0 L149.3 41.4 L125.9 41.7 L124.0 42.2 L116.7 45.7 L112.4 45.7 L111.2 46.2 L111.4 46.9 L113.3 47.2 L113.8 48.1 L109.8 50.7 L96.0 56.9 L95.5 57.4 L95.5 59.5 L93.8 58.6 L93.8 59.5 L93.3 59.8 L89.8 56.4 L89.1 56.4 L89.1 57.2 L89.8 58.1 L89.5 58.3 L87.1 56.9 L86.4 56.9 L86.2 57.9 L84.5 56.7 L83.1 56.4 L83.1 57.9 L79.3 57.9 L78.8 59.3 L76.2 59.5 L76.0 60.5 L68.3 60.2 L64.1 58.6 L57.2 57.4 L54.5 55.7 L51.7 56.0 L51.7 56.7 L52.2 56.7 L52.4 57.2 L51.7 57.9 L49.5 58.6 L48.1 58.6 L46.5 57.4 L44.3 56.9 L42.2 56.9 L41.9 57.4 L41.2 56.9 L39.3 56.9 L39.3 57.6 L42.6 58.1 L44.3 59.1 L36.0 62.2 L29.1 65.5 L23.8 69.1 L16.9 75.0 L12.4 79.5 L7.4 86.7 L6.0 90.0 L6.0 94.3 L7.0 94.8 L7.4 91.9 L9.1 88.8 L12.4 85.7 L16.7 83.3 L19.1 83.3 L21.5 85.0 L22.2 86.4 L22.2 87.6 L21.5 89.0 L21.5 90.9 L21.9 90.9 L24.3 87.4 L30.3 81.9 L35.5 78.6 L41.7 75.7 L46.5 74.3 L48.8 74.3 L49.5 75.7 L50.3 76.0 L52.4 73.3 L54.8 71.7 L59.5 69.1 L63.6 67.6 L66.7 67.1 L71.9 67.1 L79.8 68.1 L80.0 68.3 L79.3 68.8 L79.5 69.8 L79.1 70.2 L76.7 70.7 L76.7 71.9 L74.1 72.1 L73.8 73.3 L71.4 73.3 L71.0 73.8 L71.0 74.8 L69.1 75.0 L69.1 75.5 L69.8 75.7 L69.3 76.4 L66.2 76.7 L66.0 77.6 L66.7 77.9 L66.2 78.3 L62.2 79.5 L61.9 80.7 L59.1 81.7 L59.1 82.9 L58.6 83.3 L56.2 84.3 L56.2 85.2 L53.1 87.1 L53.4 88.3 L49.5 92.1 L49.3 93.6 L47.2 96.7 L47.2 98.1 L46.0 101.4 L46.5 102.4 L46.0 104.3 L46.0 108.3 L46.5 110.7 L47.9 114.0 L49.1 115.7 L53.6 119.3 L54.5 119.3 L54.5 118.6 L52.6 116.4 L50.7 113.3 L49.8 110.7 L50.0 109.3 L50.7 110.0 L51.7 110.0 L49.5 104.0 L49.8 100.9 L51.7 96.2 L54.5 92.4 L61.2 86.2 L67.9 82.4 L76.7 78.8 L77.4 79.0 L76.7 80.7 L75.3 82.4 L74.8 83.6 L73.6 84.3 L73.6 85.2 L74.3 85.7 L76.4 85.7 L77.2 85.2 L84.1 77.1 L84.5 77.4 L85.7 79.8 L87.6 79.8 L89.3 78.8 L92.6 74.8 L92.9 77.6 L95.7 81.7 L96.2 83.8 L96.7 84.0 L96.7 85.2 L97.9 86.9 L99.5 87.6 L100.5 87.4 L101.2 86.7 L101.4 84.5 L100.2 82.4 L100.5 81.7 L103.3 82.4 L103.8 82.9 L104.0 84.8 L102.4 87.4 L102.4 88.8 L101.9 89.3 L102.1 90.5 L104.3 90.5 L106.2 89.3 L106.9 87.6 L108.3 79.8 L108.8 79.3 L110.7 79.5 L114.0 81.2 L117.1 84.0 L116.9 84.5 L115.9 84.3 L115.7 85.2 L118.1 86.7 L117.6 87.4 L117.1 87.4 L117.4 88.1 L119.8 88.8 L122.1 90.2 L126.2 94.0 L127.1 94.0 L126.7 92.4 L127.4 92.1 L130.7 95.7 L131.2 95.7 L132.4 94.3 L132.4 91.9 L131.4 90.5 L130.9 87.6 L130.2 86.2 L129.5 85.9 L128.3 84.5 L127.1 81.2 L125.5 79.3 L123.8 76.0 L122.8 75.7 L123.3 78.1 L122.8 78.3 L119.8 71.9 L119.0 71.9 L119.0 73.1 L119.8 74.8 L119.5 75.2 L115.9 69.5 L115.2 69.5 L115.2 70.7 L115.7 71.4 L115.2 71.7 L111.4 66.9 L110.5 66.9 L110.0 66.2 L111.2 63.1 L114.0 59.8 L116.7 58.3 L127.4 54.3 L130.7 54.3 L137.6 56.4 L140.0 58.3 L140.7 58.3 L141.4 56.9 L143.3 56.4 L158.3 56.2 L162.1 57.6 L164.3 59.5 L164.7 59.5 L165.0 58.8 L164.3 57.4 L162.1 55.3 L159.5 53.6 L158.3 52.4 L158.1 51.2 L159.0 50.0 L160.7 49.3 L168.5 48.1 L178.1 47.9 L182.1 48.3 L189.0 50.5 L190.9 51.4 L193.0 53.3 L193.8 53.3 Z",
"lines": "M47.6 99.5 L47.2 99.5 L46.7 101.7 L47.4 101.4 Z M49.3 95.2 L48.4 95.7 L47.6 97.1 L47.6 97.8 L48.4 97.6 Z M51.5 91.7 L51.0 91.7 L50.0 92.6 L50.0 93.3 L50.5 93.3 L51.5 92.4 Z M125.5 90.5 L125.7 91.7 L127.4 91.7 L127.4 91.2 L126.7 90.7 Z M6.7 90.5 L6.2 90.5 L6.0 90.9 L6.0 93.8 L6.5 93.8 L6.7 93.1 L6.5 92.4 Z M55.5 86.9 L54.5 86.9 L53.8 88.6 L55.0 88.1 Z M118.6 86.4 L118.6 87.6 L119.8 87.6 L119.8 86.9 L119.3 86.4 Z M58.1 84.3 L57.6 84.3 L56.7 85.2 L56.7 85.7 L57.4 85.7 L58.1 85.0 Z M117.6 83.8 L117.8 84.8 L117.4 85.0 L117.4 85.5 L119.0 85.7 L119.0 85.0 L118.1 83.8 Z M61.4 81.7 L59.5 82.1 L59.5 83.3 L61.2 82.6 Z M64.8 79.5 L64.1 79.5 L62.6 80.5 L62.6 81.2 L64.3 80.5 Z M122.6 78.8 L122.6 79.5 L124.3 81.4 L125.0 81.4 L124.3 78.8 L123.3 79.0 Z M97.6 77.9 L97.6 78.8 L99.3 82.4 L99.8 82.4 L99.8 81.4 L100.5 81.2 L100.5 80.7 L99.0 79.8 L98.8 79.3 L99.0 78.8 L102.1 80.0 L104.5 80.0 L107.1 79.5 L108.1 79.0 L108.1 78.6 L106.9 78.6 L103.1 79.3 L100.2 78.6 L100.0 78.3 L100.2 77.6 Z M119.0 75.7 L119.0 76.4 L120.0 77.6 L120.7 77.6 L120.5 75.7 Z M81.9 74.3 L81.2 74.3 L78.8 76.9 L77.2 77.9 L77.2 78.3 L77.6 78.3 L77.9 79.0 L79.3 78.3 L81.9 74.8 Z M95.2 73.8 L93.3 74.8 L93.3 76.0 L93.8 76.0 L95.2 74.5 Z M74.1 74.3 L71.9 73.8 L71.9 74.3 L72.4 74.5 L71.7 74.8 L71.4 75.7 L70.3 75.5 L70.3 76.7 L71.2 76.4 L71.7 75.5 L72.9 75.5 L73.8 75.0 Z M74.5 72.6 L74.5 73.8 L75.7 73.8 L76.4 73.3 L76.2 72.6 Z M115.0 72.1 L115.0 72.6 L116.7 74.3 L117.1 74.3 L116.7 72.1 Z M77.4 72.4 L79.1 71.7 L79.1 71.2 L77.6 71.0 Z M80.0 70.5 L81.4 69.8 L81.2 69.1 L81.4 68.8 L83.6 68.8 L83.6 68.3 L80.5 67.6 Z M110.2 67.4 L110.7 69.3 L111.9 70.5 L113.1 71.0 L112.6 69.3 L111.7 68.6 L111.7 68.1 L110.9 67.4 Z M105.2 65.0 L105.2 65.7 L106.2 66.2 L107.9 68.1 L109.8 69.1 L109.8 68.3 L108.8 66.9 L109.5 66.7 L109.5 66.0 L109.0 66.0 L108.8 66.9 L107.6 66.4 L106.7 65.5 Z M65.0 63.3 L62.4 63.3 L55.5 64.5 L46.7 67.6 L46.5 68.3 L55.0 65.5 L60.7 64.3 L65.0 63.8 Z M93.3 60.2 L93.3 60.7 L94.3 61.4 L95.0 61.4 L95.2 61.0 L96.9 62.9 L100.2 64.8 L101.2 64.8 L101.4 64.3 L102.1 65.0 L102.9 65.0 L102.9 64.3 L101.4 62.9 L100.0 62.2 L99.5 62.2 L99.3 63.1 L97.1 61.2 L96.7 60.0 Z M79.5 58.6 L79.5 60.0 L80.5 60.0 L80.7 59.3 L80.0 58.6 Z M89.3 58.8 L89.3 59.3 L90.5 60.0 L91.4 60.0 L90.7 58.3 L90.2 58.3 L90.0 58.8 Z M81.2 58.6 L81.4 59.3 L82.9 59.5 L82.9 58.8 L82.4 58.3 Z M86.4 58.3 L86.7 59.1 L88.3 59.3 L87.9 58.1 L86.9 57.9 Z M83.8 57.4 L84.1 58.1 L83.3 58.3 L83.3 58.8 L85.5 59.3 L85.5 58.6 L84.3 57.4 Z M159.0 40.7 L159.0 41.4 L166.2 41.2 L166.2 40.7 L165.4 40.5 Z"
}
};
const POSES = Object.fromEntries(Object.entries(TRACED).map(([k, p]) => [k, () => ({ d: [p.body], lines: p.lines, eye: [0, 0], eyeR: 0 })]));
const cache = {};
/** SVG markup for one dragon: <g> with the silhouette in `fill`, its interior lines in `ink` (lineOpacity; lines:
* false leaves them out) and, with `outline`, a hairline of that colour round the edge that stays 1px at any size.
* `dark: true` draws it like the reference sheet: a near-black body with light lines and outline. */
function svg(pose, { fill = "#2a2230", eyeFill = "#f6e6c4", flip = false, lines = true, ink = "#1b0811", lineOpacity = 0.38,
outline = null, outlineWidth = 1, outlineOpacity = 0.7, dark = false } = {}) {
if (!cache[pose]) cache[pose] = POSES[pose]();
const p = cache[pose];
if (dark) {
fill = "#16111b"; ink = "#e9e0f5"; lineOpacity = 0.6; outline = outline || "#d9cdee"; outlineOpacity = 0.85;
}
const tf = flip ? ' transform="translate(200 0) scale(-1 1)"' : "";
const edge = outline ? ` stroke="${outline}" stroke-opacity="${outlineOpacity}" stroke-width="${outlineWidth}" stroke-linejoin="round" vector-effect="non-scaling-stroke"` : "";
const body = `<g fill="${fill}" fill-rule="evenodd"${edge}>${p.d.map((d) => `<path d="${d}"/>`).join("")}</g>`;
const inner = lines && p.lines ? `<path d="${p.lines}" fill="${ink}" fill-opacity="${lineOpacity}" stroke="none"/>` : "";
const eye = p.eyeR ? `<circle cx="${f(p.eye[0])}" cy="${f(p.eye[1])}" r="${p.eyeR}" fill="${eyeFill}"/>` : "";
return `<g${tf}>${body}${inner}${eye}</g>`;
}
/* ---------- cadets and the thorn bush (same building blocks, 100 x 140 box, feet near y = 132) ---------- */
const line = (a, b, r0, r1 = r0) => tube([a, [lerp(a[0], b[0], 0.33), lerp(a[1], b[1], 0.33)], [lerp(a[0], b[0], 0.66), lerp(a[1], b[1], 0.66)], b], r0, r1, 8);
/** A cadet from joint positions; `cloak` adds a short flying cape, weapons are drawn from the hands. */
function cadet(j, { cloak = true, sword = null, dagger = null, size = 1 } = {}) {
const d = [];
if (cloak) d.push(poly([j.neck, [j.neck[0] - 4, j.neck[1] + 2], [j.hip[0] - 14 * (j.face || 1), j.hip[1] + 16], [j.hip[0] - 2 * (j.face || 1), j.hip[1] + 8], [j.neck[0] + 3, j.neck[1] + 4]]));
d.push(line(j.neck, j.hip, 7.5 * size, 6.5 * size)); // torso
d.push(line(j.hip, j.lKnee, 4.6 * size, 4 * size), line(j.lKnee, j.lFoot, 3.8 * size, 3 * size));
d.push(line(j.hip, j.rKnee, 4.6 * size, 4 * size), line(j.rKnee, j.rFoot, 3.8 * size, 3 * size));
d.push(poly([[j.lFoot[0] - 3, j.lFoot[1] - 2], [j.lFoot[0] + 7 * (j.face || 1), j.lFoot[1] - 1], [j.lFoot[0] + 7 * (j.face || 1), j.lFoot[1] + 2], [j.lFoot[0] - 3, j.lFoot[1] + 2]]));
d.push(poly([[j.rFoot[0] - 3, j.rFoot[1] - 2], [j.rFoot[0] + 7 * (j.face || 1), j.rFoot[1] - 1], [j.rFoot[0] + 7 * (j.face || 1), j.rFoot[1] + 2], [j.rFoot[0] - 3, j.rFoot[1] + 2]]));
const sh = [j.neck[0], j.neck[1] + 3];
d.push(line(sh, j.lElbow, 3.4 * size, 3), line(j.lElbow, j.lHand, 3, 2.4));
d.push(line(sh, j.rElbow, 3.4 * size, 3), line(j.rElbow, j.rHand, 3, 2.4));
d.push(ell(j.head[0], j.head[1], 7.2 * size, 8 * size, 0)); // head
d.push(ell(j.head[0] - 2 * (j.face || 1), j.head[1] - 3, 7 * size, 5 * size, 0)); // hair
d.push(line([(j.neck[0] + j.head[0]) / 2, (j.neck[1] + j.head[1]) / 2 + 2], j.neck, 3.2, 3.6)); // neck
const blade = (hand, ang, len, w) => {
const tip = [hand[0] + Math.cos(ang) * len, hand[1] + Math.sin(ang) * len];
const nx = -Math.sin(ang), ny = Math.cos(ang);
return [poly([[hand[0] + nx * w, hand[1] + ny * w], [tip[0] + nx * w * 0.4, tip[1] + ny * w * 0.4], [tip[0] + Math.cos(ang) * 4, tip[1] + Math.sin(ang) * 4], [tip[0] - nx * w * 0.4, tip[1] - ny * w * 0.4], [hand[0] - nx * w, hand[1] - ny * w]]),
line([hand[0] + nx * 6, hand[1] + ny * 6], [hand[0] - nx * 6, hand[1] - ny * 6], 1.4)];
};
if (sword) d.push(...blade(j[sword.hand], sword.ang, sword.len || 44, 1.9));
if (dagger) d.push(...blade(j[dagger.hand], dagger.ang, dagger.len || 16, 1.6));
return d;
}
const FIGURES = {
// your squadmate, braced, sword raised high
defender: () => cadet({ face: 1, head: [42, 30], neck: [44, 42], hip: [46, 84], lKnee: [36, 106], lFoot: [28, 130], rKnee: [58, 104], rFoot: [64, 130],
lElbow: [56, 50], lHand: [62, 34], rElbow: [56, 56], rHand: [62, 38] }, { sword: { hand: "lHand", ang: -1.15, len: 46 } }),
// the bigger bully, lunging with a sword
lunging: () => cadet({ face: -1, head: [56, 34], neck: [54, 46], hip: [58, 86], lKnee: [42, 104], lFoot: [30, 130], rKnee: [70, 108], rFoot: [82, 130],
lElbow: [40, 56], lHand: [26, 60], rElbow: [44, 60], rHand: [30, 64] }, { sword: { hand: "lHand", ang: Math.PI + 0.12, len: 42 }, size: 1.12 }),
// the smaller bully, dagger raised to throw
throwing: () => cadet({ face: -1, head: [50, 46], neck: [50, 57], hip: [52, 92], lKnee: [42, 110], lFoot: [36, 130], rKnee: [62, 110], rFoot: [68, 130],
lElbow: [40, 66], lHand: [36, 80], rElbow: [64, 52], rHand: [70, 38] }, { dagger: { hand: "rHand", ang: -0.9 }, size: 0.88 }),
// the wounded cadet, lying on the ground, a belt tied above the knee
lying: () => {
const d = cadet({ face: 1, head: [16, 118], neck: [26, 120], hip: [62, 122], lKnee: [80, 116], lFoot: [96, 126], rKnee: [80, 126], rFoot: [84, 128],
lElbow: [34, 108], lHand: [40, 96], rElbow: [38, 128], rHand: [52, 130] }, { cloak: false });
d.push(poly([[2, 132], [98, 132], [96, 136], [4, 136]])); // the ground line
return d;
},
// a thorn bush: arching branches with thorns and a few leaves
thorns: () => {
const d = [], R = (() => { let s = 7; return () => ((s = (s * 1103515245 + 12345) % 2147483648) / 2147483648); })();
// a low mound of leaves, then arching thorny canes
[[22, 128, 18, 9], [50, 124, 24, 12], [78, 128, 18, 9], [36, 118, 14, 8], [64, 118, 14, 8]].forEach(([x, y, rx, ry]) => d.push(ell(x, y, rx, ry, 0)));
for (let k = 0; k < 11; k++) {
const a = Math.PI * (0.08 + 0.84 * (k / 10)) + (R() - 0.5) * 0.2, len = 50 + R() * 34;
const sx = 50 + (R() - 0.5) * 24, sy = 124;
const ex = sx - Math.cos(a) * len, ey = sy - Math.sin(a) * len * 0.95;
const b = [[sx, sy], [sx - Math.cos(a) * len * 0.35, sy - Math.sin(a) * len * 0.75], [ex + Math.cos(a) * 6, ey - 10], [ex, ey + 4]];
d.push(tube(b, 2.6, 0.8, 18));
bez(b, 12).slice(2, -1).forEach((p, i) => {
const side = i % 2 ? 1 : -1, l = 3.5 + R() * 3;
d.push(poly([[p[0] - 1.2, p[1]], [p[0] + side * l, p[1] - l * 0.7], [p[0] + 1.2, p[1]]]));
if (i % 3 === 1) d.push(ell(p[0] - side * 5, p[1] - 1, 4.2, 2.2, side * 0.6));
});
}
return d;
},
};
const fcache = {};
/** SVG markup for a figure (cadets, the thorn bush) in one ink colour. */
function figure(name, { fill = "#3b2416", flip = false } = {}) {
if (!fcache[name]) fcache[name] = FIGURES[name]();
const tf = flip ? ' transform="translate(100 0) scale(-1 1)"' : "";
return `<g${tf}><g fill="${fill}">${fcache[name].map((d) => `<path d="${d}"/>`).join("")}</g></g>`;
}
return { svg, figure, poses: Object.keys(POSES), figures: Object.keys(FIGURES) };
});
+22
View File
@@ -0,0 +1,22 @@
# Where the Atlas's repository is hosted. Everything that talks to the host reads this file: the daily workflow
# (opening its pull request and issues), the "Report a run" collector, the links on the page and in the dataset
# metadata (data/croissant.json). Moving hosts is an edit here (then `python -m collection build`).
#
# kind: gitea or github. The Gitea workflows live in .gitea/workflows/ (Gitea ignores .github/workflows/ when that
# folder exists); the GitHub ones, including GitHub Pages, stay in .github/workflows/ for when GitHub is used again.
version: 1
kind: gitea
url: https://git.kenschiano.net
repo: YOUR-GITEA-USERNAME/threshing-atlas # owner/name on the server (set your username here)
branch: main
# public, limited (only people signed in to this server) or private: who can open the links below
visibility: limited
# the published page, when it is hosted somewhere (GitHub Pages is paused while the GitHub account is suspended;
# the page is viewed locally or as a Claude artifact meanwhile)
site: null
# other copies of the repository (informational)
mirrors:
github: https://github.com/ekcSchiano/threshing-atlas # suspended; GitHub Pages workflow kept for later
+21
View File
@@ -0,0 +1,21 @@
{
"name": "threshing-atlas",
"private": true,
"description": "Route probabilities and path-finding for the Dragonkind threshing",
"license": "MIT",
"scripts": {
"build": "node site/build.js",
"dev": "node site/build.js && python3 -m http.server 8000 -d dist",
"test:py": "python3 -m collection build --check && PYTHONPATH=core python3 -m unittest discover -s tests/core -p 'test_*.py' && python3 -m unittest discover -s tests/collection -p 'test_*.py'",
"test:unit": "node --test tests/core/graph.test.js tests/core/advisor.test.js",
"test": "npm run test:py && npm run test:unit",
"graph": "node analysis/network/build-graph.js",
"policy": "python3 planner/build_policy.py && python3 planner/policy_report.py",
"stats": "python3 analysis/stats/site_stats.py",
"collect": "python3 -m collection update",
"build-data": "python3 -m collection build"
},
"engines": {
"node": ">=18"
}
}
+15
View File
@@ -0,0 +1,15 @@
# planner
The route planner: the best route to every dragon, and what goes back to Ken's bot.
| File | What it does |
|---|---|
| `build_policy.py` | Solves the route model (`core/atlas/solver.py`, built from the game in `core/spec/game.yaml`) for every colour and both goals ("this attempt" and "eventually"), with 200 posterior draws and a cross-fit check. Writes `data/public/policy.json`, which has a content id so each bot run can record which policy it followed. About 2 minutes. |
| `policy_report.py` | Writes the readable version, `analysis/reports/POLICY.md`. |
Run both with `npm run policy`. The site's valley map and The Odds read `policy.json`; the bot downloads it with
`solver.js` and `graph.js` (see `docs/BOT_INTEGRATION.md`).
**The loop with the bot.** The planner's routes go out to the bot; the bot's runs come back through
`collection/bot/`. Experiments the bot should run to fill gaps the community form cannot (for example the
answers at each bonding encounter) belong here; `experiments.json` is on the roadmap.
+90
View File
@@ -0,0 +1,90 @@
"""Build data/public/policy.json: the best decisions for every dragon colour, under both objectives.
python planner/build_policy.py [--draws 200] [--out data/public/policy.json]
Two samples, from the runs and rules in planner/policy.yaml: every run, and a low-bias sample (bot runs, bulk logs,
and riders not chasing a rare dragon).
The output has a content id, so each bot run can record which policy it followed.
"""
import argparse
import hashlib
import json
import math
import sys
import time
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(ROOT / "core"))
from atlas import model, solver # noqa: E402
from atlas import runs as runs_io # noqa: E402
import yaml # noqa: E402
# which runs the model learns from, and the low-bias sample (planner/policy.yaml)
with open(ROOT / "planner/policy.yaml", encoding="utf-8") as _f:
CONFIG = yaml.safe_load(_f)
SOURCES = CONFIG["sources"]
def low_bias(r, lb=CONFIG["low_bias"]):
"""Kept in the low-bias sample: every run of an always-kept source, bulk logs, and riders not chasing a rare dragon."""
if r["source"] in lb["always"]:
return True
if r["source"] == "reddit spreadsheet" and "bulk" in lb["entries_kept"] and r["entry"] not in (None, "Form"):
return True
return r["goal"] not in lb["rare_goals"]
def clean(o):
"""JSON-safe: numpy numbers to floats, infinities and NaN to null (as JavaScript's JSON.stringify does)."""
if isinstance(o, dict):
return {str(k): clean(v) for k, v in o.items()}
if isinstance(o, (list, tuple)):
return [clean(v) for v in o]
if hasattr(o, "item"):
o = o.item()
if isinstance(o, float) and (math.isinf(o) or math.isnan(o)):
return None
return o
def main(argv=None):
ap = argparse.ArgumentParser(description=__doc__)
ap.add_argument("--draws", type=int, default=200)
ap.add_argument("--data", default=str(runs_io.PATH))
ap.add_argument("--out", default=str(ROOT / "data/public/policy.json"))
a = ap.parse_args(argv)
runs = runs_io.read(a.data, sources=SOURCES)
rows = len(runs)
samples = {
"all": runs,
"lowBias": [r for r in runs if low_bias(r)],
}
t0 = time.time()
by_source = {}
for r in runs:
by_source[r["source"]] = by_source.get(r["source"], 0) + 1
out = {"schema": 1, "source": {"form_rows": by_source.get("reddit spreadsheet", 0), "runs": rows, "by_source": by_source},
"samples": {}}
for name, rs in samples.items():
out["samples"][name] = clean(solver.build_policy(rs, draws=a.draws, bias_config=CONFIG.get("reporting_bias")))
print(f"{name}: {len(rs)} runs, {time.time() - t0:.1f} s")
# a content id (no timestamps: the build is reproducible)
out["id"] = hashlib.sha1(json.dumps(out["samples"], separators=(",", ":"), sort_keys=True).encode()).hexdigest()[:12]
Path(a.out).write_text(json.dumps(out, separators=(",", ":")), encoding="utf-8")
print("policy id", out["id"])
pct = lambda p: "–" if p is None else f"{100 * p:.{2 if p < 0.01 else 1}f}%" # noqa: E731
for name, s in out["samples"].items():
print(f"\n{name} alphas {json.dumps(s['model']['alphas'])}")
for X, t in s["targets"].items():
x, e = t["thisAttempt"], t["eventually"]
att = e["expectedAttempts"]["mean"]
print(f" {X:<6} this attempt {pct(x['pX']['mean'])} [{pct(x['pX']['lo'])}, {pct(x['pX']['hi'])}] other bond {pct(x['pOther']['mean'])}"
f" | eventually: ratio {pct(e['ratio']['mean'])}, P(X) {pct(e['pX']['mean'])}, ~{'–' if att is None else round(att)} attempts"
f" | cross-fit {pct(t['crossFit']['inSample'])} -> held-out {pct(t['crossFit']['heldOut'])}")
if __name__ == "__main__":
main()
+34
View File
@@ -0,0 +1,34 @@
# Which runs the route model (data/public/policy.json) learns from. planner/build_policy.py reads this file.
#
# The model estimates the game's rolls (first dragon, deaths, shadow, meadow dragon, bond chances) given the choices
# made before them, so any run that records its choices and what happened can teach it, whoever chose the route.
# Deliberate deaths (Malek, the bot's "no shadow" / "no Blue" burns) are never counted as failed bond attempts.
version: 1
# the `source` values of data/public/runs_clean.csv the model learns from
sources: [reddit spreadsheet, reported, bot]
# 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
# run, and bulk-pasted logs record every run of the players who kept them, so both stay in.
low_bias:
always: [bot] # sources whose every run is kept
entries_kept: [bulk] # spreadsheet rows whose `entry` is not "Form" (bulk-pasted logs)
rare_goals: [Blue, Black, Blue or Black]
# Reporting bias (core/atlas/bias.py). A rider is more likely to write up a run with a shadow or a meadow Blue than
# one without, so those sightings are over-represented in form submissions. For each rare roll below and each group
# that is not complete, the model estimates how many times more often the group reports the rare outcome than the
# complete groups do (rho, with a 90% range), and counts each rare outcome it reports as 1/rho. The group's pattern
# across routes is kept; its overall level comes from complete logging. Assumes the bias is the same on every route.
reporting_bias:
rolls: { shadow: "yes", meadow: Blue } # roll: its rare outcome
min_runs: 30 # fewer runs than this in a group (or the complete groups): borrow
min_complete_rare: 5 # fewer rare outcomes than this in complete logs: the bias cannot be
# estimated, so the roll is learned from complete logs only
groups: # first match wins
- { name: bot, when: { source: bot }, complete: true }
- { name: bulk logs, when: { source: reddit spreadsheet, entry_not: Form }, complete: true }
- { name: "form, chasing Blue/Black", when: { source: reddit spreadsheet, goal: rare } }
- { name: "form, other", when: { source: reddit spreadsheet } }
- { name: reported, when: { source: reported }, same_as: "form, other" }
+93
View File
@@ -0,0 +1,93 @@
"""Write analysis/reports/POLICY.md: a readable summary of data/public/policy.json.
python planner/policy_report.py
"""
import json
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
def js_round(x):
"""Math.round: halves round up (toward +infinity), unlike Python's round()."""
import math
return math.floor(x + 0.5)
def to_fixed(x, digits):
"""Number.prototype.toFixed: round half away from zero on the decimal value."""
from decimal import Decimal, ROUND_HALF_UP
return str(Decimal(repr(x)).quantize(Decimal(1).scaleb(-digits), rounding=ROUND_HALF_UP))
def pct(p):
return "–" if p is None else to_fixed(100 * p, 1 if p < 0.1 else 0) + "%"
def conf(n):
return "" if n.get("stillBest") is None else f" (still best in {pct(n['stillBest'])} of posterior draws)"
def walk(n, out, indent=""):
if not n:
return
if n["type"] == "decision":
alts = ", ".join(f"{k} {pct(v['pX'])}" for k, v in sorted(n["options"].items(), key=lambda kv: -kv[1]["pX"]))
if n["tie"]:
out.append(f"{indent}- {n['label']}: any (no difference for this colour)")
else:
weak = " — no clear winner" if n.get("stillBest") is not None and n["stillBest"] < 0.75 else ""
out.append(f"{indent}- **{n['label']}: {n['choice']}**{conf(n)}{weak}. If chosen, then best play after: {alts}")
walk(n["next"], out, indent)
elif n["type"] == "chance":
br = sorted(n["branches"].items(), key=lambda kv: -kv[1]["p"])
live = [(k, b) for k, b in br if k != "die"]
die = next((b for k, b in br if k == "die"), None)
if die is not None:
out.append(f"{indent}- {n['label']}: {pct(1 - die['p'])} survive")
for _, b in live:
walk(b["next"], out, indent)
return
if len(live) == 1:
return walk(live[0][1]["next"], out, indent)
out.append(f"{indent}- {n['label']}: " + ", ".join(f"{k} {pct(b['p'])}" for k, b in br))
for k, b in br:
out.append(f"{indent} - if **{k}**:")
walk(b["next"], out, indent + " ")
elif n.get("outcomes"):
items = sorted(n["outcomes"].items(), key=lambda kv: -kv[1])
out.append(f"{indent}- Outcome if you attempt: " + ", ".join(f"{'incinerated' if k == 'burn' else 'bond ' + k} {pct(p)}" for k, p in items))
else:
out.append(f"{indent}- {n['what']}")
def main():
P = json.load(open(ROOT / "data/public/policy.json", encoding="utf-8"))
s, lb = P["samples"]["all"], P["samples"]["lowBias"]
L = ["# Best routes by dragon colour", ""]
L += [f"Generated from {s['data']['runs']} community runs by `planner/build_policy.py` from the game in `core/spec/game.yaml`. Machine-readable version: `data/public/policy.json`.", ""]
L += ["**How to read this.** \"This attempt\" maximises the chance of bonding the colour on one run. \"Eventually\" assumes you will die on purpose and try again whenever the run goes wrong, so it avoids any choice that can end the account on a different dragon. Percentages are posterior means with 95% credible intervals. \"Held-out\" is the same policy chosen on half of the runs and scored on the other half: when it is much lower than the in-sample number, the route's advantage is mostly noise.", ""]
L += ["**Caveats.** The form records choices only at the level of company, direction, first dragon, cadet encounter, fork, tree or valley, and which dragon you met. Choices inside each encounter are not recorded, so the bond chance at an encounter is the community's average with whatever answers people used. Riders chasing a rare dragon report sightings more often than riders who log every run; the \"low-bias\" columns use only bulk logs and non-chasers.", ""]
L += ["| Colour | This attempt | Low-bias sample | Held-out | Eventually: chance the account ends on this colour | Attempts needed (about) |",
"|---|---|---|---|---|---|"]
for X, t in s["targets"].items():
a, e, l = t["thisAttempt"], t["eventually"], lb["targets"][X]["thisAttempt"]
att = e["expectedAttempts"]["mean"]
L.append(f"| {X} | {pct(a['pX']['mean'])} ({pct(a['pX']['lo'])}–{pct(a['pX']['hi'])}) | {pct(l['pX']['mean'])} ({pct(l['pX']['lo'])}–{pct(l['pX']['hi'])}) | {pct(t['crossFit']['heldOut'])} | {pct(e['ratio']['mean'])} | {'–' if att is None else js_round(att)} |")
L += ["", "## How much do earlier choices matter?", ""]
L += ["Each chance event can depend on the choices before it. The model learns how much from the data (empirical-Bayes concentration; larger means the history matters less):", ""]
L += ["| Chance event | Depends on (most important first) | Concentration |", "|---|---|---|"]
for k, ctx in s["model"]["chanceContext"].items():
L.append(f"| {k} | {', '.join(ctx) or 'nothing'} | {s['model']['alphas'][k]} |")
for X in s["targets"]:
for obj, title in (("thisAttempt", "this attempt"), ("eventually", "eventually")):
out = []
walk(s["targets"][X][obj]["tree"], out)
L += ["", f"## {X}: {title}", "", *out]
path = ROOT / "analysis/reports/POLICY.md"
path.write_text("\n".join(L) + "\n", encoding="utf-8")
print(f"wrote {path.relative_to(ROOT)} {len(L)} lines")
if __name__ == "__main__":
main()
+25
View File
@@ -0,0 +1,25 @@
[build-system]
requires = ["setuptools>=61"]
build-backend = "setuptools.build_meta"
[project]
name = "threshing-atlas"
version = "0.2.0"
description = "Route probabilities and path finding for the Dragonkind threshing"
license = { text = "MIT" }
requires-python = ">=3.10"
dependencies = ["pandas>=2.0", "numpy>=1.24", "scipy>=1.10", "openpyxl>=3.1", "pypdf>=4.0", "pyyaml>=6.0"]
[project.optional-dependencies]
dev = ["pytest>=7", "scikit-image>=0.20"]
[tool.setuptools]
package-dir = { "" = "core" }
packages = ["atlas"]
[tool.setuptools.package-data]
atlas = []
[tool.pytest.ini_options]
testpaths = ["tests"]
pythonpath = ["core"]
+8
View File
@@ -0,0 +1,8 @@
pandas>=2.0
numpy>=1.24
scipy>=1.10
openpyxl>=3.1
pypdf>=4.0
scikit-image>=0.20
pyyaml>=6.0
pytest>=7
+4 -14
View File
@@ -84,7 +84,6 @@
// ------------------------------------------------------------ data loading
async function loadStats() {
state.stats = await (await fetch("data/stats.json")).json();
try { state.overlap = await (await fetch("data/overlap.json")).json(); } catch { state.overlap = null; }
const sel = $("#f-preset");
sel.innerHTML = Object.entries(META().presets).map(([k, l]) => `<option value="${k}">${esc(l)}</option>`).join("");
sel.value = state.preset;
@@ -272,15 +271,7 @@
const chance = s.chance;
const t = svgEl("text", { x: colX(i), y: 18, class: "stage-label" + (chance ? " stage-chance" : "") }, svg);
t.textContent = s.label;
if (chance) {
const r = svgEl("text", { x: colX(i), y: 31, class: "stage-label stage-chance" }, svg);
r.textContent = "game roll";
const here = G.nodes.filter((n) => n.stage === i), tot = here.reduce((a, n) => a + n.n, 0) || 1;
const w = r.getComputedTextLength ? r.getComputedTextLength() : 70; // the headings are left-aligned
Dice.svg(svg, colX(i) + w + 15, 27, { title: `${s.label}: the game's roll`, n: tot,
options: here.map((n) => [n.value, n.n / tot]),
note: "Share of riders who reached this step, in the runs shown. The game decides it; earlier choices can shift the odds." });
}
if (chance) { const r = svgEl("text", { x: colX(i), y: 31, class: "stage-label stage-chance" }, svg); r.textContent = "game roll"; }
});
// links
@@ -350,7 +341,7 @@
<span>${state.widthMode === "traffic" ? "Band width = number of runs" : "Line width = chance of the outcome"}</span>
<span style="display:inline-flex;gap:6px;align-items:center">0% <span class="ramp" style="background:linear-gradient(90deg, ${low}, ${tcol})"></span> ${pct(pmax, 0)}</span>
<span>Grey = fewer than ${state.minN} runs</span>
<span>${Dice.legend('and <span style="color:var(--accent)">gold headings</span> = steps the game rolls at random, not your choice. Click the dice for the odds of each outcome.')}</span>`;
<span><span style="color:var(--accent)">Gold headings</span> = steps the game rolls, not you</span>`;
}
function renderBestRoutes() {
@@ -563,8 +554,7 @@
</tbody></table></div><p class="small">Bulk logs come from players who recorded every run, so they are the least selective rows. Their rare-dragon rates are several times lower than the form's, which is the strongest sign of reporting bias in this data.</p></div>
<div class="panel"><h3>Rows flagged for contradictions</h3><p class="small muted">${m.n_flagged} of ${r.n} rows (${pct(m.n_flagged / r.n)}). Flagged rows stay in unless you pick "Rows without data-quality flags" above.</p><div class="tbl-wrap"><table><tbody>${flags.map(([f, n]) => `<tr><td>${esc(f)}</td><td class="num">${n}</td></tr>`).join("") || `<tr><td>None</td></tr>`}</tbody></table></div></div>
<div class="panel"><h3>How runs ended</h3><div class="tbl-wrap"><table><tbody>${outs.map(([f, n]) => `<tr><td>${esc(f)}</td><td class="num">${n}</td><td class="num">${pct(n / r.n)}</td></tr>`).join("")}</tbody></table></div><p class="small muted">"No outcome recorded" rows reached the hour but the form shows no Bonded or Incinerated. They count toward reaching a branch but not toward bond rates.</p></div>
${state.overlap && state.overlap.comparable ? `<div class="panel"><h3>The same run reported twice?</h3><p class="small">A rider may log a run in the form and post it in a megathread comment too. With no player IDs, a copy can only be measured, not proven, so nothing is removed. Of ${state.overlap.comparable} Reddit runs detailed enough to compare, ${state.overlap.matched} give the same answers as a form row sent within ${state.overlap.rule.window_days} day; chance alone (the same test a few weeks off) gives about ${state.overlap.expected_by_chance}. So about ${Math.round(state.overlap.likely_double)} of ${state.overlap.comment_runs} Reddit runs look reported twice${state.overlap.likely_double < 0.1 * state.overlap.comment_runs ? ", too few to matter" : ""}.</p></div>` : ""}
<div class="panel"><h3>Independence</h3><p class="small">The form has no player ID. One player's 50 runs count as 50 independent runs, so intervals are somewhat narrower than they should be. ${pct(Object.entries(m.sources).filter(([k]) => !["Form", "Reddit comments", "DragonKind bot", "Reported on the Atlas"].includes(k)).reduce((s, [, n]) => s + n, 0) / r.n, 0)} of rows arrived as bulk imports, each probably one player's or one group's log.</p></div>
<div class="panel"><h3>Independence</h3><p class="small">The form has no player ID. One player's 50 runs count as 50 independent runs, so intervals are somewhat narrower than they should be. ${pct((r.n - (m.sources["Form"] || 0)) / r.n, 0)} of rows arrived as bulk imports, each probably one player's or one group's log.</p></div>
<div class="panel"><h3>What the form does not ask</h3><p class="small">The redesigned form asks how you reacted to the first dragon (answered in ${r.factors.reach_hour.rows.filter((x) => x.factor === "sighting_action" && !["Unknown", "(not asked)"].includes(x.level)).reduce((a, x) => a + x.n, 0)} rows; most riders answer "Unsure") and how the bully fight went (${r.factors.reach_hour.rows.filter((x) => x.factor === "combat_first" && x.level !== "(not recorded)").reduce((a, x) => a + x.n, 0)} rows). It still does not record most choices inside the bonding encounters. Theories that rely on those choices cannot be confirmed or refuted here.</p></div>`;
}
const sourceRate = (outKey, source) => state.res.source_rates[outKey][source];
@@ -598,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 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.*`);
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.*`);
return L.join("\n");
}
$("#cp-reddit").addEventListener("click", () => copyText(redditPost(), "Reddit post"));
+308
View File
@@ -0,0 +1,308 @@
/* dragons.js — original dragon silhouettes for the valley map.
* Each pose is built from simple parts (tapered tubes, a scalloped wing membrane, a head with horns, spines,
* a spaded tail), so every dragon is drawn the same way but stands differently. Drawn facing right in a
* 200 x 160 box; flip with scale(-1, 1). Works in the browser (window.DragonArt) and in Node. */
(function (root, factory) {
if (typeof module === "object" && module.exports) module.exports = factory();
else root.DragonArt = factory();
})(typeof self !== "undefined" ? self : this, function () {
"use strict";
const f = (n) => Math.round(n * 10) / 10;
const lerp = (a, b, t) => a + (b - a) * t;
/** Points along a cubic Bezier given as [p0, c1, c2, p1] (each [x, y]). */
function bez(P, n = 28) {
const out = [];
for (let i = 0; i <= n; i++) {
const t = i / n, u = 1 - t;
out.push([
u * u * u * P[0][0] + 3 * u * u * t * P[1][0] + 3 * u * t * t * P[2][0] + t * t * t * P[3][0],
u * u * u * P[0][1] + 3 * u * u * t * P[1][1] + 3 * u * t * t * P[2][1] + t * t * t * P[3][1],
]);
}
return out;
}
/** A tube along a Bezier whose half-width goes from r0 to r1 (r can also be a function of t). */
function tube(P, r0, r1, n = 28) {
const pts = bez(P, n), L = [], R = [];
pts.forEach((p, i) => {
const a = pts[Math.max(0, i - 1)], b = pts[Math.min(pts.length - 1, i + 1)];
let dx = b[0] - a[0], dy = b[1] - a[1];
const len = Math.hypot(dx, dy) || 1;
dx /= len; dy /= len;
const t = i / n, r = typeof r0 === "function" ? r0(t) : lerp(r0, r1, t);
L.push([p[0] - dy * r, p[1] + dx * r]);
R.push([p[0] + dy * r, p[1] - dx * r]);
});
const ring = L.concat(R.reverse());
return "M" + ring.map((p) => `${f(p[0])} ${f(p[1])}`).join(" L") + " Z";
}
const poly = (pts) => "M" + pts.map((p) => `${f(p[0])} ${f(p[1])}`).join(" L") + " Z";
const ell = (cx, cy, rx, ry, rot = 0) => {
const pts = [];
for (let i = 0; i < 36; i++) {
const a = (i / 36) * Math.PI * 2, x = rx * Math.cos(a), y = ry * Math.sin(a), c = Math.cos(rot), s = Math.sin(rot);
pts.push([cx + x * c - y * s, cy + x * s + y * c]);
}
return poly(pts);
};
/**
* Wing membrane: a leading-edge bone shoulder -> wrist -> tip, finger tips along the trailing edge, and
* scalloped membrane between them, back to the root on the body.
*/
function wing({ shoulder, wrist, tip, fingers, root, bow = 0.28, bone = 4 }) {
const d = [tube([shoulder, [lerp(shoulder[0], wrist[0], 0.4), lerp(shoulder[1], wrist[1], 0.4) - 6], [lerp(shoulder[0], wrist[0], 0.8), lerp(shoulder[1], wrist[1], 0.8)], wrist], bone, bone * 0.8),
tube([wrist, [lerp(wrist[0], tip[0], 0.3), lerp(wrist[1], tip[1], 0.3)], [lerp(wrist[0], tip[0], 0.7), lerp(wrist[1], tip[1], 0.7)], tip], bone * 0.8, 0.8)];
const edge = [tip].concat(fingers, [root]);
let m = `M${f(shoulder[0])} ${f(shoulder[1])} L${f(wrist[0])} ${f(wrist[1])} L${f(tip[0])} ${f(tip[1])}`;
for (let i = 1; i < edge.length; i++) {
const a = edge[i - 1], b = edge[i];
// scallop: control point pulled toward the wrist
const mx = (a[0] + b[0]) / 2, my = (a[1] + b[1]) / 2;
const cx = lerp(mx, wrist[0], bow), cy = lerp(my, wrist[1], bow);
m += ` Q${f(cx)} ${f(cy)} ${f(b[0])} ${f(b[1])}`;
}
m += ` L${f(shoulder[0])} ${f(shoulder[1])} Z`;
d.push(m);
// finger bones from the wrist (thin, add texture at the edge)
fingers.forEach((p) => d.push(tube([wrist, [lerp(wrist[0], p[0], 0.33), lerp(wrist[1], p[1], 0.33)], [lerp(wrist[0], p[0], 0.66), lerp(wrist[1], p[1], 0.66)], p], 1.6, 0.6, 10)));
return d;
}
/** Head pointing along `ang` (radians, 0 = right) from the neck end, with horns and an open or closed jaw. */
function head({ at, ang = 0, size = 1, open = 0, horns = 2 }) {
const c = Math.cos(ang), s = Math.sin(ang);
const T = (x, y) => [at[0] + (x * c - y * s) * size, at[1] + (x * s + y * c) * size];
const d = [];
// skull and upper snout
d.push(poly([T(-8, 2), T(-6, -9), T(4, -12), T(14, -8), T(26, -5), T(31, -2), T(30, 1), T(18, 2 + open * 0.3), T(8, 6)]));
// jaw (drops when open)
d.push(poly([T(-6, 3), T(10, 4), T(28, 3 + open), T(26, 6 + open), T(12, 10 + open * 0.4), T(-4, 9)]));
// horns sweeping back
for (let i = 0; i < horns; i++) {
const y0 = -9 + i * 4, len = 18 - i * 6;
d.push(tube([T(2 - i * 3, y0), T(-6 - i * 2, y0 - 6), T(-14 - i * 3, y0 - 8 - i), T(-12 - len * 0.6 - i * 3, y0 - 14 + i * 3)], 2.6 * size - i * 0.4, 0.4, 10));
}
// brow spike and cheek frill
d.push(poly([T(-4, 4), T(-14, 8), T(-5, 8)]));
return { d, eye: T(8, -5), eyeR: 1.9 * size };
}
/** Small triangular spines along a list of points (pointing away from `side` normal). */
function spines(pts, size, side = -1, every = 2) {
const d = [];
for (let i = 1; i < pts.length - 1; i += every) {
const a = pts[i - 1], b = pts[i + 1], p = pts[i];
let dx = b[0] - a[0], dy = b[1] - a[1];
const len = Math.hypot(dx, dy) || 1;
dx /= len; dy /= len;
const nx = -dy * side, ny = dx * side, k = typeof size === "function" ? size(i / pts.length) : size;
d.push(poly([[p[0] - dx * k * 0.6, p[1] - dy * k * 0.6], [p[0] + nx * k * 1.5 - dx * k * 0.5, p[1] + ny * k * 1.5 - dy * k * 0.5], [p[0] + dx * k * 0.6, p[1] + dy * k * 0.6]]));
}
return d;
}
/** Tail as a tapering tube ending in a spade. */
function tail(P, r0) {
const d = [tube(P, (t) => Math.max(0.9, r0 * (1 - t) ** 1.1), null, 36)];
const pts = bez(P, 36), a = pts[pts.length - 3], b = pts[pts.length - 1];
let dx = b[0] - a[0], dy = b[1] - a[1];
const len = Math.hypot(dx, dy) || 1;
dx /= len; dy /= len;
const nx = -dy, ny = dx, k = Math.max(4, r0 * 0.9);
d.push(poly([[b[0] - dx * k * 0.6, b[1] - dy * k * 0.6], [b[0] + nx * k, b[1] + ny * k], [b[0] + dx * k * 1.6, b[1] + dy * k * 1.6], [b[0] - nx * k, b[1] - ny * k]]));
return { d, pts };
}
/** Leg: hip -> knee -> foot with three claws. */
function leg(hip, knee, foot, r, toe = 1) {
const d = [tube([hip, [lerp(hip[0], knee[0], 0.6), lerp(hip[1], knee[1], 0.6)], knee, [lerp(knee[0], foot[0], 0.5), lerp(knee[1], foot[1], 0.5)]], r, r * 0.6, 14),
tube([[lerp(knee[0], foot[0], 0.4), lerp(knee[1], foot[1], 0.4)], [lerp(knee[0], foot[0], 0.6), lerp(knee[1], foot[1], 0.6)], [lerp(knee[0], foot[0], 0.85), lerp(knee[1], foot[1], 0.85)], foot], r * 0.6, r * 0.45, 10)];
for (let i = -1; i <= 1; i++) d.push(poly([[foot[0] - 2, foot[1] - 2], [foot[0] + toe * (6 + i * 1.5), foot[1] + 1 + i * 2.2], [foot[0] + 1, foot[1] + 2.5]]));
return d;
}
/* ---------- poses ---------- */
const POSES = {
// seated and watchful, one wing raised, tail curled round the feet
sitting() {
const d = [];
d.push(...wing({ shoulder: [88, 74], wrist: [62, 18], tip: [24, 30], fingers: [[14, 66], [30, 98], [56, 116]], root: [76, 112], bow: 0.3 }));
d.push(ell(92, 104, 26, 36, -0.25));
d.push(tube([[90, 80], [96, 58], [110, 42], [116, 34]], 13, 7));
const t = tail([[76, 132], [56, 150], [110, 158], [168, 150]], 9);
d.push(...t.d);
d.push(...leg([84, 120], [70, 136], [86, 152], 12, 1));
d.push(...leg([102, 104], [110, 124], [114, 150], 7, 1));
const h = head({ at: [114, 34], ang: -0.05, size: 1.05 });
d.push(...h.d);
d.push(...spines(bez([[86, 84], [84, 62], [100, 44], [110, 36]], 10), 4, -1, 2));
d.push(...spines(t.pts.slice(0, 26), (u) => 4 * (1 - u), 1, 3));
return { d, eye: h.eye, eyeR: h.eyeR };
},
// low and stalking, head forward, wings folded
prowling() {
const d = [];
d.push(...wing({ shoulder: [92, 92], wrist: [70, 64], tip: [118, 52], fingers: [[136, 70], [130, 90]], root: [104, 100], bow: 0.25, bone: 3.4 }));
d.push(ell(96, 108, 38, 18, 0.05));
d.push(tube([[124, 104], [140, 98], [152, 92], [162, 94]], 11, 7));
const t = tail([[62, 108], [36, 106], [22, 128], [6, 120]], 11);
d.push(...t.d);
d.push(...leg([72, 112], [60, 128], [70, 146], 11));
d.push(...leg([84, 116], [94, 130], [92, 146], 8));
d.push(...leg([118, 112], [126, 128], [124, 146], 8));
d.push(...leg([128, 110], [140, 126], [146, 146], 7));
const h = head({ at: [160, 94], ang: 0.12, size: 1 });
d.push(...h.d);
d.push(...spines(bez([[66, 92], [90, 84], [130, 86], [156, 88]], 14), 3.6, -1, 2));
d.push(...spines(t.pts.slice(0, 26), (u) => 3.6 * (1 - u), -1, 3));
return { d, eye: h.eye, eyeR: h.eyeR };
},
// in flight, both wings spread
flying() {
const d = [];
d.push(...wing({ shoulder: [96, 84], wrist: [70, 36], tip: [40, 6], fingers: [[30, 40], [44, 66], [70, 80]], root: [92, 94], bow: 0.32 }));
d.push(...wing({ shoulder: [110, 84], wrist: [140, 30], tip: [190, 14], fingers: [[178, 52], [160, 76], [134, 90]], root: [114, 96], bow: 0.32 }));
d.push(ell(104, 96, 30, 13, 0.2));
d.push(tube([[128, 92], [142, 86], [150, 76], [158, 72]], 9, 6));
const t = tail([[78, 92], [54, 98], [40, 120], [12, 116]], 8);
d.push(...t.d);
d.push(...leg([94, 102], [96, 116], [108, 124], 6));
d.push(...leg([116, 102], [122, 114], [132, 118], 5));
const h = head({ at: [156, 72], ang: -0.2, size: 0.9, open: 2 });
d.push(...h.d);
return { d, eye: h.eye, eyeR: h.eyeR };
},
// reared up and roaring, wings half open
roaring() {
const d = [];
d.push(...wing({ shoulder: [94, 68], wrist: [52, 40], tip: [30, 2], fingers: [[16, 46], [34, 78], [66, 96]], root: [90, 98], bow: 0.3 }));
d.push(ell(98, 100, 22, 40, 0.2));
d.push(tube([[104, 70], [112, 50], [126, 34], [136, 24]], 13, 7));
const t = tail([[86, 136], [60, 156], [30, 150], [14, 132]], 10);
d.push(...t.d);
d.push(...leg([90, 124], [104, 138], [96, 154], 12));
d.push(...leg([108, 86], [124, 92], [132, 82], 6, 1));
d.push(...leg([102, 92], [116, 104], [126, 98], 6, 1));
const h = head({ at: [134, 24], ang: -0.55, size: 1.05, open: 7 });
d.push(...h.d);
d.push(...spines(bez([[94, 86], [100, 60], [116, 40], [130, 28]], 10), 4, -1, 2));
return { d, eye: h.eye, eyeR: h.eyeR };
},
// coiled, as if wrapped around something, head lifted
coiled() {
const d = [];
const t = tail([[100, 120], [30, 150], [20, 80], [80, 74]], 15);
d.push(...t.d);
d.push(tube([[100, 120], [150, 130], [170, 96], [140, 70]], 16, 12));
d.push(tube([[140, 70], [124, 52], [128, 34], [146, 26]], 12, 7));
d.push(...wing({ shoulder: [134, 76], wrist: [106, 36], tip: [72, 26], fingers: [[64, 52], [80, 70], [104, 82]], root: [124, 90], bow: 0.28, bone: 3.4 }));
d.push(...leg([150, 116], [164, 126], [170, 142], 8));
d.push(...leg([116, 124], [114, 138], [122, 150], 8));
const h = head({ at: [144, 26], ang: 0.1, size: 1 });
d.push(...h.d);
d.push(...spines(t.pts, (u) => 3.5 * (1 - u * 0.7), -1, 3));
return { d, eye: h.eye, eyeR: h.eyeR };
},
// lying down at rest, head up
resting() {
const d = [];
d.push(...wing({ shoulder: [90, 108], wrist: [66, 84], tip: [112, 70], fingers: [[134, 88], [124, 108]], root: [100, 118], bow: 0.25, bone: 3.2 }));
d.push(ell(92, 126, 42, 18, 0));
d.push(tube([[124, 120], [140, 112], [146, 92], [158, 82]], 12, 7));
const t = tail([[54, 130], [24, 140], [20, 152], [70, 152]], 11);
d.push(...t.d);
d.push(...leg([120, 132], [132, 142], [150, 146], 8));
d.push(...leg([70, 134], [82, 144], [96, 148], 10));
const h = head({ at: [156, 84], ang: 0.05, size: 1 });
d.push(...h.d);
d.push(...spines(bez([[60, 112], [90, 104], [130, 106], [152, 88]], 14), 3.4, -1, 2));
return { d, eye: h.eye, eyeR: h.eyeR };
},
};
const cache = {};
/** SVG markup for one dragon: <g> with the silhouette in `fill` and a small eye in `eyeFill`. */
function svg(pose, { fill = "#2a2230", eyeFill = "#f6e6c4", flip = false } = {}) {
if (!cache[pose]) cache[pose] = POSES[pose]();
const p = cache[pose];
const tf = flip ? ' transform="translate(200 0) scale(-1 1)"' : "";
// one path per part: parts wind in different directions, so a single combined path would punch holes
return `<g${tf}><g fill="${fill}">${p.d.map((d) => `<path d="${d}"/>`).join("")}</g><circle cx="${f(p.eye[0])}" cy="${f(p.eye[1])}" r="${p.eyeR}" fill="${eyeFill}"/></g>`;
}
/* ---------- cadets and the thorn bush (same building blocks, 100 x 140 box, feet near y = 132) ---------- */
const line = (a, b, r0, r1 = r0) => tube([a, [lerp(a[0], b[0], 0.33), lerp(a[1], b[1], 0.33)], [lerp(a[0], b[0], 0.66), lerp(a[1], b[1], 0.66)], b], r0, r1, 8);
/** A cadet from joint positions; `cloak` adds a short flying cape, weapons are drawn from the hands. */
function cadet(j, { cloak = true, sword = null, dagger = null, size = 1 } = {}) {
const d = [];
if (cloak) d.push(poly([j.neck, [j.neck[0] - 4, j.neck[1] + 2], [j.hip[0] - 14 * (j.face || 1), j.hip[1] + 16], [j.hip[0] - 2 * (j.face || 1), j.hip[1] + 8], [j.neck[0] + 3, j.neck[1] + 4]]));
d.push(line(j.neck, j.hip, 7.5 * size, 6.5 * size)); // torso
d.push(line(j.hip, j.lKnee, 4.6 * size, 4 * size), line(j.lKnee, j.lFoot, 3.8 * size, 3 * size));
d.push(line(j.hip, j.rKnee, 4.6 * size, 4 * size), line(j.rKnee, j.rFoot, 3.8 * size, 3 * size));
d.push(poly([[j.lFoot[0] - 3, j.lFoot[1] - 2], [j.lFoot[0] + 7 * (j.face || 1), j.lFoot[1] - 1], [j.lFoot[0] + 7 * (j.face || 1), j.lFoot[1] + 2], [j.lFoot[0] - 3, j.lFoot[1] + 2]]));
d.push(poly([[j.rFoot[0] - 3, j.rFoot[1] - 2], [j.rFoot[0] + 7 * (j.face || 1), j.rFoot[1] - 1], [j.rFoot[0] + 7 * (j.face || 1), j.rFoot[1] + 2], [j.rFoot[0] - 3, j.rFoot[1] + 2]]));
const sh = [j.neck[0], j.neck[1] + 3];
d.push(line(sh, j.lElbow, 3.4 * size, 3), line(j.lElbow, j.lHand, 3, 2.4));
d.push(line(sh, j.rElbow, 3.4 * size, 3), line(j.rElbow, j.rHand, 3, 2.4));
d.push(ell(j.head[0], j.head[1], 7.2 * size, 8 * size, 0)); // head
d.push(ell(j.head[0] - 2 * (j.face || 1), j.head[1] - 3, 7 * size, 5 * size, 0)); // hair
d.push(line([(j.neck[0] + j.head[0]) / 2, (j.neck[1] + j.head[1]) / 2 + 2], j.neck, 3.2, 3.6)); // neck
const blade = (hand, ang, len, w) => {
const tip = [hand[0] + Math.cos(ang) * len, hand[1] + Math.sin(ang) * len];
const nx = -Math.sin(ang), ny = Math.cos(ang);
return [poly([[hand[0] + nx * w, hand[1] + ny * w], [tip[0] + nx * w * 0.4, tip[1] + ny * w * 0.4], [tip[0] + Math.cos(ang) * 4, tip[1] + Math.sin(ang) * 4], [tip[0] - nx * w * 0.4, tip[1] - ny * w * 0.4], [hand[0] - nx * w, hand[1] - ny * w]]),
line([hand[0] + nx * 6, hand[1] + ny * 6], [hand[0] - nx * 6, hand[1] - ny * 6], 1.4)];
};
if (sword) d.push(...blade(j[sword.hand], sword.ang, sword.len || 44, 1.9));
if (dagger) d.push(...blade(j[dagger.hand], dagger.ang, dagger.len || 16, 1.6));
return d;
}
const FIGURES = {
// your squadmate, braced, sword raised high
defender: () => cadet({ face: 1, head: [42, 30], neck: [44, 42], hip: [46, 84], lKnee: [36, 106], lFoot: [28, 130], rKnee: [58, 104], rFoot: [64, 130],
lElbow: [56, 50], lHand: [62, 34], rElbow: [56, 56], rHand: [62, 38] }, { sword: { hand: "lHand", ang: -1.15, len: 46 } }),
// the bigger bully, lunging with a sword
lunging: () => cadet({ face: -1, head: [56, 34], neck: [54, 46], hip: [58, 86], lKnee: [42, 104], lFoot: [30, 130], rKnee: [70, 108], rFoot: [82, 130],
lElbow: [40, 56], lHand: [26, 60], rElbow: [44, 60], rHand: [30, 64] }, { sword: { hand: "lHand", ang: Math.PI + 0.12, len: 42 }, size: 1.12 }),
// the smaller bully, dagger raised to throw
throwing: () => cadet({ face: -1, head: [50, 46], neck: [50, 57], hip: [52, 92], lKnee: [42, 110], lFoot: [36, 130], rKnee: [62, 110], rFoot: [68, 130],
lElbow: [40, 66], lHand: [36, 80], rElbow: [64, 52], rHand: [70, 38] }, { dagger: { hand: "rHand", ang: -0.9 }, size: 0.88 }),
// the wounded cadet, lying on the ground, a belt tied above the knee
lying: () => {
const d = cadet({ face: 1, head: [16, 118], neck: [26, 120], hip: [62, 122], lKnee: [80, 116], lFoot: [96, 126], rKnee: [80, 126], rFoot: [84, 128],
lElbow: [34, 108], lHand: [40, 96], rElbow: [38, 128], rHand: [52, 130] }, { cloak: false });
d.push(poly([[2, 132], [98, 132], [96, 136], [4, 136]])); // the ground line
return d;
},
// a thorn bush: arching branches with thorns and a few leaves
thorns: () => {
const d = [], R = (() => { let s = 7; return () => ((s = (s * 1103515245 + 12345) % 2147483648) / 2147483648); })();
// a low mound of leaves, then arching thorny canes
[[22, 128, 18, 9], [50, 124, 24, 12], [78, 128, 18, 9], [36, 118, 14, 8], [64, 118, 14, 8]].forEach(([x, y, rx, ry]) => d.push(ell(x, y, rx, ry, 0)));
for (let k = 0; k < 11; k++) {
const a = Math.PI * (0.08 + 0.84 * (k / 10)) + (R() - 0.5) * 0.2, len = 50 + R() * 34;
const sx = 50 + (R() - 0.5) * 24, sy = 124;
const ex = sx - Math.cos(a) * len, ey = sy - Math.sin(a) * len * 0.95;
const b = [[sx, sy], [sx - Math.cos(a) * len * 0.35, sy - Math.sin(a) * len * 0.75], [ex + Math.cos(a) * 6, ey - 10], [ex, ey + 4]];
d.push(tube(b, 2.6, 0.8, 18));
bez(b, 12).slice(2, -1).forEach((p, i) => {
const side = i % 2 ? 1 : -1, l = 3.5 + R() * 3;
d.push(poly([[p[0] - 1.2, p[1]], [p[0] + side * l, p[1] - l * 0.7], [p[0] + 1.2, p[1]]]));
if (i % 3 === 1) d.push(ell(p[0] - side * 5, p[1] - 1, 4.2, 2.2, side * 0.6));
});
}
return d;
},
};
const fcache = {};
/** SVG markup for a figure (cadets, the thorn bush) in one ink colour. */
function figure(name, { fill = "#3b2416", flip = false } = {}) {
if (!fcache[name]) fcache[name] = FIGURES[name]();
const tf = flip ? ' transform="translate(100 0) scale(-1 1)"' : "";
return `<g${tf}><g fill="${fill}">${fcache[name].map((d) => `<path d="${d}"/>`).join("")}</g></g>`;
}
return { svg, figure, poses: Object.keys(POSES), figures: Object.keys(FIGURES) };
});
+26 -197
View File
@@ -9,9 +9,7 @@
* 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.
* "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).
* A toggle adds the community's actual traffic underneath. The URL keeps the selection (#valley/blue/meadow-Blue).
*/
(function () {
"use strict";
@@ -41,15 +39,15 @@
};
const RESCUE = { Orange: "tree-Greens", Brown: "tree-Greens" };
const SPOTS = [
{ place: "treeRed", enc: "tree-Red", colour: "Red", pose: "roaring", 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: "prowling", 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: "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: "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: "flying", flip: true, sc: 0.3 },
{ place: "meadow:Brown", enc: "meadow-Brown", colour: "Brown", pose: "sitting", sc: 0.32 },
{ place: "meadow:Blue", enc: "meadow-Blue", colour: "Blue", pose: "coiled", sc: 0.32 },
{ place: "meadow:Orange", enc: "meadow-Orange", colour: "Orange", pose: "sitting", flip: true, sc: 0.3 },
{ place: "meadow:Brown", enc: "meadow-Brown", colour: "Brown", pose: "resting", 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" };
Object.keys(L).filter((k) => k.startsWith("see:")).forEach((k) => {
@@ -87,13 +85,12 @@
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, 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];
function advisorFor(enc, colour = st.colour) {
const k = `${st.sample}|${colour}|${st.objective}|${enc}`;
// the Black needs the shadow, which (almost) only shows on a first attempt: its routes are solved for that attempt
if (!st.cache.has(k)) st.cache.set(k, S.advisor(model(), colour, st.objective, { only: [enc], attempt: colour === "Black" ? "First attempt" : null }));
if (!st.cache.has(k)) st.cache.set(k, S.advisor(model(), colour, st.objective, { only: [enc] }));
return st.cache.get(k);
}
let encParams = null;
@@ -325,13 +322,6 @@
pills.push({ g, x, y, w, h, dy: 0 });
el("rect", { x: x - w / 2, y: y - h / 2, width: w, height: h, rx: h / 2, fill: bg, "fill-opacity": 0.95, stroke: edge || ink, "stroke-opacity": edge ? 0.95 : 0.4, "stroke-width": edge ? 2 : 1 }, g);
el("text", { x, y: y + (strong ? 4.5 : 4), "text-anchor": "middle", "font-size": strong ? 12.5 : 11, "font-weight": strong ? 700 : 500, fill: ink, "font-family": "var(--font-data)" }, g).textContent = text;
return { g, w };
}
/** What a roll on the route can come out as: every outcome with its odds, for the dice. */
function rollOf(s, title) {
return { title: title || s.label || "A roll", options: Object.entries(s.probs || {}).filter(([, p]) => p > 0.0005),
note: "The game decides this at random. The odds are the model's, given the choices on this route so far." };
}
function drawDragons(g, routesOn) {
@@ -352,8 +342,8 @@
"aria-label": sp.first ? `${sp.colour} dragon, first sighting` : `${ENC_NAME[sp.enc]}. Show the routes to it.` }, g);
if (isTarget && routesOn) el("ellipse", { cx: 100, cy: 140, rx: 80, ry: 16, fill: INK[sp.colour], "fill-opacity": 0.25 }, gg);
// a soft paper-coloured halo keeps dark dragons readable on the dark canopy
gg.innerHTML += `<g stroke="${PAPER.halo}" stroke-width="9" stroke-linejoin="round" opacity="0.55">${D.svg(sp.pose, { fill: PAPER.halo, eyeFill: PAPER.halo, flip: sp.flip, lines: false })}</g>`;
gg.innerHTML += D.svg(sp.pose, sp.colour === "Black" ? { dark: true, outline: "#3a2a44", flip: sp.flip } : { fill: INK[sp.colour], flip: sp.flip, lineOpacity: 0.5, outline: "#1b0811", outlineOpacity: 0.55, outlineWidth: 1.1 });
gg.innerHTML += `<g stroke="${PAPER.halo}" stroke-width="9" stroke-linejoin="round" opacity="0.55">${D.svg(sp.pose, { fill: PAPER.halo, eyeFill: PAPER.halo, flip: sp.flip })}</g>`;
gg.innerHTML += D.svg(sp.pose, { fill: INK[sp.colour], flip: sp.flip });
el("rect", { x: 0, y: 0, width: 200, height: 160, fill: "transparent" }, gg);
if (sp.twin) return;
const tipHtml = () => {
@@ -428,22 +418,6 @@
hit.addEventListener("keydown", (e) => { if (e.key === "Enter" || e.key === " ") { e.preventDefault(); go(); } });
}
});
// every other choice point (the bully fight's endings, the wounded cadet's, the forks, who you enter with) is a
// small dot you can click too; its name shows on hover, and in full once it is picked or its moment is open
if (!st.colour && st.policy) {
Object.keys(POINTS).forEach((id) => {
const P = L[id];
if (!P || P.kind === "dragon" || ids.has(id)) return;
const name = LANDMARK_NAME[id] || P.name || id;
const hit = el("g", { class: "ex-place ex-minor", tabindex: 0, role: "button", "aria-label": `${name}: show the best way from here to every dragon` }, g);
el("circle", { cx: P.x, cy: P.y, r: 10, fill: "transparent" }, hit);
el("circle", { cx: P.x, cy: P.y, r: 3.6, fill: PAPER.halo, stroke: PAPER.ink, "stroke-width": 1.6, "stroke-opacity": 0.85 }, hit);
el("title", {}, hit).textContent = `${name}${P.desc ? `: ${P.desc}` : ""} Click for the best way from here to every dragon.`;
const go = () => { st.point = id; st.info = null; writeHash(); render(); };
hit.addEventListener("click", go);
hit.addEventListener("keydown", (e) => { if (e.key === "Enter" || e.key === " ") { e.preventDefault(); go(); } });
});
}
const gt = el("text", { x: GATE.x, y: GATE.y + 14, "text-anchor": "middle", "font-size": 11, "letter-spacing": "0.16em", fill: PAPER.ink, "font-family": "var(--font-label)", "paint-order": "stroke", stroke: PAPER.halo, "stroke-width": 3 }, g);
gt.textContent = "ENTER THE VALLEY";
if (!st.colour && st.policy) {
@@ -458,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) {
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)
// 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]) => {
@@ -479,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) {
const best = Math.max(1e-12, ...routes.map((r) => r.value.x));
const onRoute = new Set();
@@ -534,12 +468,11 @@
if (p > 0.995) return;
// the last roll leads straight into the dragon, whose own label sits there: put the roll under the fork point
const at = !ro.at ? { x: ro.P.x + 34, y: ro.P.y - 22 } : ro.at === pts.length - 1 ? { x: pts[ro.at - 1].P.x, y: pts[ro.at - 1].P.y + 24 } : mid(pts[ro.at - 1].P, pts[ro.at].P, 0.38);
const lab = pill(gLab, at.x, at.y, ro.s.var === "shadow" ? (ro.s.taken === "yes" ? `shadow ${pct(p)}` : `no shadow ${pct(p)}`) : `roll ${pct(p)}`);
Dice.svg(lab.g, at.x - lab.w / 2 - 14, at.y, rollOf(ro.s, ro.s.var === "shadow" ? "Does the shadow show at the tree?" : null));
pill(gLab, at.x, at.y, ro.s.var === "shadow" ? (ro.s.taken === "yes" ? `shadow ${pct(p)}` : `no shadow ${pct(p)}`) : `roll ${pct(p)}`);
});
// destination label
const end = pts[pts.length - 1];
pill(gLab, end.P.x, end.P.y + 30, `${pct(r.value.x)} ${st.colour === "Black" ? "on a first attempt" : "per attempt"}`, { edge: tc, strong: rel === 1 });
pill(gLab, end.P.x, end.P.y + 30, `${pct(r.value.x)} per attempt`, { edge: tc, strong: rel === 1 });
// choice points on the focused route: one diamond per place, even when several choices are made there
// (at the bully fight: help or walk away, your first move, the dagger, then the bullies' fate)
if (focus) {
@@ -699,20 +632,9 @@
const hideTip = () => { const t = $("#ex-tip"); if (t) t.hidden = true; };
/* ---------- 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)", dark: c === "Black" })}</svg>`;
const POSE_OF = { Red: "roaring", Orange: "flying", Brown: "sitting", Green: "prowling", Blue: "coiled", Black: "resting" };
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 || !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>`;
}
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>`;
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>`;
}
@@ -723,7 +645,7 @@
const sp = st.info, dir = sp.place.split(":")[1];
const fs = st.policy ? S.makeParams(model().model.tables, { alphas: model().model.alphas }).chance("fs", { direction: dir }) : null;
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${fs ? ` ${Dice.html({ title: `First dragon, going ${dir === "Center" ? "to the forest centre" : dir.toLowerCase()}`, options: Object.entries(fs).filter(([, p]) => p > 0.0005), note: "The game decides which dragon you see first. Which way you went changes the odds." })}` : ""}: 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>`;
<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.nRuns ? st.nRuns.toLocaleString() : "thousands of"} logged runs</span>
<h2 id="h-valley">The valley</h2>
@@ -762,95 +684,9 @@
${trafficToggle()}`;
}
/** Inside the bonding encounter: the answers the bot gave, screen by screen, on its best logged way to bond this
* colour (data/tree.json, analysis/tree/build_tree.py), with what every other answer did. Only shown when the bot's
* way goes through the same encounter as the route; the community form does not record these answers. */
const TREE_SIDE = (enc) => (/^(valley|meadow)-/.test(enc) ? "valley" : "tree");
/** The community route PDF's answers for an encounter (data/pdf_encounters.json): its recommended (dark-tile) answers
* as numbered steps toward this dragon, then the whole tree. */
// the goal inside one encounter: a bond with this colour, or (an encounter that leads on, like the shadow before
// the Black) the way on to the next one
const isGoal = (end, colour, onward) => onward ? new RegExp(`^On to the ${onward}`).test(end || "")
: /^Bonded|Bonded \(/.test(end || "") && (!/\(/.test(end) || new RegExp(colour).test(end));
function leadsTo(o, colour, onward) {
if (o.end) return isGoal(o.end, colour, onward);
return (o.then || []).some((c) => !c.roll && leadsTo(c, colour, onward));
}
function guidePath(options, colour, onward) {
const steps = [];
let opts = options;
while (opts && opts.length) {
const live = opts.filter((o) => !o.roll);
const pick = live.find((o) => o.best && leadsTo(o, colour, onward)) || live.find((o) => leadsTo(o, colour, onward));
if (!pick) break;
const roll = opts.find((o) => o.roll);
steps.push({ pick, others: live.filter((o) => o !== pick), roll: roll ? roll.roll : null });
if (pick.end) break;
opts = pick.then;
}
return steps;
}
const endOf = (o) => (o.end ? o.end : "continues");
function treeList(options) {
return `<ul>${options.map((o) => o.roll ? `<li class="roll">${Dice.html({ title: "A roll (from the community guide)", note: `The guide notes: ${o.roll}. It gives no odds for it.` })}<em>${esc(o.roll)}</em></li>` :
`<li class="${o.best ? "best" : ""}${o.unconfirmed ? " pale" : ""}">${esc(o.say)}${o.pct ? ` <small>${esc(o.pct)}</small>` : ""}${o.end ? ` → <b>${esc(o.end)}</b>` : ""}${o.then ? treeList(o.then) : ""}</li>`).join("")}</ul>`;
}
function guideAnswers(enc) {
const g = st.guide;
if (!g) return "";
const keys = (g.route_encounters || {})[enc] || [];
if (!keys.length) return "";
const src = g.source || {};
const blocks = keys.map((k, ki) => {
const E = g.encounters[k];
if (!E) return "";
const next = keys[ki + 1] ? (g.encounters[keys[ki + 1]] || {}).title || "" : "";
const steps = guidePath(E.options, st.colour, next ? next.replace(/^The /, "") : null);
const rows = steps.map((s, i) => `<li><span class="n">${i + 1}</span><div><b>${esc(s.pick.say)}</b>${s.roll ? `<small class="ex-roll">${Dice.html({ title: "A roll (from the community guide)", note: `The guide notes: ${s.roll}. It gives no odds for it.` })}The guide notes: ${esc(s.roll)}.</small>` : ""}
<small>${s.pick.pct ? `the guide's rate: ${esc(s.pick.pct)}` : ""}${s.pick.unconfirmed ? " · unconfirmed" : ""}${s.pick.end ? `${s.pick.pct ? " · " : ""}${esc(s.pick.end)}` : ""}</small>
${s.others.length ? `<details><summary>Other answers here</summary><ul>${s.others.map((o) => `<li>${esc(o.say)}${o.pct ? ` <small>${esc(o.pct)}</small>` : ""} → ${esc(endOf(o))}</li>`).join("")}</ul></details>` : ""}</div></li>`).join("");
return `<p class="small"><b>${esc(E.title)}</b>: <em>${esc(E.scene)}</em>${E.warning ? ` <span class="ex-warn">${esc(E.warning)}</span>` : ""}</p>
${rows ? `<ol>${rows}</ol>` : `<p class="small muted">The guide shows no way to bond a ${st.colour} here.</p>`}
${E.note ? `<p class="small muted">${esc(E.note)}</p>` : ""}
<details class="ex-fulltree"><summary>Every answer in the guide's tree</summary>${treeList(E.options)}</details>`;
}).join("");
return `<div class="ex-inside"><span class="eyebrow">Inside the encounter: the community guide's answers</span>${blocks}
<p class="small muted">From the <a href="${esc(src.link || "#")}" target="_blank" rel="noopener">community route PDF</a> by ${esc((src.authors || []).join(", "))} (${esc(src.version || "")} version), transcribed as data. ${esc(src.note || "")}</p></div>`;
}
function encounterAnswers(enc) {
return guideAnswers(enc) + botAnswers(enc);
}
function botAnswers(enc) {
const t = st.tree;
if (!t) return '<p class="small muted ex-inside">Loading the answers inside the encounter…</p>';
const best = (t.best || {})[st.colour];
const picks = best && best.picks && best.picks.length ? best.picks : null;
const hourAt = picks ? picks.findIndex((p) => (t.screens[p.screen] || {}).stage === "THORN_WALK") : -1;
const side = hourAt >= 0 && /valley/i.test(picks[hourAt].text) ? "valley" : "tree";
const viaShadow = picks && picks.some((p) => /shadow/i.test(p.text) && !/descend/i.test(p.text));
const fits = picks && hourAt >= 0 && side === TREE_SIDE(enc) && (enc.startsWith("shadow-") ? viaShadow : !viaShadow || side === "valley");
if (!fits) return `<p class="small muted ex-inside">The DragonKind bot hasn't bonded a ${st.colour} through ${esc(ENC_NAME[enc] || enc)} yet, so it can't confirm these answers. (The community form records only how the encounter ended, not the answers given.)</p>`;
const died = (o) => (o.to && o.to.DIED ? o.to.DIED.n : 0);
const rows = picks.slice(hourAt + 1).map((p, i) => {
const sc = t.screens[p.screen] || { options: {} };
const me = sc.options[p.option] || { n: p.n, to: {} };
const lived = me.n - died(me);
const others = Object.entries(sc.options).filter(([k]) => k !== p.option).map(([, o]) =>
`<li>${esc(o.text)} <small>${o.n ? `died ${died(o)} of ${o.n}` : "untested"}</small></li>`).join("");
return `<li><span class="n">${i + 1}</span><div><b>${esc(p.text)}</b>
<small>${me.n ? `got through ${lived} of ${me.n} times` : ""}${me.kind === "fixed" && me.n ? " · always the same so far" : me.kind === "dice" ? ` · a roll ${Dice.html({ title: p.text, n: me.n, options: Object.entries(me.to || {}).map(([k, o]) => [k === "DIED" ? "died" : k.startsWith("BONDED") ? k.replace("BONDED_", "bonded ").toLowerCase() : (t.screens[k] ? `then: ${t.screens[k].stage.toLowerCase().replace(/_/g, " ")}${t.screens[k].tint ? ` (${t.screens[k].tint})` : ""}` : k), o.n / me.n]), note: "The same answer led to different screens in the bot's runs: the game rolled." })}` : ""}</small>
${others ? `<details><summary>Other answers here</summary><ul>${others}</ul></details>` : ""}</div></li>`;
}).join("");
const end = Object.keys((t.screens[picks[picks.length - 1].screen] || { options: {} }).options[picks[picks.length - 1].option]?.to || {}).find((k) => k.startsWith("BONDED"));
return `<div class="ex-inside"><span class="eyebrow">What the DragonKind bot did: the answers that bonded</span>
<ol>${rows}</ol>
<p class="small muted">${end ? `Bonded a ${end.split(":")[1]}. ` : ""}From the bot's own runs (it logs every screen it sees), so the counts are small; untested answers may also work.</p></div>`;
}
function panelRoutes(routes) {
const best = Math.max(1e-12, ...routes.map((r) => r.value.x));
const T = model().targets[st.colour], first = st.colour === "Black" && T.firstAttempt, b = first ? T.firstAttempt.thisAttempt : T[st.objective];
const T = model().targets[st.colour], b = T[st.objective];
const focus = routes.find((r) => r.enc === st.focus) || routes[0];
const card = (r) => {
const rel = r.value.x / best, o = encOutcome(r.enc), c = encColour(r.enc);
@@ -860,18 +696,17 @@
return `<button type="button" class="ex-route-card${r.enc === focus.enc ? " on" : ""}" data-enc="${r.enc}" aria-pressed="${r.enc === focus.enc}">
<i class="ex-swatch ${style}" style="--c: var(${DV[st.colour]}); opacity:${(0.3 + 0.7 * rel).toFixed(2)}"></i>
<span class="nm">${esc(ENC_NAME[r.enc])}${RESCUE[st.colour] === r.enc && st.colour !== "Green" ? " <em>(rescue)</em>" : ""}</span>
<b>${pct(r.value.x)}</b><small>${st.colour === "Black" ? "on a first attempt" : "per attempt"} · ${bond}${n < 30 ? ` · only ${n} attempts logged` : ""}${r.value.o > 0.005 ? ` · ends on another dragon ${pct(r.value.o)}` : ""}</small></button>`;
<b>${pct(r.value.x)}</b><small>per attempt · ${bond}${n < 30 ? ` · only ${n} attempts logged` : ""}${r.value.o > 0.005 ? ` · ends on another dragon ${pct(r.value.o)}` : ""}</small></button>`;
};
const steps = focus.steps.filter((s) => s.kind === "decision" || s.kind === "chance").map((s) => {
if (s.kind === "chance") return `<li class="chance"><span>${esc(s.label)} ${Dice.html(rollOf(s))}</span><b>${esc(String(s.taken))}</b><small>roll ${pct(s.probs[s.taken])}</small></li>`;
if (s.kind === "chance") return `<li class="chance"><span>${esc(s.label)}</span><b>${esc(String(s.taken))}</b><small>roll ${pct(s.probs[s.taken])}</small></li>`;
const open = st.expanded === s.var;
const opts = open ? `<div class="ex-opts">${Object.entries(s.options).sort((a, c) => c[1].pX - a[1].pX).map(([v, val]) =>
`<button type="button" class="ex-opt${v === s.taken ? " on" : ""}" data-var="${s.var}" data-v="${esc(v)}"><span>${esc(v)}${v === s.choice ? ' <em class="rec">best</em>' : ""}</span><b>${pct(val.pX)}</b></button>`).join("")}</div>` : "";
const inside = open && s.var === "encounter" ? encounterAnswers(focus.enc) : "";
return `<li class="dec${open ? " open" : ""}"><button type="button" class="ex-step" data-var="${s.var}" aria-expanded="${open}"><span>${esc(s.label)}</span><b>${esc(String(s.taken))}</b><small>${s.userSet ? "your choice" : "best"} · ${s.var === "encounter" ? pct(s.options[s.taken].pX) : pct(s.options[s.taken].pX)}</small></button>${opts}${inside}</li>`;
return `<li class="dec${open ? " open" : ""}"><button type="button" class="ex-step" data-var="${s.var}" aria-expanded="${open}"><span>${esc(s.label)}</span><b>${esc(String(s.taken))}</b><small>${s.userSet ? "your choice" : "best"} · ${s.var === "encounter" ? pct(s.options[s.taken].pX) : pct(s.options[s.taken].pX)}</small></button>${opts}</li>`;
}).join("");
const risks = focus.steps.filter((s) => s.risk && s.risk.p > 0.0005).map((s) => `${s.risk.label.toLowerCase()} ${pct(s.risk.p)}`);
const lbT = st.policy.samples.lowBias.targets[st.colour], lb = first && lbT.firstAttempt ? lbT.firstAttempt.thisAttempt : lbT.thisAttempt;
const lb = st.policy.samples.lowBias.targets[st.colour].thisAttempt;
return `<div class="ex-head" style="--c: var(${DV[st.colour]})">${mini(st.colour, POSE_OF[st.colour])}<div><span class="eyebrow">Routes to a</span><h2 id="h-valley">${st.colour} dragon</h2></div>
<button type="button" class="ex-close" id="ex-clear" aria-label="Back to the whole valley">×</button></div>
${chooser()}
@@ -879,12 +714,11 @@
${st.blocked ? `<p class="small ex-warn">Your choices so far can't reach a ${st.colour} dragon. <button type="button" class="linklike" id="ex-reset-route">Reset your choices</button></p>` : ""}
<div class="ex-routes">${routes.map(card).join("")}</div>
<p class="small muted ex-key"><span class="solid"></span> best route <span class="dashed"></span> under half as likely <span class="dotted"></span> under a tenth · line width: chance you are still on the route</p>
<p class="small muted">${Dice.legend()}</p>
<span class="eyebrow">${esc(ENC_NAME[focus.enc])}: step by step</span>
<ol class="ex-steps">${steps}</ol>
<p class="small muted">Diamonds on the map are choices: click one to see where the other options lead. ${st.blocked ? "" : `Your choices apply to every route to this dragon. Changed your mind? <button type="button" class="linklike" id="ex-reset-route">Reset your choices</button>`}</p>
<details class="ex-why"><summary>Why this route?</summary>
${first ? `<p class="small"><span class="pill warn">Low evidence</span> Best route for the Black, on a <b>first attempt</b>: about <b>1 in ${Math.round(1 / Math.max(b.pX.mean, 1e-9))}</b>, somewhere between 1 in ${Math.round(1 / Math.max(b.pX.hi, 1e-9))} and 1 in ${Math.round(1 / Math.max(b.pX.lo, 1e-9))} (95%). Later attempts almost never see the shadow. The low-bias sample suggests about 1 in ${Math.round(1 / Math.max(lb.pX.mean, 1e-9))}. Every logged shadow comes from riders who chose to post their run, so the shadow's odds rest on an assumption until complete first-attempt logs exist.</p>` : `<p class="small">Best route for any ${st.colour}: <b>${pct(b.pX.mean)}</b> per attempt (95% interval ${pct(b.pX.lo)}–${pct(b.pX.hi)}), about ${isFinite(b.expectedAttempts.mean) ? Math.round(b.expectedAttempts.mean) : "–"} attempts. Riders who logged every run suggest ${pct(lb.pX.mean)}.</p>`}
<p class="small">Best route for any ${st.colour}: <b>${pct(b.pX.mean)}</b> per attempt (95% interval ${pct(b.pX.lo)}–${pct(b.pX.hi)}), about ${isFinite(b.expectedAttempts.mean) ? Math.round(b.expectedAttempts.mean) : "–"} attempts. Riders who logged every run suggest ${pct(lb.pX.mean)}.</p>
<p class="small">Each roll's odds may depend on your earlier choices, as far as the data support it. Choices marked "no clear winner" in <a href="#deep">Deep Dive</a> are within the noise.${risks.length ? ` Risks on this route: ${risks.join(", ")}.` : ""}</p>
<p class="small">The bond chance at each encounter is the community average: the form does not record the answers riders gave there.</p>
<div class="seg" role="group" aria-label="Data"><button type="button" data-s="all" aria-pressed="${st.sample === "all"}">All runs</button><button type="button" data-s="lowBias" aria-pressed="${st.sample === "lowBias"}">Low-bias</button></div>
@@ -901,7 +735,6 @@
$$("[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(); });
@@ -1013,8 +846,7 @@
}
/** The runs selected on the page (one preset of data/stats.json): how many reached each place, and each step. */
function setStats(P, paths) {
if (paths) st.paths = paths;
function setStats(P) {
st.nRuns = P.analyse.n;
st.counts = P.valley.counts;
st.edges = P.valley.edges;
@@ -1023,9 +855,6 @@
function init() {
render();
// the screen tree (the answers inside each encounter), for the "Bonding encounter" step
fetch("data/tree.json").then((r) => r.json()).then((t) => { st.tree = t; if (st.expanded === "encounter") render(); }).catch(() => { st.tree = { best: {}, screens: {} }; });
fetch("data/pdf_encounters.json").then((r) => r.json()).then((g) => { st.guide = g; if (st.expanded === "encounter") render(); }).catch(() => {});
fetch("data/policy.json").then((r) => r.json()).then((p) => {
st.policy = p;
S.useGame(p.samples.all); // the game (and where each colour can be bonded) comes with the route model

Some files were not shown because too many files have changed in this diff Show More