fix readme
This commit is contained in:
+9
-9
@@ -6,20 +6,21 @@ Card Game
|
|||||||
## Example
|
## Example
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
use card_game::Rng;
|
use card_game::{Session, Game};
|
||||||
use card_game::card_game::{Session, Game};
|
use klondike::Klondike;
|
||||||
use card_game::klondike::Klondike;
|
|
||||||
|
|
||||||
// create game session
|
// create game session
|
||||||
let game = Klondike::new_random();
|
let game = Klondike::with_seed(123);
|
||||||
let mut session = Session::new_default(game);
|
let mut session = Session::new_default(game);
|
||||||
|
|
||||||
// is winnable
|
// play game a bit
|
||||||
let is_winnable = session.is_winnable().is_some();
|
|
||||||
|
|
||||||
// play game
|
|
||||||
while let Some(instruction) = session.possible_instructions().next() {
|
while let Some(instruction) = session.possible_instructions().next() {
|
||||||
session.process_instruction(instruction);
|
session.process_instruction(instruction);
|
||||||
|
|
||||||
|
// quit after 1000 moves
|
||||||
|
if 1000 < session.stats().stats().moves() {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// did win
|
// did win
|
||||||
@@ -30,7 +31,6 @@ for (i, instruction) in session.history().iter().enumerate() {
|
|||||||
println!("move {i} = {instruction:?}");
|
println!("move {i} = {instruction:?}");
|
||||||
}
|
}
|
||||||
|
|
||||||
println!("is_winnable = {is_winnable}");
|
|
||||||
println!("is_win = {is_win}");
|
println!("is_win = {is_win}");
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user