Crates.io | pokers |
lib.rs | pokers |
version | 0.5.1 |
source | src |
created_at | 2024-05-06 00:34:38.652837 |
updated_at | 2024-07-27 23:02:27.030005 |
description | Rust Poker Library |
homepage | |
repository | https://github.com/EddieMataEwy/pokers |
max_upload_size | |
id | 1230656 |
size | 880,098 |
A poker library written in rust.
Multithreaded range vs range equity calculation
Fast hand evaluation
Efficient hand indexing
Individual hand and combo results
Add this to your Cargo.toml
:
[dependencies]
pokers = "0.5.1"
Evaluates the strength of any poker hand using up to 7 cards.
use pokers::{Hand, CARDS};
// cards are indexed 0->51 where index is 4 * rank + suit
let hand = Hand::empty() + CARDS[0] + CARDS[1];
let score = hand.evaluate();
println!("score: {}", score);
Calculates the range vs range equities for up to 6 different ranges specified by equilab-like range strings. Supports monte-carlo simulations and exact equity calculations
use std::sync::{atomic::AtomicBool, Arc};
use pokers::{HandRange, get_card_mask};
use pokers::approx_equity;
let ranges = HandRange::from_strings(["AK,22+".to_string(), "AA,KK,QQ@50".to_string()].to_vec());
let board_mask = get_card_mask("2h3d4c");
let dead_mask = get_card_mask("");
let cancel_token = Arc::new(AtomicBool::new(false));
let callback = |x: u8| {
print!("\rProgress: {x}%");
io::stdout().flush().unwrap();
};
let std_dev_target = 0.01;
let n_threads = 4;
let result = approx_equity(&ranges, board_mask, dead_mask, n_threads, std_dev_target, cancel_token, callback).unwrap();
let equities = result.equities;
println!("player 1 equity: {}", equities[0]);
This library is a fork of Kyle Murphy's rust rewrite (rust_poker) of zekyll's C++ equity calculator, OMPEval. Differences with the original repo:
This project is MIT Licensed
Copyright (c) 2020 Kyle Murphy
Copyright (c) 2024 Eduardo Mata Ewy