Skip to content

Add Canfield game variant - #63

Merged
austin-smith merged 1 commit into
mainfrom
canfield-variant
Jul 14, 2026
Merged

austin-smith merged 1 commit into
mainfrom
canfield-variant

Conversation

@austin-smith

Copy link
Copy Markdown
Owner

Closes #51.

What Changed

  • Adds Canfield as the tenth game variant, implementing the strict classic rules: a thirteen-card reserve whose exposed card is always playable and which must fill any empty tableau pile at once; four foundations built up by suit from a dealt base rank, wrapping King to Ace; a four-pile tableau built down in alternating colors, wrapping Ace to King, with whole-pile moves only; a draw-three stock with unlimited redeals; and locked foundations. Spaces fill only from the waste once the reserve is out, and the exposed waste top stays playable after a spent fan.
  • GameState gains a reserve pile (back-compatible decoding) and Selection.Source a .reserve case; the shared foundation rule gains a state-aware path for Canfield's base-rank starts. Every other variant's persistence rules now reject cards stranded in the reserve field, mirroring the existing foreign-field guards.
  • Hints come from CanfieldPlanner, a bounded best-first search over moves and stock taps with a recycle-aware position hash, followed as cached improving lines. Because a tap on the spent stock recycles, an exhausted search is a proof the game is over, so hints go silent there instead of churning a dead stock; only truncated verdicts fall back to a tap.
  • The compulsory reserve fill scores like any reserve-to-tableau play, matching how Klondike's compulsory flip scores through its automatic path.
  • Moves recycleWaste from the Klondike session file to the shared stock section now that two variants recycle, and fixes a macOS Game menu crash assembling a Character("10") keyboard shortcut for a tenth variant (⌘1⌘9, then ⌘0).
  • Rules doc (docs/rules/canfield.md), README rows, in-app rules/terms/scoring, statistics, screenshot fixture, and the hint-probe wiring and ledger row.

Why

Canfield (Demon in Britain) is a classic reserve-based patience the app was missing (#51). The implementation follows the printed classic sources over the relaxations common in software — whole-pile moves only, no worrying back, compulsory reserve fills — with the deliberate choices documented in the rules doc.

Validation

  • Full test suite passes on macOS, including four new Canfield suites (rules wrap edges, whole-pile pickup, space-fill gating, reserve refill and scoring, recycling, planner line following, persistence corruption) and a shared test proving every other variant rejects reserve-stranded cards.
  • Hint probe, 500 seeded deals: 25.0% following every hint vs 1.2% random control, zero stalemate loops, zero position revisits (gated), zero action caps — every loss an exhaustively-proven deadlock. A full all 500 study reproduces every existing variant's ledger figure exactly, so the shared-code changes are behavior-preserving outside Canfield.
  • Verified in the iOS simulator: deal layout, draw-three fan, reserve tap auto-move with reveal and count, base-rank foundation placeholders, and the game-mode picker thumbnail.

UI Changes

  • New Canfield board: Klondike-shaped top row (stock, fanned waste, four foundations) with the reserve in the tableau band at the left column, its count in felt-set type below, and the four piles aligned under the foundations.
  • Empty foundation placeholders show the dealt base rank in Canfield instead of the Ace glyph.
  • Game-mode picker gains a Canfield row with a mini-board silhouette; rules/terms/scoring and statistics screens gain Canfield content.

strict classic rules: a thirteen-card reserve with compulsory space
fills, foundations built up by suit from a dealt base rank with wrap in
both directions, whole-pile tableau moves only, and a draw-three stock
with unlimited redeals onto locked foundations. hints follow cached
improving lines from a bounded best-first planner whose exhausted
search — taps and recycles included — proves a dead position; the probe
baseline is 25.0% following every hint vs 1.2% random over 500 deals
with zero loops and zero revisits. every other variant's persistence
rules now reject cards stranded in the new reserve field, and the macos
game menu no longer crashes assembling a digit shortcut for a tenth
variant.
@austin-smith
austin-smith merged commit aa333c1 into main Jul 14, 2026
2 checks passed
@austin-smith
austin-smith deleted the canfield-variant branch July 14, 2026 02:14
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.

Add Canfield game variant

1 participant