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>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
d04b88e7b4
commit
11b4a0398e
+14
-14
@@ -1,21 +1,21 @@
|
||||
# core
|
||||
|
||||
The shared model. Every other part uses it, so a change here touches everything: run `npm test` after any edit.
|
||||
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 |
|
||||
|---|---|
|
||||
| `engine.js` | Turns a row of the community form (any version of it) into one coded run: the run format, every coding rule, missing answers, email redaction. Also the statistics the site shows. |
|
||||
| `spec/form.yaml` | **Declarative.** 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. |
|
||||
| `spec/game.yaml` | **Declarative.** The game: every decision and its options in order, every roll and what its odds may depend on, every bonding encounter, and the flow of a run from the entrance to the dragons. |
|
||||
| `atlas/model.py`, `atlas/solver.py` | The route model in Python: what each coded run reveals about each step, the count tables and shrinkage, and one interpreter of `game.yaml` used to solve, evaluate and export the best routes. `tests/parity/compare_solver.py` checks it against `solver.js`, which the site and the bot use until the JS advisor replaces it. |
|
||||
| `atlas/coding.py` | The Python coding rules: reads `form.yaml`, codes every row (`python -m atlas.coding`). Rule tests: `tests/core/test_coding.py`. |
|
||||
| `graph.js` | The route graph: the bot's scene graph, the decision-variable graph shared by all sources, the crosswalk from the bot's on-screen text to form answers, Beta credible intervals. |
|
||||
| `solver.js` | The decision model: every choice and roll in a run, chance estimates with empirical-Bayes back-off, backward induction for each dragon, and the advisor the site and the bot use to get advice from any point in a run. |
|
||||
| `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. |
|
||||
|
||||
All three JS files have no dependencies and run unchanged in Node and the browser. The site and Ken's bot load
|
||||
the published copies (`https://ekcschiano.github.io/threshing-atlas/solver.js` etc.), so their file names on the
|
||||
site must not change.
|
||||
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 answer, add it to `spec/form.yaml`. To change a rule, edit `atlas/coding.py`, add a test case, and (until the site stops coding rows in the browser) mirror it in `codeRow()` in `engine.js`; `tests/parity/` fails if they disagree.
|
||||
|
||||
The project is moving to Python plus declarative spec files; JavaScript stays only where it must run in the browser or in Ken's bot (see `docs/ROADMAP.md`).
|
||||
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`).
|
||||
|
||||
Reference in New Issue
Block a user