This project is a comprehensive implementation of a Poker Texas Hold'em No Limit game from scratch, including:
- all necessary classes
- a custom hand evaluation system
- hand recognition system
- algorithm that calculates win probabilities using Monte Carlo simulation
- algorithm to evaluate decision effectiveness
- bot that makes optimal mathematical decisions using these algorithms
Game is implemented using object-oriented programming with the following classes:
- Player: stores information about chip stack, betting amounts and has methods for acting during the game: fold, check or raise.
- Bot: inherits Player class extending it by new method: decision. This method makes a decision based on mathematical probabilities.
- Deck: stores cards
- Card: represents card
- Pot: stores information about amount of chips and tracks minimum bet allowed.
- Game: controls flow of the game.
To evaluate and compare hand strength, an authorial scoring system was developed. This system uses a combination of addition and specifically chosen multipliers to uniquely evaluate each poker hand. Below are the precise formulas for each possible hand in poker:
Let kickers be represented by
The calculator utilizes Monte Carlo simulations to estimate probabilities. This method involves running a large number of random simulations to model the possible outcomes of a game. Here's how it works in the context of this poker calculator:
- Random Sampling: The calculator generates random combinations of common cards and opponent hands to simulate different game scenarios.
- Statistical Accuracy: By running thousands or even millions of these simulations, the calculator can approximate the true probability of winning a hand with high accuracy.
- Efficiency: Instead of analyzing every possible combination exhaustively, Monte Carlo simulation allows for quick probability estimation by focusing on a representative sample of possible outcomes.
Function: Calculates the win probability for specific player hands and common cards.
Example: For two players with no common cards, the calculator considers 1,712,304 possible combinations. It samples 50,000 combinations for quick results, achieving 2% margin of error within 5 seconds.
Function: Evaluates probabilities by inputting two known cards and assuming two unknown cards for the opponent.
Example: In a one-on-one game, the opponent's hand can form 1,225 possible combinations. The calculator uses sampling to estimate probabilities efficiently.
Function: Assesses hand strength against a range of potential opponent hands using Bill Chen’s scoring method.
Example: Calculate the win probability of a pair of Kings against any hands scored 8 or higher.
git clone https://github.com/MarcinKadziolka/poker.git
cd poker
python3 -m venv .venv
source .venv/bin/activate
pip3 install -r requirements.txt
python3 poker/poker.py
python3 poker/win_evaluation_gui.py