Skip to main content

A poker hand evaluation and equity calculation library

Project description

https://travis-ci.org/julianandrews/pyeval7.svg?branch=master

Python Texas Hold’em hand evaluation library based on Anonymous7’s codebase which is in turn based on Keith Rule’s hand evaluator (which you can see here). Eval7 also provides a parser for an extended set of PokerStove style range strings, and approximate equity calculation for unweighted ranges.

Eval7 is a work in progress: only the functionality needed by Flop Ferret has been fully implemented. Time permitting, the goal is to provide a fully featured poker hand evaluator and range equity calculator with a clean native python interface and all performance critical parts implemented in Cython.

Installation

Linux with 3.7

There is a manylinux wheel on PyPI that for python 3.7:

pip install eval7

Although not officially supported, there’s also a wheel for python 2.7 that probably still works.

Other Platforms

eval7 is tested on python 3.5, 3.6, and 3.7 and likely works with 2.7. The build process requires cython (tested with 0.23). If you have a working copy of python:

pip install cython

should work. Once you have cython, clone the repo and install with:

python setup.py install

If you have difficulty installing, please open an issue! If there’s much interest I can get wheels built for other platforms with a little effort.

Usage

Basic usage:

>>> import eval7, pprint
>>> deck = eval7.Deck()
>>> deck.shuffle()
>>> hand = deck.deal(7)
>>> pprint.pprint(hand)
[Card("5c"),
 Card("9s"),
 Card("8d"),
 Card("5d"),
 Card("Ac"),
 Card("Qc"),
 Card("3d")]
>>> eval7.evaluate(hand)
17025648
>>> eval7.handtype(17025648)
'Pair'

>>> hand = [eval7.Card(s) for s in ('As', '2c', '3d', '5s', '4c')]
>>> eval7.evaluate(hand)
67305472
>>> eval7.handtype(67305472)
'Straight'

Deck objects provide sample, shuffle, deal and peek methods. The deck code is currently implemented in pure python and works well for quick lightweight simulations, but is too slow for full range vs. range equity calculations. Ideally this code will be rewritten in Cython.

Hand Ranges

eval7 also provides a parser for weighted PokerStove style hand ranges.

Examples:

>>> from pprint import pprint
>>> hr = eval7.HandRange("AQs+, 0.4(AsKs)")
>>> pprint(hr.hands)
[((Card("Ac"), Card("Qc")), 1.0),
 ((Card("Ad"), Card("Qd")), 1.0),
 ((Card("Ah"), Card("Qh")), 1.0),
 ((Card("As"), Card("Qs")), 1.0),
 ((Card("Ac"), Card("Kc")), 1.0),
 ((Card("Ad"), Card("Kd")), 1.0),
 ((Card("Ah"), Card("Kh")), 1.0),
 ((Card("As"), Card("Ks")), 1.0),
 ((Card("As"), Card("Ks")), 0.4)]

>>> hr = eval7.HandRange("AJ+, ATs, KQ+, 33-JJ, 0.8(QQ+, KJs)")
>>> len(hr)
144

At present the HandRange objects are just a thin front-end for the range-string parser. Ultimately the hope is to add Cython backed sampling, enumeration, and HandRange vs. HandRange equity calculation.

Equity

eval7 also provides equity calculation functions: py_hand_vs_range_exact, py_hand_vs_range_monte_carlo and py_all_hands_vs_range. These don’t yet support weighted ranges and could probably benefit from optimization. See equity.pyx for documentaiton.

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

eval7-0.1.6.tar.gz (158.2 kB view details)

Uploaded Source

Built Distributions

eval7-0.1.6-cp38-cp38-manylinux1_x86_64.whl (443.4 kB view details)

Uploaded CPython 3.8

eval7-0.1.6-cp38-cp38-macosx_10_9_x86_64.whl (89.9 kB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

eval7-0.1.6-cp37-cp37m-manylinux1_x86_64.whl (397.1 kB view details)

Uploaded CPython 3.7m

eval7-0.1.6-cp37-cp37m-macosx_10_9_x86_64.whl (89.0 kB view details)

Uploaded CPython 3.7m macOS 10.9+ x86-64

eval7-0.1.6-cp36-cp36m-manylinux1_x86_64.whl (334.5 kB view details)

Uploaded CPython 3.6m

File details

Details for the file eval7-0.1.6.tar.gz.

File metadata

  • Download URL: eval7-0.1.6.tar.gz
  • Upload date:
  • Size: 158.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.3

File hashes

Hashes for eval7-0.1.6.tar.gz
Algorithm Hash digest
SHA256 f8a5ceca8a9a68ae9c5661b1f00d407050563e7efd8f5777f072a0ccf3566ee6
MD5 4f7811f4b2c08970104c1219c323c2c7
BLAKE2b-256 f3066b921a687390e37377f0ec83131986038ee48f2d40efc7fa7528f4651038

See more details on using hashes here.

File details

Details for the file eval7-0.1.6-cp38-cp38-manylinux1_x86_64.whl.

File metadata

  • Download URL: eval7-0.1.6-cp38-cp38-manylinux1_x86_64.whl
  • Upload date:
  • Size: 443.4 kB
  • Tags: CPython 3.8
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.3

File hashes

Hashes for eval7-0.1.6-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 e54329f3744e625f69e209b58470dc7b5abf88be9efefc5377ad140a3edc4cd3
MD5 bab1efac47a8a2cb45294d8589781946
BLAKE2b-256 cdbebe02d1e508d73a0c913af504061e11d4219c3456c99d82ca38a0e04b934e

See more details on using hashes here.

File details

Details for the file eval7-0.1.6-cp38-cp38-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: eval7-0.1.6-cp38-cp38-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 89.9 kB
  • Tags: CPython 3.8, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.3

File hashes

Hashes for eval7-0.1.6-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 f06a0878753e14b73cbfca7ee7fd9836d53e5ee311f8e6a9c5c562e2f0147550
MD5 cf6ac9dc245927ac586908e7fb0705cf
BLAKE2b-256 d114fd7bda3d44a28f61a7ce27334fd39637142ddddcd730d9ee50945cd57981

See more details on using hashes here.

File details

Details for the file eval7-0.1.6-cp37-cp37m-manylinux1_x86_64.whl.

File metadata

  • Download URL: eval7-0.1.6-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 397.1 kB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.3

File hashes

Hashes for eval7-0.1.6-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 342e931a54d061223f4781005ffcec3a55179b0e2966d4a22d80fec3c4aa0716
MD5 8d7c463c9d03db44455082fa21503370
BLAKE2b-256 ebf36b4901c88847dfe717e38a373484c035cbc2b6d590dc59e67292ee030ca6

See more details on using hashes here.

File details

Details for the file eval7-0.1.6-cp37-cp37m-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: eval7-0.1.6-cp37-cp37m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 89.0 kB
  • Tags: CPython 3.7m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.3

File hashes

Hashes for eval7-0.1.6-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 731eb95931c53decac7f2d09ec7c69041454ab95669d20576077bef6c878f773
MD5 ddf2ed0d30b84174ccfcda283e89224c
BLAKE2b-256 85de80a733410f3df23e5c1675017b90901be53ed95bbb133053d784a99c7ff1

See more details on using hashes here.

File details

Details for the file eval7-0.1.6-cp36-cp36m-manylinux1_x86_64.whl.

File metadata

  • Download URL: eval7-0.1.6-cp36-cp36m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 334.5 kB
  • Tags: CPython 3.6m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/44.1.1 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/2.7.16

File hashes

Hashes for eval7-0.1.6-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 ac611b3fee23c3bdba18e184383acb67389878b3d4806dd02d8ebcf56bfa9eb7
MD5 23d64c2584190905908ec66c1652cf6a
BLAKE2b-256 a57bc1e074123c0ec300307d281785a104a9ccaddcb22a7c9db6200c80b307a0

See more details on using hashes here.

Supported by

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