Crates.io | pkr |
lib.rs | pkr |
version | 0.1.1 |
source | src |
created_at | 2023-05-31 21:19:57.798754 |
updated_at | 2023-05-31 21:24:44.286025 |
description | A library for evaluating poker hands |
homepage | |
repository | |
max_upload_size | |
id | 879160 |
size | 93,020 |
"pkr" is a Rust library that provides basic components to model and evaluate a poker game. It includes basic entities like Card, Rank, Suit, Deck and Hand along with functionalities to shuffle and deal cards. Furthermore it provides a set of tools for creating and evaluating poker hands. The library has been built with efficiency in mind, with performance critical components written in a way to minimize unnecessary computation.
You can download and use this library in your Rust project by adding the
following to your Cargo.toml
:
[dependencies]
pkr = "0.1.1"
Create a Hand struct:
use pkr::hand::Hand;
hand1 = Hand::new_from_str("Ts Js Qs Ks As").unwrap();
This creates a Royal Flush hand.
Once you have a Hand you can evaluate its score:
let score1 = hand1.get_score();
This returns an u32 score representing the value of the hand according to the poker rules and makes it comparable:
hand2 = Hand::new_from_str("As Ad Ah Ac Ks").unwrap();
score2 = hand2.get_score();
assert!(score1 > score2);
Please note that this library does not handle game progression (yet) - it simply provides a way to evaluate poker hands.
This project is licensed under the GNU General Public License v3.0.