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

# 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
deck = pkrbot.Deck(seed=42)
deck.shuffle()        # will use seed 42
hand = deck.sample(7) # will use seed 42 as well
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.2.tar.gz (181.3 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.2-cp313-cp313-macosx_14_0_arm64.whl (84.2 kB view details)

Uploaded CPython 3.13macOS 14.0+ ARM64

File details

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

File metadata

  • Download URL: pkrbot-1.0.2.tar.gz
  • Upload date:
  • Size: 181.3 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.2.tar.gz
Algorithm Hash digest
SHA256 5fec547b7cf11e2b4ef7cadb7c0849a312f030ab14ef55bb4ad6fd9a493997bc
MD5 23dec432d1a203c2b8fa6a0b5dd470e6
BLAKE2b-256 0dec715e496053fdbfc8adbb5207a53fd5cc9ccace03106921aa2a9a35fa1987

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pkrbot-1.0.2-cp313-cp313-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 61709e29c11daf29e10aa1fe3f8e143ca5f5681b1656e6d2418a0fee4ab7f0e4
MD5 8f201179a0e9241777aa9026751aea17
BLAKE2b-256 6bc694f960d9641e487bf2f664e900e0d0ca78c607923e8694b834ee05fded30

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