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>
195 lines
9.3 KiB
YAML
195 lines
9.3 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] }
|
|
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] }
|
|
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]
|