Files
threshing-atlas/core/spec/game.yaml
T
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

214 lines
11 KiB
YAML

# 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).
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] }
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. tree-Greens can also end in an Orange or Brown rescue.
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 }
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" }