https://github.com/yashlad27/pokercpp
๐ A command-line Texas Holdโem Poker game written in C++. Features basic game flow including dealing, hand evaluation, and a simple bot opponent. Built for practicing game logic, object-oriented design, and C++ fundamentals.
https://github.com/yashlad27/pokercpp
ai cli cpp game monte-carlo-simulation poker stl-algorithms vector
Last synced: 8 months ago
JSON representation
๐ A command-line Texas Holdโem Poker game written in C++. Features basic game flow including dealing, hand evaluation, and a simple bot opponent. Built for practicing game logic, object-oriented design, and C++ fundamentals.
- Host: GitHub
- URL: https://github.com/yashlad27/pokercpp
- Owner: yashlad27
- Created: 2025-04-16T14:18:44.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2025-04-26T04:11:33.000Z (about 1 year ago)
- Last Synced: 2025-07-04T17:50:27.637Z (11 months ago)
- Topics: ai, cli, cpp, game, monte-carlo-simulation, poker, stl-algorithms, vector
- Language: C++
- Homepage:
- Size: 1.68 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# ๐ CLI Texas Hold'em Poker Game in C++
This project is a **command-line Texas Hold'em poker game** built in modern **C++17**, featuring a multithreaded bot, clean MVC design, and strategic hand evaluation logic.
---
## โ ๏ธ Features (Implemented)
- โ
Card & Deck generation (with emojis for suits โ ๏ธโฆ๏ธโฅ๏ธโฃ๏ธ)
- โ
Full game loop with betting and showdown
- โ
**Bot opponent with Easy/Medium/Hard difficulty**
- โ
**Multithreaded spinner animation** while bot thinks
- โ
Hand evaluator (frequency maps, sorting)
- โ
Clear CLI interface (check, bet, fold actions)
- โ
SOLID design with `BotPlayer` subclass
- โ
MVC Pattern: clean separation of model, controller, view
---
## ๐ Poker Rules - Texas Hold'em
1. **2 hole cards** dealt to each player
2. **5 community cards** revealed in stages:
- **Flop** (3 cards)
- **Turn** (1 card)
- **River** (1 card)
3. Make the **best 5-card poker hand**
4. Actions: `check`, `bet`, `fold`
5. Win by:
- Forcing opponent to fold
- Having a better hand at showdown
---
## ๐ Hand Rankings (Best to Worst)
1. Royal Flush
2. Straight Flush
3. Four of a Kind
4. Full House
5. Flush
6. Straight
7. Three of a Kind
8. Two Pair
9. One Pair
10. High Card
---
## ๐ค Bot Difficulty Logic
You can choose bot difficulty at the start:
- **Easy**: Randomly calls ~25% of the time
- **Medium**: Calls if hand โฅ One Pair
- **Hard**: Calls if hand is good, but may bluff ~20% with weak hands
---
## ๐ง Architecture Overview
### ๐น `Card` & `Deck`
- Card = suit + rank
- Deck = 52-card generation + shuffling
### ๐น `Player` & `BotPlayer`
- `Player`: name, chip count, hand
- `BotPlayer`: subclass with `shouldCallBet()` based on difficulty
### ๐น `HandEvaluator`
- Uses frequency maps and sorted ranks
- Detects pairs, trips, flushes, full house, straights, etc.
### ๐น `PokerController`
- Manages game loop, betting, round progression
### ๐น `CLIView`
- Handles output formatting and emoji display
- Includes `Spinner` animation using multithreading
---
## ๐ How a Round Works
1. Deal hole cards
2. Reveal flop โ turn โ river
3. User chooses action
4. Bot decides based on difficulty
5. Evaluate hands and determine winner
6. Update chip counts
---
## ๐คน Strategy Guide: How Poker Players Think
- Is my pre-flop hand strong?
- Did the flop improve my hand?
- What could the opponent be holding?
- Should I bluff or fold?
- Whatโs the pot odds and EV?
---
## ๐งฐ How to Run the Game
### ๐ฆ Requirements
- macOS or Linux with **clang++ or g++**
- C++17 compatible terminal setup
- (Optional) Sublime Text or VSCode
### โถ๏ธ Compile and Run
```bash
make clean
make run
```
or without MakeFile
```bash
clang++ -std=c++17 main.cpp controller/poker_controller.cpp view/cli_view.cpp \
model/card.cpp model/deck.cpp model/player.cpp model/hand_evaluator.cpp \
model/advanced_hand_evaluator.cpp model/bot_player.cpp animation/spinner.cpp -o poker && ./poker
```