Skip to main content

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() - Randomize
  • deck.deal(n) - Remove and return n cards
  • deck.peek(n) - View top n cards
  • deck.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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pkrbot-1.0.4.tar.gz (181.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pkrbot-1.0.4-cp313-cp313-macosx_14_0_arm64.whl (84.4 kB view details)

Uploaded CPython 3.13macOS 14.0+ ARM64

File details

Details for the file pkrbot-1.0.4.tar.gz.

File metadata

  • Download URL: pkrbot-1.0.4.tar.gz
  • Upload date:
  • Size: 181.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for pkrbot-1.0.4.tar.gz
Algorithm Hash digest
SHA256 dfcddcd4c769f60f5a773abfe360b10879bac8610563822a0525a5147461e167
MD5 b6ea64da9598503cb06671818506d8e2
BLAKE2b-256 10852cff06e8d39e41eb468dfdc1b4d6a599990c2ee5b5982e3955daf23309a3

See more details on using hashes here.

File details

Details for the file pkrbot-1.0.4-cp313-cp313-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for pkrbot-1.0.4-cp313-cp313-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 eb7c85c4d957067fb359c037ab85706fc05a4d07a9e87875b00ee85b778294cb
MD5 bb023843ea69d68510400b607d908be9
BLAKE2b-256 f0e31b4f30a5d37ac2c0f25ce193253984d0cd5de04e21dc5985bc02fb714bb6

See more details on using hashes here.

Supported by

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