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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyholdem-0.0.2.tar.gz (16.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyholdem-0.0.2-py3-none-any.whl (15.4 kB view details)

Uploaded Python 3

File details

Details for the file pyholdem-0.0.2.tar.gz.

File metadata

  • Download URL: pyholdem-0.0.2.tar.gz
  • Upload date:
  • Size: 16.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.13

File hashes

Hashes for pyholdem-0.0.2.tar.gz
Algorithm Hash digest
SHA256 0562fa4ebf3bf4fe39f59ea36531875b3a3651e33da66fda59e481da9dd57376
MD5 3148ca92d926cf495f557f22a9198203
BLAKE2b-256 86ccc215d5697c85bbbb93be3e6a1a9a9f21038d3d555413564d3b1940ce07ae

See more details on using hashes here.

File details

Details for the file pyholdem-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: pyholdem-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 15.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.13

File hashes

Hashes for pyholdem-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 9530a2fc415d2edf9dc4f9dd707b744100afaf3ef058a90090b2a7ca07d035e7
MD5 7ab7756b5b1f86f54cf7e36bf666e095
BLAKE2b-256 074a4c2ae755f5e4f3c278f0370a2723da73f8563e69ade0d3f64ee4770cfabc

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 Sentry Error logging StatusPage Status page