Skip to main content

holdem

holdem is a Python library for Texas Hold’em poker, built as an interactive learning environment for probability and game strategy. It provides not only complete game logic (cards, deck handling, hand evaluation, betting rounds, and AI players), but also an LLM tutor skill (holdem.skill pyskill) that teaches everything from basic poker rules to related topics such as probability, simulations, game theory.

Why it exists: Poker is a natural classroom for mathematics with topics ranging from combinatorics, pot odds, expected value, variance, Bayesian reasoning, and game theory. In traditional classroom settings, those topics are taught from bottom up, and it’s often hard to see how these topics are directly connected to anything important and useful in practice. Students therefore lose interest, become demotivated, and learn less. holdem lets a tutor agent and student play actual hands, so concepts come up when they matter or when students are curious. The students have clear goals on what and why they want to learn, rather than the whole curriculum imposed on them. It’s like how we learned to play soccer (or any game) as kids. We learned about rules and strategies slowly as we needed to play the game over time.

The learning is hands-on: students run Monte Carlo simulations (equity) to watch win rates converge, count outcomes on small decks, and experiment with code that generate real data. The tutor’s philosophy is play-first: explain only what the learner asks about, check prerequisites before diving in, and treat wrong answers as teaching moments.

I hope students have fun playing, and enjoy asking questions and thinking about them. It may be challenging and hard at times, but it’s fun hard. And play on your pace. The tutor isn’t going anywhere.

How to use

from holdem.skill import *
game = Game([Player('you', balance=20, strategy=human), # Create a game with players.
             Player('bot', balance=20, strategy=always_call)])
game.start()   # deal and show your hand
game.act()     # one human turn; bots auto-play; repeat until "Game is over"

Key pieces:

  • Player(username, balance, strategy) — human puts a learner in the seat; always_call/always_check/always_fold/always_raise(n) create bot personalities
  • Game.start() / Game.act() / Game.state() — play one turn per cell so learners can explore between turns; start() again deals a fresh hand
  • evaluate_hand, compare_hands, hand_name — hand ranking, e.g. (7,3,2) → 'full house, threes over twos'
  • equity(hand, community, n_opponents, n_sims) — Monte Carlo win/tie/lose estimate; pass a seed for reproducible classroom demos
  • mk_deck(suits, ranks), shuffle_deck, withdraw_card — build small decks (e.g. mk_deck(suits[:2], ranks[:5])) to make counting outcomes concrete before switching to real odds

Usage

Installation

Install latest from the GitHub repository:

$ pip install git+https://github.com/galopyz/holdem.git

or from pypi

$ pip install pyholdem

Documentation

Documentation can be found hosted on this GitHub repository’s pages. Additionally you can find package manager specific guidelines on pypi.

Developer Guide

If you are new to using nbdev here are some useful pointers to get you started.

Install holdem in Development mode

# make sure holdem package is installed in development mode
$ pip install -e .

# make changes under nbs/ directory
# ...

# compile to have changes apply to holdem
$ nbdev_prepare

Metadata

Release files for pyholdem 0.0.2

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

Source distribution (sdist)

Source distribution for pyholdem 0.0.2
File Size Uploaded
pyholdem-0.0.2.tar.gz 16.1 kB Details

Built distribution (wheel)

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

Total release size: 31.5 kB

Release files / pyholdem-0.0.2.tar.gz

Download URL pyholdem-0.0.2.tar.gz
Size 16.1 kB
Tags Source
SHA-256 checksum
How to use checksums
0562fa4ebf3bf4fe39f59ea36531875b3a3651e33da66fda59e481da9dd57376
BLAKE2b-256 checksum
How to use checksums
86ccc215d5697c85bbbb93be3e6a1a9a9f21038d3d555413564d3b1940ce07ae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release files / pyholdem-0.0.2-py3-none-any.whl

Download URL pyholdem-0.0.2-py3-none-any.whl
Size 15.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9530a2fc415d2edf9dc4f9dd707b744100afaf3ef058a90090b2a7ca07d035e7
BLAKE2b-256 checksum
How to use checksums
074a4c2ae755f5e4f3c278f0370a2723da73f8563e69ade0d3f64ee4770cfabc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files

0.0.1

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