espada

Crates.ioespada
lib.rsespada
version0.3.1
sourcesrc
created_at2024-03-08 01:51:40.629183
updated_at2024-03-28 06:33:32.808206
descriptionTexas Hold'em poker odds evaluator
homepage
repositoryhttps://github.com/axross/espada
max_upload_size
id1166424
size1,106,711
Kohei (axross)

documentation

https://docs.rs/espada

README

♠️ espada

Texas Hold'em poker odds evaluator.

https://crates.io/crates/espada Recent Downloads License

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

Here

Commit count: 13

cargo fmt