fix: enforce must-use-larger-die at turn start instead of after execution#131
Merged
Conversation
…tion When only one die can be played and both dice had moves from the turn-start board, the rules require the larger die. pureMove rejected the smaller die after execution, but Play.initialize still offered it as a ready move. A robot (or human) picking the smaller die had every turn attempt rejected, freezing the game in 'moving'. Production game 2d98cf14-e262-433c-baf5-95a2f878311d: one checker on the 2-point, 14 off, roll [3,5]. Either die bears off. GNU's bearoff hint carries no die; the AI matcher took the first ready move (die 3) and MustUseLargerDieError fired on every retry. - Play.initialize: convert smaller-die ready moves to completed no-moves when maxDiceUsable === 1 and both dice were playable - planMoveExecution: prefer the larger ready die for plays persisted before this fix (stale plays loaded from the database) - pureMove validation kept as backstop Bump to 1.0.2.
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.
Problem
Production game
2d98cf14-e262-433c-baf5-95a2f878311dfroze instateKind: 'moving'on the final play. The robot had one checker on its 2-point, 14 off, rolled [3,5]. Either die bears off the last checker, somaxDiceUsable = 1and both dice were playable at turn start.PR #129 added the must-use-larger-die validation in
Play.pureMove, which rejects the smaller die after execution — butPlay.initializestill offered the smaller-die move as ready. GNU's bearoff hint carries no die value, the AI matcher took the first ready move (die 3, roll order), andMustUseLargerDieErrorfired on every retry.RobotActionProcessorswallows robot-turn errors, so the game was never persisted and stayed stuck. Humans hit the same path:planMoveExecutionusesreadyMoves[0].dieValue.Fix
Play.initialize: whenmaxDiceUsable === 1and ≥2 distinct die values were playable at start, convert smaller-die ready moves to completed no-moves — the option the rules forbid is never offered.planMoveExecution: when no explicit die was requested and the larger die is mandatory, prefer the largest ready die — heals stale plays persisted before this fix.pureMovevalidation kept as defensive backstop.Tests