poker: The Poker Evaluation Crate
poker is a Rust crate for the speedy evaluation and comparison of poker hands.
It it based on the treys Python package
and the algorithms found within, with mild adaptations and some personal touches
to try to make it as idiomatic as possible in Rust.
use ;
Using poker
Add poker to the dependencies in your Cargo.toml file:
[]
= "0.4"
Features
poker currently has two features. One depends on the
rand crate, in order to shuffle generated
decks. This is enabled by default.
The second feature, which is also not enabled by default is static_lookup.
Enabling this feature opens up the poker::evaluate::static_lookup module,
which contains the free evauluate function. It works similar to
Evaluator::evaluate, but semantically it uses a static data structure that
does not rely on heap allocations.
There is no real benefit to using the feature yet, but it is an experimental
first step for possible no_std support in the future. To enable this feature:
[]
# To use without `rand`, add `default-features = false`
= { = "0.4", = ["static_lookup"] }
A Note on Performance
For readability, the #[inline] attribute has been removed from function
declarations. In order to ensure rustc can make appropriate inlining and
optimization decisions, remember to use link-time optimization in your release
builds. This comes at the cost of slower compilation times. In your
Cargo.toml:
[]
# ...
= true # the default is false!
Examples
poker includes two fun builtin examples: poker-repl and jacks-or-better.
poker-repl is a repl-like environment when you can evaluate different poker
hands. jacks-or-better is a terminal re-creation of the Jacks or Better video
poker game. Payouts based on
this image.
Rules for the game can be found
here.
DISCLAIMER
The
jacks-or-betterexample from thepokercrate has themes of gambling using a currency calledcredits. This program is meant for example purposes only to illustrate one possible use of this library. There is no risk associated with running the example as it can be terminated and restarted at any time.Please be aware of the financial risk of real gambling.
You can install these examples through cargo by running the following command:
# Then you can run the programs, assuming they were installed somewhere in $PATH
You can also run the examples through a cloned git repository.
License
Licensed under the MIT license (LICENSE.txt or http://opensource.org/licenses/MIT).