Poker hand evaluating modules that provide fast enumerations.Both C Extension module it's pure python analogies are included.
Project description
This is a python library that provides routines for very fast poker hand comparisons to power hand match ups.
Pure python and c-extention modules are included. Using the cpoker module it should be easy to write python code that will, for example, quickly caluculate expected hand strength squared and opponent cluster hand strength (EHS2/OCHS).
Be aware that the main modules use a lookup table of over 30mb, which in the case of the pure python version can take up to a second to build. The rank lookup sceme uses 13 magic numbers attributed to the specialK blog, which I used to supplement my own algorithm. A pure python lite version is also include that leaves a small memory footprint and is still fast. A good use case might be where you can’t use third party modules and have limited resources, such as on a free google-app-engine site.
Sample
Cards are represented by intergers 0-51 and groups of cards are contained in lists. A Card class is provided for convenience. The pretty_args wrapper allows you to use standard card strings rather than Card objects or integers.
>>> from poker import cpoker
>>> from poker.utils import pretty_args
>>> #return the evs of a match between any number of hands
>>> enum = pretty_args(cpoker.full_enumeration)
>>> enum(["AsKd", "8c2s"])
[0.6753362720638392, 0.32466372793616083]
>>> enum(["AsKd", "7h 8h", "6c 6d"], "Kc 6h 9h")
[0.021040974529346623, 0.44518272425249167, 0.5337763012181617]
>>> # percentile on river vs all 990 hand combos
>>> pretty_args(cpoker.rivervalue)("As Kd", "Ks Qh Jc 8s 8d")
0.8585858585858586
Compile and Install
OSX -> Easiest is to install xcode command line tools. On Maverick you should be able to open a terminal and just type
$ xcode-select --install
On older versions you may have to download the entire Xcode from the app store.
Linux -> You just need python-dev and gcc and you should be good to go. ie. on debian/ubuntu:
$ sudo apt-get install gcc python-dev
Then in any case from the pokyr directory:
$ python setup.py install
or with pip
$ sudo easy_install pip $ sudo pip install pokyr
There is an issue with later versions of osx and Xcode 5.1. If you get the error:
clang: error: unknown argument: '-mno-fused-madd' [-Wunused-command-line-argument-hard-error-in-future]
you can try running this before setup.py:
$ export CFLAGS=-Qunused-arguments
Apple will hopefully fix this problem in a future release.
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
Built Distributions
Hashes for pokyr-0.1.macosx-10.9-intel.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | d1ea455a564385a0efb9bf5386e94094432c7fd56a074014d9b0026a46b315ee |
|
MD5 | eb2961c8354e20b616eef8fe7a8e108e |
|
BLAKE2b-256 | ab9394ef4e68d02b789a4e0c6745676e32358b88a87c3139b4738ac48faaf591 |