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:
ekcSchiano
2026-11-03 22:01:32 +00:00
committed by GitHub
co-authored by Claude Opus 5.5
parent d04b88e7b4
commit 11b4a0398e
27 changed files with 578 additions and 2260 deletions
+22 -3
View File
@@ -51,9 +51,10 @@ min_support: 20
# strength learned from the data).
chance:
fs: { label: First dragon, outcomes: [Red, Brown, Green, Orange], context: [direction, company, left] }
dieSight: { label: Survive the first dragon, outcomes: [die, live], context: [fs, direction, company, left, react] }
dieCombat: { label: Survive the fight, outcomes: [die, live], context: [fight, dagger, fs, direction] }
dieHour: { label: Survive the hour, outcomes: [die, live], context: [cadet, post] }
# 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] }
shadowColour: { label: Shadow dragon, outcomes: [Black, Blue], context: [] }
meadow: { label: Meadow dragon, outcomes: [Orange, Brown, Blue], context: [cadet, post, fs, direction, company] }
@@ -192,3 +193,21 @@ from_form:
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" }