Undo penalty deducted from pre-move score instead of post-move score #12

Closed
opened 2026-05-19 18:43:04 +00:00 by funman300 · 0 comments
Owner

File

solitaire_core/src/game_state.rs lines 207–211, 405–411

Description

push_snapshot() saves self.score before the move is applied (line 210). On undo, the restored score is snapshot.score + scoring_undo() — i.e., pre_move_score - 15.

Example: player has 20 points, moves a card to foundation (+10 → 30), then undoes. Snapshot holds 20. Undo produces max(0, 20 - 15) = 5. Correct result is max(0, 30 - 15) = 15. The player loses 10 extra points on every undo that preceded a scoring move.

Correct Windows XP Klondike scoring deducts -15 from the current post-move score, not the pre-move snapshot.

Fix

Apply the undo penalty to the current score at undo time rather than restoring the snapshot score and applying the penalty to that.

## File `solitaire_core/src/game_state.rs` lines 207–211, 405–411 ## Description `push_snapshot()` saves `self.score` **before** the move is applied (line 210). On undo, the restored score is `snapshot.score + scoring_undo()` — i.e., `pre_move_score - 15`. Example: player has 20 points, moves a card to foundation (+10 → 30), then undoes. Snapshot holds 20. Undo produces `max(0, 20 - 15) = 5`. Correct result is `max(0, 30 - 15) = 15`. The player loses 10 extra points on every undo that preceded a scoring move. Correct Windows XP Klondike scoring deducts -15 from the **current** post-move score, not the pre-move snapshot. ## Fix Apply the undo penalty to the **current** score at undo time rather than restoring the snapshot score and applying the penalty to that.
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: funman300/Ferrous-Solitaire#12