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

# Simple evaluation
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"

# Poker game with Board and Hand
deck = pkrbot.Deck()
deck.shuffle()

player = pkrbot.Hand(deck.deal(2))
board = pkrbot.Board(deck.deal(3))  # Flop
board.push(deck.deal(1)[0])  # Turn
board.push(deck.deal(1)[0])  # River

full_hand = player.cards + board.cards
result = pkrbot.evaluate(full_hand)
print(f"{player} on {board} = {pkrbot.handtype(result)}")

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"

Board: Community cards with built-in evaluation

  • board = pkrbot.Board([cards]) - Create board
  • board.push(card) - Add card (flop/turn/river)
  • board.evaluate() - Evaluate board
  • board.handtype() - Get hand type
  • board.get_street() - Get street

Hand: Player's hole cards

  • hand = pkrbot.Hand([cards]) - Create hand
  • hand.remove(card) - Remove a card
  • hand.get_card(index) - Get card at index

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.1.tar.gz (186.6 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.1-cp313-cp313-macosx_14_0_arm64.whl (87.9 kB view details)

Uploaded CPython 3.13macOS 14.0+ ARM64

File details

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

File metadata

  • Download URL: pkrbot-1.0.1.tar.gz
  • Upload date:
  • Size: 186.6 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.1.tar.gz
Algorithm Hash digest
SHA256 2a67d435b0bd0ceaa7ff3e2a32e245b02944866e8416350032039b333c2a2adb
MD5 3097d2e9b44f815e9d6fb04d4cdc7b46
BLAKE2b-256 9b02ce52f722eda78a9c63e3134f8faf299810c6e774e4625e6480a950cdad89

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pkrbot-1.0.1-cp313-cp313-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 c06a3be07b445013684cb07b4641939aa6460ad885e1def8e19a5ac2a904fba5
MD5 6ac84c1be6087bcc4cc119de3097c954
BLAKE2b-256 a5350c3ac01ad0ec08e259ca7765d441d597d2597b2159e9e9c68bef40a10472

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