A micro-library intended for studying No Limit Texas Hold'Em (NLH), written in pure Python.
The library provides classes and tools for toy games, simulations, and inductive equity calculations. It is intended for approximation and ease-of-use, rather than a replacement for more rigorous GTO study.
No Limit Hold'Em is the most popular variant of poker, allowing for uncapped betting across multiple streets which creates a more complex layer of strategy. The goal of this package is to provide the basic tools needed to understand NLH inductively. It includes six main classes that allow for custom simulation and equity calculation:
Card
: Provides functionality for individual cards, including several generation mechanisms.Hand
: Performs made hand strength calculations and comparison.Player
: Encapsulates information about individual players (stack, hole, made hand, etc.).Deck
: Provides functionality for a deck (burn, draw, deal, shuffle, etc.).Simulation
: Encapsulates all information about a given trial, running the board out, assessing winners, etc.EquitySolver
: The main equity calculation mechanism. Hand and range equity, EV, fold equity calculation.
Generate a few ranges and a custom board if desired with the utilities provided by the Card
class.
myRange = [Card.generateSet(('9s', '9h'))]
standardThreeBet = EquitySolver.generateRange(['AA', 'KK', 'QQ', 'AKs', 'AKo', 'JJ',
'TT', '99', 'AQs', 'AQo', 'AJs', 'AJo',
'ATs', 'ATo', 'KQs', 'KQo'])
board = Card.generateSet(('Ah', '9c', '5c'))
Initialize an EquitySolver
and input the ranges and board to approximate equity.
equities, message = EquitySolver.calculateRangeEquity(myRange, standardThreeBet,
trials=10000, customBoard=board)
print(message)
____________________
BoardCards:
♥A ♣9 ♣5
____________________
Range 1 | 84.11034482757842%
Range 2 | 10.833620689654694%
CHOP | 5.0560344827581485%
____________________
For more detailed instruction on how to use the library, refer to the short tutorial notebook.
Install via pip
:
pip install git+https://github.com/sumaddury/pokeriq.git
Or install from source:
git clone https://github.com/sumaddury/pokeriq.git
cd pokeriq
pip install .
Finally, import the required classes!
from pokeriq import Card, Hand, Deck, Player, Simulation, EquitySolver
Implementation | Supported Params | |
---|---|---|
Hand Equity | Randomizes over some n trials. • All inputs are first removed from the deck • All-way chops are recorded as ties • Chops between a subset of the players count as a win • For players with unspecified hands, a random hand from the deck is drawn on each trial |
PC: 1-10 Streets: Any Custom deck: ✅ |
Range Equity | Enumerates over all possible hand combinations between ranges exactly n trials each. • Above rules apply • Exact card collisions are not an issue • Does NOT account for blockers |
PC: Any Streets: Any Range Size: Any Custom deck: ✅ |
Semi-Bluff EV | Calculates EV based on showdown equity, player count, pot bet, and fold equity per player. Uses deduction. | PC: Any Streets: Any |
Fold Equity Calculation | Calculates necessary average fold equity to break even based on showdown equity, player count, and pot bet. Uses root-finding. | PC: Any Streets: Any |
Custom Simulation | Non-dealt streets are dealt, and winners are assessed. | PC: Varies Streets: Any Custom deck: ✅ |
Top:
tutorial.ipynb
: Short tutorial for PokerIQ functionality. *NOT UPDATED FOR RECENT FEATURES.tests.ipynb
: Few tests to ensure sanity and stability. Credits to PokerAI for solver references. *NOT UPDATED FOR RECENT FEATURES.
In pokeriq
directory:
card.py
: ContainsCard
class functionality.deck.py
: ContainsDeck
class functionality.made_hand.py
: ContainsHand
class functionality.player.py
: ContainsPlayer
class functionality.runout_simulation.py
: ContainsSimulation
class functionality.equity_tools.py
: ContainsEquitySolver
class functionality.