AyaPoker
AyaPoker is a Rust library for fast poker hand evaluation based on the OMPEval C++ hand evaluator, with support for most popular poker variants.
Features
- Can be used to rank hands from standard poker, ace-to-five lowball, deuce-to-seven lowball, six-or-better (short-deck), Omaha, Omaha Hi/Lo, Badugi or Baduci.
- Can evaluate hands with 0 to 7 cards, with the missing cards counting as the worst possible kickers, allowing for use in stud poker games.
- Uses compile-time generated perfect hash function lookup tables for excellent runtime performance and fast initialization.
- Has extensive suite of tests to ensure correct implementation of the hand ranking rules for each variant.
Flags
This crate has the following Cargo features:
std
: By default,aya_poker
is a!#[no_std]
crate, but can be compiled with thestd
feature in order to allow the initialization ofDeck
s with system-generated random seeds.colored
: Usecolored
to display cards and hands in color.colored-4color
: Same ascolored
, but using a four-color deck.
Example
use Ordering;
use ;
const SEED: u64 = 42;
const SAMPLE_SIZE: usize = 100_000;
Performance
All of the following benchmarks were run on an AMD Ryzen 5 2600 and compiled
with lto = "thin"
.
Standard / Ace-to-Five Lowball / Deuce-to-Seven Lowball / Six-plus
Standard poker, ace-to-five lowball, and six-or-better (short-deck) poker are the
fastest since they represent the ideal scenario for the lookup table approach:
they only require computing the Hand
value, and then using it to perform a
single lookup.
Deuce-to-seven lowball is slightly slower for more than 5 cards due to having to iterate over non-flush card combinations.
Badugi / Baduci
Badugi / Baduci evaluation is much slower since at the moment AyaPoker only has lookup tables for rank combinations with non-overlapping suits, and thus requires a number of lookups for each such combination of cards.
Omaha
AyaPoker does not include any lookup tables for Omaha since they are too large to compute at compile time, but, due to the excellent performance of the lookup tables for standard and ace-to-five lowball poker, is still able to achieve decent performance for Omaha by iterating over all 5-card combinations.
License
Licensed under any of:
- Apache License, Version 2.0, (LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or https://opensource.org/licenses/MIT)
- zlib License (LICENSE-ZLIB or https://opensource.org/license/zlib/)
by your choice.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be multi-licensed as above, without any additional terms or conditions.