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 holdem

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.1.tar.gz (16.0 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.1-py3-none-any.whl (15.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyholdem-0.0.1.tar.gz
  • Upload date:
  • Size: 16.0 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.1.tar.gz
Algorithm Hash digest
SHA256 6e6fbaa0ff85280b6a276415e750565ea0f6ee9324126e6c6102d6f3a3443308
MD5 f68bd82fbf1e2fb0c541c618b9b37877
BLAKE2b-256 9a4e4cbac8486a9be972973de81e771b64937f6c243d16055dcc5fce98a4c78d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pyholdem-0.0.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7f806f100eecc8defa4ad84c09c258833410e5ca7c9be30298faac19f37544de
MD5 f11f4a404239a32fcb5501f8c1cf1c48
BLAKE2b-256 ddaefe26f6e27630d54c3bf11f66ff52b82a114d15f904da9e4bf9f3407f3cc1

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