Warning
Early Development Warning: This project is in early development stages. The code may be messy, incomplete, or subject to significant changes.
A real-time Texas Hold'em poker game where different AI language models compete against each other. Watch as AI players make strategic decisions, bluff, and compete for chips while you observe their reasoning in real-time.
- Live AI vs AI Gameplay: Six different language models play Texas Hold'em autonomously
- Real-time Web Interface: Watch games unfold with live updates and animations
- AI Reasoning Display: See what each AI is thinking as they make decisions
- Equity Calculations: Real-time win probability calculations for each hand
- Historical Analysis: Track performance across multiple games
- Beautiful UI: Modern, responsive interface with smooth animations
- Next.js 15 with App Router
- Real-time updates via InstantDB
- Components:
- Live game visualization
- Player cards and chip stacks
- Community cards display
- AI reasoning viewer
- Historical game browser
- Performance analytics
- Modular TypeScript architecture
- Core Modules:
types.ts- Type definitions for game stateconstants.ts- Game configuration and AI modelsgame-setup.ts- Game initializationround-manager.ts- Round orchestrationbetting-round.ts- Betting logic and pot managementai-player.ts- AI decision making interfaceshowdown.ts- Hand evaluation and winner determinationutils.ts- Helper functions
- Trigger.dev for game orchestration
- Manages game flow and AI API calls
- Handles database updates
The game features various language models competing:
- GPT-4
- Claude 3
- Gemini Pro
- Llama 3
- Mixtral
- And more via OpenRouter
Each model receives the same game information and must decide whether to fold, check, call, raise, or go all-in based on their cards, the community cards, and the betting action.
- Pre-flop: Each player receives 2 hole cards
- Flop: 3 community cards are revealed
- Turn: 4th community card is revealed
- River: Final community card is revealed
- Showdown: Best hand wins the pot
The game continues for multiple rounds, tracking each AI's performance over time.
Uses InstantDB for real-time data synchronization:
games- Overall game state and configurationplayers- AI players and their chip stacksgameRounds- Individual poker handshands- Player hole cardsbettingRounds- Betting action for each phaseactions- Individual player decisionstransactions- Chip movements and pot distributions
-
Clone the repository
git clone https://github.com/yourusername/llm-poker.git cd llm-poker -
Install dependencies
npm install
-
Set up environment variables
NEXT_PUBLIC_INSTANT_APP_ID=your_instant_app_id OPENROUTER_API_KEY=your_openrouter_key TRIGGER_SECRET_KEY=your_trigger_key
-
Run the development server
npm run dev
-
Start a game
- Navigate to
http://localhost:3000 - Use Trigger.dev dashboard to initiate games
- Navigate to
Game parameters can be adjusted in /engine/constants.ts:
- Initial stack size
- Blind amounts
- Number of hands per game
- AI models to include
The web interface provides:
- Real-time win/loss tracking
- Historical game data
- Per-model performance statistics
- Hand history replay
- Equity calculations
Card.tsx- Playing card displayPlayer.tsx- Player information and actionsChipStack.tsx- Animated chip displaysButton.tsx- Consistent button stylingFramedLink.tsx- Navigation components
- Human vs AI gameplay
- Tournament mode
- Different poker variants (Omaha, Stud)
- Advanced statistics and analytics
- Replay system for interesting hands
- AI model fine-tuning based on results
MIT License - feel free to use this project for your own experiments with AI and game theory!