Block a user
card_game (0.1.0)
Published 2026-05-16 20:35:48 +00:00 by Quaternions
Installation
[registry]
default = "gitea"
[registries.gitea]
index = "sparse+https://git.aleshym.co/api/packages/Quaternions/cargo/" # Sparse index
# index = "https://git.aleshym.co/Quaternions/_cargo-index.git" # Git
[net]
git-fetch-with-cli = truecargo add card_game@0.1.0About this package
Card game library.
Card Game
card_game is a library to implement card games. Mainly interesting for the Game trait and the Session type. Contains klondike as the reference implementation.
Example
use card_game::Rng;
use card_game::card_game::{Session, Game};
use card_game::klondike::Klondike;
// create game session
let game = Klondike::new_random_default();
let mut session = Session::new(game);
// is winnable
let is_winnable = session.is_winnable().is_some();
// play game
while let Some(instruction) = session.possible_instructions().next() {
session.process_instruction(instruction);
}
// did win
let is_win = session.is_win();
// print session history
for (i, instruction) in session.history().iter().enumerate() {
println!("move {i} = {instruction:?}");
}
println!("is_winnable = {is_winnable}");
println!("is_win = {is_win}");
License
Licensed under either of Apache License, Version 2.0 or MIT license at your option.Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
Dependencies
| ID | Version |
|---|---|
| arrayvec | ^0.7.6 |
| rand | ^0.10.1 |
Keywords
card
cards
solitaire
klondike
Details
2026-05-16 20:35:48 +00:00
Assets (1)
Versions (2)
View all
Cargo
0
Rhys Lloyd <krakow20@gmail.com>
MIT OR Apache-2.0
16 KiB
card_game-0.1.0.crate
16 KiB