Skip to main content

Rust poker library

Project description

RustPoker

Build Status docs.rs crates.io

A poker library written in rust.

  • Multithreaded range vs range equity calculation
  • Fast hand evaluation
  • Efficient hand indexing

Installation

Add this to your Cargo.toml:

[dependencies]
rust_poker = "0.1.13"

Note: The first build of an application using rust_poker will take extra time to generate the hand evaluation table

Developing Bindings

Use virtual env virtualenv .venv.

Enable the envirnmoent source .venv/bin/activate

Run maturin develop to create ptyhon lib with bindings, it will automatically put it inside the python packages dir.

To test out point the ipynb notebooks kernel to virtualenv and then just run the package.

To install pytohn packages pip install poetry && poetry install --no-root

Hand Evaluator

Evaluates the strength of any poker hand using up to 7 cards.

Usage

use rust_poker::hand_evaluator::{Hand, CARDS, evaluate};
// cards are indexed 0->51 where index is 4 * rank + suit
let hand = Hand::empty() + CARDS[0] + CARDS[1];
let score = evaluate(&hand);
println!("score: {}", score);

Equity Calculator

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

Usage

use rust_poker::hand_range::{HandRange, get_card_mask};
use rust_poker::equity_calculator::approx_equity;
let ranges = HandRange::from_strings(["AK,22+".to_string(), "random".to_string()].to_vec());
let public_cards = get_card_mask("2h3d4c".to_string());
let stdev_target = 0.01;
let n_threads = 4;
let equities = approx_equity(&ranges, public_cards, n_threads, stdev_target);
println!("player 1 equity: {}", equities[0]);

Credit

The hand evaluator and equity calculator library is a rust rewrite of zekyll's C++ equity calculator, OMPEval

License

This project is MIT Licensed

Copyright (c) 2020 Kyle Murphy

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyrust_poker-0.1.14.tar.gz (55.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyrust_poker-0.1.14-cp312-cp312-manylinux_2_34_x86_64.whl (243.4 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

File details

Details for the file pyrust_poker-0.1.14.tar.gz.

File metadata

  • Download URL: pyrust_poker-0.1.14.tar.gz
  • Upload date:
  • Size: 55.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.7.8

File hashes

Hashes for pyrust_poker-0.1.14.tar.gz
Algorithm Hash digest
SHA256 1822ec0aeb09780077ff9256425d379c942aaa414379e25c5aa293a3e6613f9e
MD5 e92e0ad48ae1871c515998b04a3dc9a7
BLAKE2b-256 414c0cee3328e1e7e1c9ebc0828cc4c31571f9410d53512ba394bc8d47d2784b

See more details on using hashes here.

File details

Details for the file pyrust_poker-0.1.14-cp312-cp312-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for pyrust_poker-0.1.14-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 a30a0d865f5154cc727b22655b53e3f0eea4c6a5353033b0c7fc12e5f38cbbc6
MD5 c9ff95d1b102169d1a587ce4d47709e2
BLAKE2b-256 f6ec0d246acd30d191c61bebed417e7ee184a7f415e5253250a59862c2af68a6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page