seed_from_u64 (#7)

Closes #5

Reviewed-on: #7
Co-authored-by: Rhys Lloyd <krakow20@gmail.com>
Co-committed-by: Rhys Lloyd <krakow20@gmail.com>
This commit was merged in pull request #7.
This commit is contained in:
2026-05-18 19:17:11 +00:00
committed by Quaternions
parent 25760d19a1
commit a28a965d12
6 changed files with 21 additions and 10 deletions
+1
View File
@@ -6,3 +6,4 @@ edition = "2024"
[dependencies]
card_game = { version = "0.1.0", path = "../card_game" }
klondike = { version = "0.1.0", path = "../klondike" }
rand = { version = "0.10.1", default-features = false, features = ["thread_rng"] }
+9 -2
View File
@@ -255,10 +255,14 @@ fn get_good_move(state: &Klondike) -> Option<KlondikeInstruction> {
}
fn main() -> Result<(), std::io::Error> {
let mut session = Session::new_default(Klondike::new_random());
use rand::RngExt;
let mut rng = rand::rng();
let mut seed = rng.random();
let mut session = Session::new_default(Klondike::with_seed(seed));
let mut input = String::new();
loop {
// display stats
println!("seed: {seed} ");
println!("{}", Displayed(session.stats()));
// display game
println!("{}", Displayed(session.state()));
@@ -273,7 +277,10 @@ fn main() -> Result<(), std::io::Error> {
// run game
match instruction {
SessionInstruction::New => session = Session::new_default(Klondike::new_random()),
SessionInstruction::New => {
seed = rng.random();
session = Session::new_default(Klondike::with_seed(seed))
}
SessionInstruction::Undo => session.undo(),
SessionInstruction::Exit => break Ok(()),
SessionInstruction::Hint => {