Game Over False Positive #2
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This game showed the game over screen:
but stack 4 (6 of hearts) can be moved onto stack 2 (7 of spades) like so:
Fix Applied ✓
Root cause:
has_legal_moves()ingame_plugin.rsonly checkedt.cards.last()— the top face-up card — of each tableau column as a potential move source. In Klondike any face-up card can anchor a movable run, so mid-column cards were invisible to the check. A position where the only legal move was a non-top face-up card would incorrectly be declared a softlock and trigger the game-over screen.Two secondary issues were also present:
can_place_on_foundationdoes not gate onface_up, this could produce false positives for unplayable cards.Fix (commit
33fb962):t.cards.iter().filter(|c| c.face_up)— all face-up cards, not just the top one.A new regression test
has_legal_moves_detects_non_top_face_up_card_as_sourceis added: it builds a board where a non-top Queen is the only card that can legally move (onto a King), and assertshas_legal_movesreturnstrue. The existing softlock test (has_legal_moves_returns_false_when_stock_only_holds_unplayable_cards) continues to pass.