refactor: slim solver to card_game-native types
Per Rhys: card_game's solver is the real engine, so drop the redundant
adapter types in solitaire_data::solver rather than maintain a parallel
verdict/config/move vocabulary.
- Delete SolverResult, SolverConfig, SolverMove, and snapshot_to_solver_move.
The verdict now reads straight off card_game's return:
Ok(Some(instr)) = winnable (first move on the path)
Ok(None) = provably unwinnable
Err(_) = inconclusive (budget exceeded)
- SolveOutcome is now Result<Option<KlondikeInstruction>, SolveError>.
- try_solve / try_solve_from_state take plain (moves_budget, states_budget)
u64s; add DEFAULT_SOLVE_{MOVES,STATES}_BUDGET consts.
- snapshot_to_solver_move duplicated core's GameState::instruction_to_move,
so make that pub and have the hint convert the first-move instruction to
highlighted (from, to) piles through it. Re-export KlondikeInstruction
from solitaire_core.
- HintSolverConfig now holds { moves_budget, states_budget } instead of
wrapping the deleted SolverConfig.
- Update consumers: pending_hint, play_by_seed (verdict badge), game_plugin
(choose_winnable_seed), input_plugin, hud_plugin, and the gen_seeds /
gen_difficulty_seeds asset tools.
solver.rs drops 274 -> 140 lines. cargo test --workspace and
cargo clippy --workspace --all-targets -- -D warnings pass.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -826,7 +826,14 @@ impl GameState {
|
||||
}
|
||||
}
|
||||
|
||||
fn instruction_to_move(
|
||||
/// Converts an upstream [`KlondikeInstruction`] into the engine's
|
||||
/// `(from, to, count)` pile-move form, resolving multi-card tableau moves
|
||||
/// against the live board. Returns `None` for no-op instructions
|
||||
/// (foundation→foundation, or a tableau move of zero cards).
|
||||
///
|
||||
/// Used by the hint system to render a solver's recommended first move,
|
||||
/// and internally by [`Self::possible_instructions`].
|
||||
pub fn instruction_to_move(
|
||||
&self,
|
||||
instruction: KlondikeInstruction,
|
||||
) -> Option<(KlondikePile, KlondikePile, usize)> {
|
||||
|
||||
@@ -12,7 +12,7 @@ pub mod klondike_adapter;
|
||||
// re-exported — they are only used internally in `klondike_adapter.rs` and do
|
||||
// not appear in any public method signature.
|
||||
pub use card_game::{Card, Session};
|
||||
pub use klondike::{Foundation, Klondike, KlondikePile, Tableau};
|
||||
pub use klondike::{Foundation, Klondike, KlondikeInstruction, KlondikePile, Tableau};
|
||||
pub use klondike_adapter::DrawMode;
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
Reference in New Issue
Block a user