Skip to main content

PokerTable

Pure Texas Hold'em engine with Monte Carlo equity calculator. Zero dependencies. Designed for AI agents.

from poker_engine import PokerEngine, Action, ActionType

engine = PokerEngine(["Alice", "Bob", "Charlie"], starting_chips=1000, seed=42)
engine.new_hand()

# Get valid actions for current player
player = engine.get_current_player()
actions = engine.get_valid_actions(player.name)

# Apply an action
result = engine.apply_action(player.name, Action(ActionType.CALL, 20))

# Check equity
from poker_engine import calculate_equity
equity = calculate_equity(player.hole_cards, engine.community, num_opponents=2)
print(f"Win probability: {equity.win_probability:.0%}")

Installation

pip install pokertable

Features

  • Complete Texas Hold'em rules (pre-flop through showdown)
  • Proper side pots for multi-player all-ins
  • Correct betting round termination (raise resets action)
  • Dealer button rotation with heads-up special rules
  • Monte Carlo equity calculator (~500 simulations, <100ms)
  • Hand evaluation for all 10 poker hand ranks
  • Human-readable hand descriptions ("Full House, Kings over Tens")
  • Turn-based API designed for AI agent integration
  • Seeded RNG for reproducible games
  • Zero external dependencies

Architecture

src/poker_engine/
├── cards.py      # Card, Suit, HandRank, evaluate_hand, describe_hand
├── engine.py     # PokerEngine state machine (the core)
├── equity.py     # Monte Carlo win probability calculator
└── __init__.py   # Public API exports

The engine is a pure state machine — no I/O, no async, no display logic. You call methods, it returns state. This makes it easy to wrap with any interface: CLI, web, AI agents, etc.

Usage

Basic Game Loop

from poker_engine import PokerEngine, Action, ActionType

engine = PokerEngine(["Alice", "Bob"], starting_chips=1000)

while not engine.is_tournament_over():
    engine.new_hand()
    
    while not engine.is_hand_over():
        if engine.is_betting_round_complete():
            if engine.phase.name == "RIVER":
                summary = engine.resolve_showdown()
                break
            engine.advance_phase()
            continue
        
        player = engine.get_current_player()
        if player is None:
            break
        
        actions = engine.get_valid_actions(player.name)
        # Your logic to choose an action here
        chosen = actions[1]  # e.g., call/check
        engine.apply_action(player.name, chosen)
    
    engine.rotate_dealer()

Equity Calculator

from poker_engine import calculate_equity
from poker_engine.cards import Card, Suit

hole = [Card(14, Suit.SPADES), Card(14, Suit.HEARTS)]  # Pocket aces
community = [Card(10, Suit.DIAMONDS), Card(7, Suit.CLUBS), Card(2, Suit.SPADES)]

equity = calculate_equity(hole, community, num_opponents=3, num_simulations=1000)
print(f"Hand: {equity.current_hand}")           # "Pair of As"
print(f"Win: {equity.win_probability:.0%}")      # "~82%"
print(f"Improvements: {equity.hand_improvement}") # {"Pair": 0.45, "Two Pair": 0.12, ...}

Development

git clone https://github.com/chiruu12/pokertable.git
cd pokertable
uv sync --extra dev
uv run pytest
uv run ruff check src tests

License

MIT

Metadata

Release files for pokertable 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pokertable 1.0.0
File Size Uploaded
pokertable-1.0.0.tar.gz 85.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pokertable 1.0.0
File Interpreter ABI Platform
pokertable-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 140.5 kB

Release files / pokertable-1.0.0.tar.gz

Download URL pokertable-1.0.0.tar.gz
Size 85.9 kB
Tags Source
SHA-256 checksum
How to use checksums
22fc65bfd75a26a2dbba6fad99fa227a1c9118d3a208697ba6fe4a52ff9046e0
BLAKE2b-256 checksum
How to use checksums
fb5f59ba2f71e0b629d344d2fc456f5828eeee98c98efeb6bd1240dea484c449
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 19, 2026.

Transparency log

Release files / pokertable-1.0.0-py3-none-any.whl

Download URL pokertable-1.0.0-py3-none-any.whl
Size 54.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b16f55ac9410f727734ac8325c9d95a59fdf338da7932016ce738b2d9b285039
BLAKE2b-256 checksum
How to use checksums
08d8cecbd02d7d8fe3a0bf4a16d82975657b6c5ea388e8848bf7feb33c088e83
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 19, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page