Fast poker hand evaluation library with eval7-compatible API
Project description
pkrbot
Fast poker hand evaluator. Drop-in replacement for eval7, 2-3x faster.
Install
pip install pkrbot
Usage
import pkrbot
import random
# Evaluate a hand
hand = [pkrbot.Card('As'), pkrbot.Card('Kh'), pkrbot.Card('Qd'), pkrbot.Card('Jc'), pkrbot.Card('Ts')]
result = pkrbot.evaluate(hand)
print(pkrbot.handtype(result)) # "Straight"
# Use a deck
deck = pkrbot.Deck()
deck.shuffle()
hand = deck.deal(7)
result = pkrbot.evaluate(hand)
# Use a set seed deck
rng = random.Random(42)
deck = pkrbot.Deck(42)
deck.shuffle() # will use seed 42
hand = deck.sample(7) # will use seed 42 as well
deck_2 = pkrbot.Deck(rng) # will use seed 42, but with persisted random state in rng
print(pkrbot.handtype(pkrbot.evaluate(hand)))
API
Cards: pkrbot.Card('As') - Ranks: 2-9, T, J, Q, K, A, Suits: c, d, h, s
Deck:
deck.shuffle()- Randomizedeck.deal(n)- Remove and return n cardsdeck.peek(n)- View top n cardsdeck.sample(n)- Get n random cards
Evaluate: result = pkrbot.evaluate(hand) - Higher values = better hands
Hand Type: pkrbot.handtype(result) - Returns: "Straight Flush", "Quads", "Full House", "Flush", "Straight", "Trips", "Two Pair", "Pair", "High Card"
Performance
~2-3x faster than eval7. Optimized Cython with aggressive compiler flags.
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pkrbot-1.0.17.tar.gz.
File metadata
- Download URL: pkrbot-1.0.17.tar.gz
- Upload date:
- Size: 180.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
11b51a81f39e65606e80c70be1b7fd53f021c1679d6fe4b12dfa2c3a9a1ec085
|
|
| MD5 |
950b8b4a9356c521dd720e99d05a4e95
|
|
| BLAKE2b-256 |
cdc22e8029e9c0db7c28f8863988f213cf6236d8fc2d005671e479ea1e1ab6d4
|
File details
Details for the file pkrbot-1.0.17-cp310-cp310-macosx_10_9_universal2.whl.
File metadata
- Download URL: pkrbot-1.0.17-cp310-cp310-macosx_10_9_universal2.whl
- Upload date:
- Size: 188.0 kB
- Tags: CPython 3.10, macOS 10.9+ universal2 (ARM64, x86-64)
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
20af75bda6cb082a696821f18c59adf7bff0037499248eb37834cb3f60615473
|
|
| MD5 |
a1047318db11c4399c983c1004083a7f
|
|
| BLAKE2b-256 |
598eec086e95f9d0ddead03692503dadb21e90dd6a350c5135118694bfbdf323
|