4 releases (2 breaking)
0.3.1 | Mar 28, 2024 |
---|---|
0.3.0 | Mar 22, 2024 |
0.2.0 | Mar 20, 2024 |
0.1.0 | Mar 8, 2024 |
#332 in Math
735KB
13K
SLoC
♠️ espada
Texas Hold'em poker odds evaluator.
Quickstart
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
);
}
}
License
Dependencies
~2.2–3.5MB
~56K SLoC