Skip to content

carrying the running score into the result#93

Merged
andy-k merged 2 commits into
mainfrom
carrying-the-running-score-into-the-result
Jul 14, 2026
Merged

carrying the running score into the result#93
andy-k merged 2 commits into
mainfrom
carrying-the-running-score-into-the-result

Conversation

@andy-k

@andy-k andy-k commented Jul 14, 2026

Copy link
Copy Markdown
Owner

Summary

the endgame and pre-endgame (PEG) solvers only value the tiles left to play from here; they know nothing of each side's score so far. because the CLI took no score input, its printed win/draw/loss for the PEG case was actually judging only the rest of the game, so a mover already losing by a wide margin on the board could be told "win" for a positive rest-of-game value, which is not the same as winning the actual game. this PR adds an optional fourth CLI argument, score_diff (the mover's current score minus the opponent's, default 0), and threads it into the value before any win/draw/loss decision, so the printed result reflects the whole game rather than just its tail. the accompanying lab/endgame.txt doc is updated to describe carrying the running score into the result.

Root cause

the solvers only ever value the remaining tiles and never saw each side's running score. the CLI passed no score in, so the PEG win/draw/loss judged only the rest of the game -- a mover losing by a wide margin on the board could be reported as a "win" purely from a positive rest-of-game value.

Changes

  • add an optional fourth CLI argument, score_diff (mover's current score minus opponent's, default 0)
  • solve_peg_one_in_bag now takes a scaled score_diff and adds it to every hypothesis's margin before aggregating, so win_pct and expected_margin reflect the whole game
  • the plain empty-bag branch prints a new line, current score plus the solver's own value; evaluate() now returns that value instead of discarding it (a pure refactor of its existing return path)
  • update lab/endgame.txt to describe carrying the running score into the result

Correctness

with the default score_diff = 0 the output is byte-identical to before this PR for every case except the one new printed line and the demo's own new line in the plain branch; the demo is otherwise untouched.

andy-k added 2 commits July 12, 2026 04:18
The endgame and PEG solvers only ever value the tiles left to play from
here -- they know nothing of each side's score so far. The command
line took no score input, so its printed win/draw/loss for the PEG
case was actually judging only the rest of the game: a mover already
losing by a wide margin on the board could be told "win" for a
positive rest-of-game value, which is not the same as winning the
actual game.

Add an optional fourth CLI argument, score_diff (the mover's current
score minus the opponent's, default 0), and thread it into the value
before any win/draw/loss decision. solve_peg_one_in_bag now takes a
scaled score_diff and adds it to every hypothesis's margin before
aggregating, so win_pct and expected_margin already reflect the whole
game, not just its tail. The plain empty-bag branch gains a new
printed line, current score plus the solver's own value, following the
same convention (evaluate() now returns that value instead of
discarding it, a pure refactor of its existing return path).

The default (score_diff = 0) is byte-identical to before this PR for
every case except the one new printed line and the demo's own new line
in the plain branch; the demo itself is otherwise untouched.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@andy-k
andy-k merged commit 974a7cb into main Jul 14, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant