Skip to content

Add Pyramid game variant - #47

Merged
austin-smith merged 4 commits into
mainfrom
pyramid-variant
Jul 13, 2026
Merged

austin-smith merged 4 commits into
mainfrom
pyramid-variant

Conversation

@austin-smith

Copy link
Copy Markdown
Owner

Closes #22

What Changed

  • New Pyramid variant: 28-card seven-row pyramid, draw-one stock with two recycles (three passes), remove exposed pairs totaling 13 (Kings alone), cover-pairs allowed, win by clearing the pyramid.
  • Engine: dedicated pyramid/discard/wasteRecyclesUsed state fields with saved-game back-compat, new Selection/Destination cases for pair removal, variant-aware win detection, all mutation through one pure PyramidGameRules.stateByApplying shared by the session and the move advisor.
  • Solver-backed hints: PyramidPlanner runs an exact two-stage search over a collision-free 59-bit packed position — weighted A* with an admissible heuristic and a partner-count prune that can prove deals unwinnable, then a max-clear stage so lost deals still get best-effort hints (silence is reserved for provably futile positions). Cached and ratcheted through HintPlanner like Yukon.
  • UI: new triangular board view with exposure-driven interaction, stock/waste reuse from Klondike, inert discard pile, win cascade generalized to launch from the discard.
  • Also fixes a latent restore bug: loading a game whose variant differs from the stored setting re-dealt over the restored board after hydration.
  • Pyramid is wired into tools/hint-probe (deal, hint follower, random control) per its acceptance recipe; the probe's state fingerprint gained a pyramid/discard section separator to avoid false revisit reports.

Why

Issue #22 requests the Pyramid variant. The sources it links disagree on rules; this implements the common digital rule set (pyramid-only win, three passes, cover-pairs) — choices and rationale are documented in docs/solitaire-rules-pyramid.md.

Validation

  • 180 unit tests pass (55 new across geometry, rules, session, persistence, and planner, with probe-verified pinned seeds).
  • Hint-probe ledger: following every hint wins 80.2% of 500 seeded deals vs a 15.2% random-control floor, zero stalemate-loops, median 67-move wins. All existing variants reproduce their ledger figures exactly, confirming the shared-core changes are behaviorally inert for them.
  • Solver verdict sweep at default budget: 79.5% of deals proved winnable, 0.8% proved unwinnable, 19.8% undecided at budget (still served best-effort lines).
  • Verified on iPhone simulator end to end: staged fixture restore, pair/King removal with scoring, tap-select-then-tap-partner, hint highlight, stock draw and recycle limits, undo, and the win cascade.

UI Changes

New Pyramid board (seven overlapping rows with per-card drop targets), Pyramid top row (stock, single-card waste, discard pile), Pyramid entries in Settings, Statistics, and Rules & Scoring, and an App Store screenshot fixture.

@austin-smith austin-smith changed the title Add Pyramid game variant with solver-backed hints Add Pyramid game variant Jul 12, 2026
# Conflicts:
#	ComputerSolitaire/Animation/WinCelebrationController.swift
#	ComputerSolitaire/Fixtures/ScreenshotFixtures.swift
#	ComputerSolitaire/Game/Klondike/AutoFinishPlanner.swift
#	ComputerSolitaire/Game/Klondike/GameSessionKlondike.swift
#	ComputerSolitaire/Game/Shared/AutoMoveAdvisor.swift
#	ComputerSolitaire/Game/Shared/GamePersistence.swift
#	ComputerSolitaire/Game/Shared/GameRulesShared.swift
#	ComputerSolitaire/Game/Shared/GameSession.swift
#	ComputerSolitaire/Game/Shared/GameState.swift
#	ComputerSolitaire/Game/Shared/GameVariant.swift
#	ComputerSolitaire/Game/Shared/HintAdvisor.swift
#	ComputerSolitaire/Game/Shared/Scoring.swift
#	ComputerSolitaire/Game/Shared/TapMovePolicy.swift
#	ComputerSolitaire/Views/RulesAndScoringView.swift
#	ComputerSolitaire/Views/Shared/BoardViews.swift
#	ComputerSolitaire/Views/StatisticsView.swift
#	ComputerSolitaireTests/Shared/ScreenshotFixtureTests.swift
#	README.md
#	tools/hint-probe/README.md
#	tools/hint-probe/main.swift
#	tools/hint-probe/run.sh
@austin-smith

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: ad54077add

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@austin-smith

Copy link
Copy Markdown
Owner Author

@codex review

1 similar comment
@austin-smith

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 👍

Reviewed commit: 9d2883d953

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@austin-smith
austin-smith merged commit 77fdb34 into main Jul 13, 2026
2 checks passed
@austin-smith
austin-smith deleted the pyramid-variant branch July 13, 2026 00:52
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 Pyramid game variant

1 participant