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/MacOS with Python 3.7, or 3.8

There are wheels on PyPI that should work with no extra effort:

pip install eval7

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 pip:

pip install cython

should work on many platforms. 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.7.tar.gz (158.1 kB view details)

Uploaded Source

Built Distributions

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

Uploaded CPython 3.8

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

Uploaded CPython 3.7m

File details

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

File metadata

  • Download URL: eval7-0.1.7.tar.gz
  • Upload date:
  • Size: 158.1 kB
  • Tags: Source
  • 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.48.0 CPython/2.7.16

File hashes

Hashes for eval7-0.1.7.tar.gz
Algorithm Hash digest
SHA256 503750d817a5f41e7173ac0ffa91ba9d89b9185da2a57e55b3c639502a6e0174
MD5 0f8186ec96df20b98a0b3a7e85182ca2
BLAKE2b-256 86e3e9f5052f5361d415e15ab77c6fe073c9c9eb430cabfd085bd69be9476376

See more details on using hashes here.

File details

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

File metadata

  • Download URL: eval7-0.1.7-cp38-cp38-manylinux1_x86_64.whl
  • Upload date:
  • Size: 443.4 kB
  • Tags: CPython 3.8
  • 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.48.0 CPython/2.7.16

File hashes

Hashes for eval7-0.1.7-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 2d94cc7965d4ebe47628fe23cad8226eefa5c3b33a1915b1680a167a68438624
MD5 e7cc1d9ac890f6482737817db35ca7d5
BLAKE2b-256 55658be56db6a57b36c50a494da5cd899bbb77ca31af9514578a26040840754c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: eval7-0.1.7-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 397.1 kB
  • Tags: CPython 3.7m
  • 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.48.0 CPython/2.7.16

File hashes

Hashes for eval7-0.1.7-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 edb1b9083f387b4b6209304082cabcfc42fda2d2eb2c827b3fb4e35b1faba9dd
MD5 3cbae6a0cab9d379a7f6957adbe09806
BLAKE2b-256 79bcb3ab70c7cf5d26f52fad35809576d1b5e72e42fa01c5c951a356a28ba643

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