Skip to content

vekovius/AI-Texas-Holdem-CSC4444

Repository files navigation

Texas Hold'em Bot

A No-Limit Poker bot with advanced decision making, hand evaluation, and opponent modeling.

Features

  • Hand strength and equity calculation
  • GTO + exploitative strategy
  • Opponent profiling (TAG, LAG, Fish, Rock, etc.)
  • Position and pot odds awareness
  • Dynamic aggression and bluffing

Quick Start

Requirements

  • Python 3.7+
  • websockets, numpy, pandas, torch, scikit-learn, tqdm

Install

# Install package in development mode
pip install -e .

# Or install dependencies only
pip install -r requirements.txt

Run Test Server & Bot

# Terminal 1: Start test server
python scripts/run_test_server.py

# Terminal 2: Start bot
python scripts/run_bot.py dev table-1 TestBot ws://localhost:8080

Usage

Running the Bot

# Standard entry point
python scripts/run_bot.py [apiKey] [table] [player] [serverUrl]

# Example
python scripts/run_bot.py dev table-1 bot1 ws://localhost:8080

# Alternative: Python module
python -m poker_bot.core.bot dev table-1 bot1 ws://localhost:8080

Competition Mode

For compatibility with the class Texas-HoldEm-Infrastructure:

python scripts/run_competition.py dev table-1 MyBot ws://localhost:8080

Testing Locally

# Start the test server (replays historical hands)
python scripts/run_test_server.py

# Or set custom log file
TEST_SERVER_LOG=historical_logs/sample_real_hands.jsonl python scripts/run_test_server.py

Training Setup

  1. Collect decisions – Logging is enabled by default. Run the bot and it will write JSON lines to logs/training_decisions.jsonl. Customize the path with POKER_TRAINING_LOG=/tmp/decisions.jsonl.

  2. Train models – Once you have data, run:

    python -m poker_bot.training.train_agent --log-path logs/training_decisions.jsonl --agent-name gto --epochs 20

    Trained weights are stored under models/ for easy loading later.

  3. Key modules:

    • src/poker_bot/training/data_collector.py - Decision logging
    • src/poker_bot/training/state_encoder.py - Feature normalization
    • src/poker_bot/training/train_agent.py - PyTorch training loop

Project Structure

AI-Texas-Holdem-CSC4444/
├── scripts/              # Entry point scripts
│   ├── run_bot.py
│   ├── run_competition.py
│   └── run_test_server.py
├── src/poker_bot/        # Main package
│   ├── core/             # Bot infrastructure
│   ├── agents/           # Strategy agents (GTO, Exploiter, Defender)
│   ├── evaluation/       # Hand & opponent evaluation
│   └── training/         # ML training infrastructure
├── tests/                # Test infrastructure
├── tools/                # Utility scripts
├── docs/                 # Additional documentation
└── logs/                 # Training logs (runtime)

Documentation

About

The WINNING No-Limit Texas Hold Em' Bot for CSC 4444 Artificial Intelligence tournament

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors