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.2.0.tar.gz (57.5 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.2.0-cp312-cp312-manylinux_2_34_x86_64.whl (244.1 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

File details

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

File metadata

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

File hashes

Hashes for pyrust_poker-0.2.0.tar.gz
Algorithm Hash digest
SHA256 d7a84dedf8a8b797f604b90942c5bd9bce1d46e193327d9763bade851ea656f6
MD5 c7f4a4d08a9890a4094158e371e9108a
BLAKE2b-256 281131b1e467344b5527c0b1ecf5390877012768c4a4b8002fe1b488c4977828

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrust_poker-0.2.0-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 1a6a5e664403d83c12259042d2a05a94810dab4297b9b22f3b33ef17e2662d57
MD5 616603abb27f02841457b10be59f18e2
BLAKE2b-256 b989c55e604271927377a0f866d3ef6a77416f632f194996c166581354acc33f

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