Crates.io | espada |
lib.rs | espada |
version | 0.3.1 |
source | src |
created_at | 2024-03-08 01:51:40.629183 |
updated_at | 2024-03-28 06:33:32.808206 |
description | Texas Hold'em poker odds evaluator |
homepage | |
repository | https://github.com/axross/espada |
max_upload_size | |
id | 1166424 |
size | 1,106,711 |
Texas Hold'em poker odds evaluator.
Add this to Cargo.toml:
[dependencies]
espada = "0.1"
In your main.rs
or lib.rs
, you can use this as:
use espada::evaluator::FlopExhaustiveEvaluator;
use espada::hand_range::HandRange;
fn main() {
let board = [
Some(Card::new(Rank::Queen, Suit::Spade)),
Some(Card::new(Rank::Eight, Suit::Diamond)),
Some(Card::new(Rank::Deuce, Suit::Heart)),
None,
None
];
let players = vec!["JJ+".parse().unwrap(), "A2s+".parse().unwrap()];
let evaluator = FlopExhaustiveEvaluator::new(&board, &players);
let mut materialized = 0_u32;
let mut wins = vec![0_f32; players.len()];
for showdown in evaluator {
for (player_index, player) in showdown.players().into_iter().enumerate() {
if player.is_winner() {
wins[player_index] += 1.0 / showdown.winner_len() as f32
}
}
materialized += 1;
}
for (player_index, _) in players.into_iter().enumerate() {
println!(
"player {}: {:.2}% eq",
player_index,
wins[player_index] / materialized as f32 * 100.0
);
}
}