An open API service indexing awesome lists of open source software.

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.

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
```