refactor(core): align Spider with upstream card_game idioms #162
Reference in New Issue
Block a user
Delete Branch "refactor/spider-upstream-idioms"
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?
Follow-up to #157, addressing the upstream author's review of the Spider core. Each point maps to one of the five critiques:
"invented its own RNG once again" — the inline SplitMix64 + Fisher-Yates is gone. Deals now go through
rand::rngs::StdRngseeded withseed_from_u64+SliceRandom::shuffle, byte-for-byte the same pattern asklondike::Klondike::with_seed.solitaire_coregains the exact rand dep klondike pins (0.10.1,default-features = false, features = ["std_rng"]) — already in the lockfile via klondike, so zero new transitive deps. Deals for a given seed change; Spider has no engine UI or persisted games yet, so nothing observable breaks."missing the quatisms ... everything being an enum" —
SpiderInstruction::Moveno longer carriesfrom: u8, to: u8, count: u8. It's nowMove(SpiderMove { from: SpiderTableau, run: RunLength, to: SpiderTableau })—Tableau1..Tableau10andRun1..Run13, each withITER_BEGIN/next()const iteration and anALLconst. Out-of-range piles and zero-card moves are unrepresentable. Rank math usesRank::checked_addinstead ofas u8 + 1."heap allocated Vecs instead of fixed size Stacks" —
build_deckreturnsStack<104>;possible_instructionsis nowSpiderIter::new().filter(is_instruction_valid)(theKlondikeIterpattern) instead of pushing into aVec. The only remaining Vecs are the test-layout helper params and theSpiderGameStatewrapper's collected return, which mirrorsGameState::possible_instructions."names functions randomly different from upstream" —
SpiderGame→Spider(matchesKlondike);tableau_face_up/_down→tableau_face_up_cards/tableau_face_down_cards(klondike's names);stock_len()→ astock()accessor;tableau_top_cardadded;with_rngadded alongsidewith_seed, same pair as upstream."wraps the session type to avoid exposing solve" —
SpiderGameState::session()now exposes the underlyingSession<Spider>, the same escape hatchGameState::session()provides. The solver was always reachable and budget-gated bySessionConfig; the wrapper no longer pretends otherwise.Tests: all 71 core tests green (rule tests rewritten against the enum types; the out-of-range/zero-count rejection test is now a note that those shapes are unrepresentable, plus a new exhaustive-iterator test). Full workspace green, clippy
-D warningsclean, fmt clean.🤖 Generated with Claude Code