Metadata-Version: 2.1
Name: phevaluator
Version: 0.5.0.4
Summary: PH Evaluator - an efficient Poker Hand Evaluator based on a Perfect Hash algorithm
Home-page: https://github.com/HenryRLee/PokerHandEvaluator/
Author: Henry Lee
Author-email: lee0906@hotmail.com
License: Apache License, Version 2.0
Project-URL: Bug Tracker, https://github.com/HenryRLee/PokerHandEvaluator/issues
Project-URL: Documentation, https://github.com/HenryRLee/PokerHandEvaluator/tree/master/Documentation
Project-URL: Source, https://github.com/HenryRLee/PokerHandEvaluator/tree/master/python
Keywords: poker,texas-holdem,poker-evaluator
Platform: UNKNOWN
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Topic :: Software Development :: Libraries
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3 :: Only
Requires-Python: <4,>=3.6
Description-Content-Type: text/markdown

# PH Evaluator Python package (phevaluator)

## Description

[PH Evaluator](https://github.com/HenryRLee/PokerHandEvaluator) is designed
for evaluating poker hands with more than 5 cards. Instead of traversing all
the combinations, it uses a perfect hash algorithm to get the hand strength
from a pre-computed hash table, which only costs very few CPU cycles and
considerably small memory (~100kb for the 7 card evaluation). With slight
modification, the same algorithm can be also applied to evaluating Omaha
poker hands.

## Installation
The library requires Python 3.
- with `pip`
    ```shell
    pip install .
    ```

## Using the library
The main function is the `evaluate_cards` function.
```python
from phevaluator import evaluate_cards

p1 = evaluate_cards("9c", "4c", "4s", "9d", "4h", "Qc", "6c")
p2 = evaluate_cards("9c", "4c", "4s", "9d", "4h", "2c", "9h")

# Player 2 has a stronger hand
print(f"The rank of the hand in player 1 is {p1}") # 292
print(f"The rank of the hand in player 2 is {p2}") # 236
```
The function can take both numbers and card strings (with format like: 'Ah' or '2C'). Usage examples can be seen in `examples.py`.

## Test
There are 1000 random examples tested for each type of hand (5 cards, 6 cards, and 7 cards). The examples are stored in json files the tests folder and were generated with the original C++ evaluator.

- with current environment
    ```shell
    python3 -m unittest discover -v
    ```

## Development
- recommended to format with [`black`](https://github.com/psf/black) before commit

    check where to correct (without formatting)
    ```shell
    black . --diff --color
    ```
    format all
    ```shell
    black .
    ```



