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(seed=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.3.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.3-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.3.tar.gz.

File metadata

  • Download URL: pkrbot-1.0.3.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.3.tar.gz
Algorithm Hash digest
SHA256 acd1d6f1521b15a50439493d01e3ecdd6702972fe7f7415904ee3c7e550ecf9b
MD5 a64a2fbb197fcb555d48ec911017d336
BLAKE2b-256 5629e23d2f4082f5d6149086eefc373b2cf990ae6dcee19620da7e261c059e28

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pkrbot-1.0.3-cp313-cp313-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 78df5f941cb0ee29ba07619a58c7772eaae5508bc9b6c4469da80005de1a6da3
MD5 1fff9c84932a3a6ba7b966d8b162a0a5
BLAKE2b-256 21632737e26f2a2e2dcb9bbe5380231a92f024b923a206d872a4f42b68a03e0a

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