carrying the running score into the result#93
Merged
Conversation
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]>
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
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.