Tests for the route model's arithmetic on hand-made data (#26, part 1) #49

Merged
kathleen merged 1 commits from planner/model-tests into main 2026-11-19 21:41:30 +00:00
Owner

Part of #26: a read-through of core/atlas/model.py with a test for each piece, on small made-up datasets whose answers are worked out by hand in the comments. No bugs found; no code changes.

tests/core/test_model.py, 20 tests:

  • Back-off. Counts at every context level, stopping at the first missing step; weights (reporting bias) scale counts and 0 drops a run; each level is shrunk toward the one above (e.g. East = [7, 4, 1, 1] / 13 with alpha 12); an unseen context returns exactly its parent.
  • Concentration (empirical Bayes). Routes that differ get a small alpha, routes that don't get a large one; the guard (a roll seen only one way is pooled fully); no context levels keeps the default; distinct levels aren't fitted.
  • The shadow's gate. gate_open; runs through a closed gate don't count; a closed gate always gives otherwise; through the solver, no Black without investigating and helping.
  • First attempt. Each attempt is its own roll with a one-run prior (checked against the hand value); the givens and their published names; the solver's Black is much higher on a first attempt.
  • Bonds. can_bond (the Greens' Orange/Brown swoop-in, nothing else) and encounter odds count only possible bonds.
  • Random numbers. xorshift matches the JavaScript model's first value; Dirichlet draws average to the counts; lgamma matches Python's.

🤖 Generated with Claude Code

Part of #26: a read-through of `core/atlas/model.py` with a test for each piece, on small made-up datasets whose answers are worked out by hand in the comments. No bugs found; no code changes. `tests/core/test_model.py`, 20 tests: - **Back-off.** Counts at every context level, stopping at the first missing step; weights (reporting bias) scale counts and 0 drops a run; each level is shrunk toward the one above (e.g. East = [7, 4, 1, 1] / 13 with alpha 12); an unseen context returns exactly its parent. - **Concentration (empirical Bayes).** Routes that differ get a small alpha, routes that don't get a large one; the guard (a roll seen only one way is pooled fully); no context levels keeps the default; `distinct` levels aren't fitted. - **The shadow's gate.** `gate_open`; runs through a closed gate don't count; a closed gate always gives `otherwise`; through the solver, no Black without investigating and helping. - **First attempt.** Each attempt is its own roll with a one-run prior (checked against the hand value); the givens and their published names; the solver's Black is much higher on a first attempt. - **Bonds.** `can_bond` (the Greens' Orange/Brown swoop-in, nothing else) and encounter odds count only possible bonds. - **Random numbers.** xorshift matches the JavaScript model's first value; Dirichlet draws average to the counts; `lgamma` matches Python's. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
kathleen added 1 commit 2026-11-19 21:37:38 +00:00
The hierarchical back-off, the empirical-Bayes concentration and its one-outcome
guard, the shadow's gate (counting and solving), which bonds an encounter allows,
the first-attempt given with its token prior, and the reproducible random numbers.
Expected values are worked out by hand in the comments.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UCzTd31GphpMXDhQqWrCMQ
kathleen merged commit 44ccd7f760 into main 2026-11-19 21:41:30 +00:00
kathleen deleted branch planner/model-tests 2026-11-19 21:41:31 +00:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: DragonKind/threshing-atlas#49