AI-powered poker agents for Primo Poker, featuring varying skill levels and personalities, deployed on Cloudflare Workers
LibratusLounge is a sophisticated AI agent system designed to play multiplayer Texas Hold'em poker on the Primo Poker platform. Our agents simulate human players with different skill levels, playing styles, and personalities, creating a more engaging and realistic poker experience.
- π― Multiple Skill Levels: Beginner, Intermediate, and Advanced agents with distinct playing strategies
- π Personality System: Configurable traits that affect decision-making and chat behavior
- π§ Hybrid Intelligence: Combines rule-based logic with optional LLM integration for complex decisions
- β‘ Serverless Architecture: Runs on Cloudflare Workers for global low-latency performance
- π° Cost-Effective: Intelligent caching and decision optimization to minimize LLM costs
- π Performance Monitoring: Real-time metrics for decision speed, win rates, and resource usage
- Node.js 18+ and npm
- Cloudflare account with Workers enabled
- Wrangler CLI (
npm install -g wrangler) - Primo Poker API credentials
# Clone the repository
git clone https://github.com/yourusername/LibratusLounge.git
cd LibratusLounge
# Install dependencies
npm install
# Copy environment template
cp .env.example .env
# Configure your environment variables
# Edit .env with your API keys and configuration# Start local development server
npm run dev
# Run tests
npm test
# Run agent simulations
npm run simulate
# Type check
npm run typecheck
# Lint code
npm run lint# Login to Cloudflare
wrangler login
# Deploy to production
npm run deploy
# View logs
wrangler tailβββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β Primo Poker ββββββΆβ Cloudflare ββββββΆβ AI Agents β
β Game Server βββββββ Workers βββββββ (Durable Obj) β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β β
βΌ βΌ
βββββββββββββββββββ βββββββββββββββββββ
β Workers KV β β Workers AI β
β (Decision Cache)β β (LLM Inference)β
βββββββββββββββββββ βββββββββββββββββββ
- Fast, deterministic decisions
- Hand strength evaluation
- Pot odds calculations
- Position-aware play
- Complex reasoning for difficult spots
- Natural language game analysis
- Adaptive strategies based on opponents
- Best of both worlds
- Rules for common situations
- LLM for edge cases
- Automatic fallback mechanisms
Configure agent personalities using trait values (0-1):
const personality = {
aggression: 0.7, // How often they bet/raise vs call
tightness: 0.6, // Hand selection strictness
deception: 0.5, // Bluffing frequency
tilt_resistance: 0.8, // Emotional stability
risk_tolerance: 0.4, // Willingness to gamble
chat_frequency: 0.3 // Table talk frequency
};- Cautious Carl: Tight, passive, rarely bluffs
- Aggressive Annie: Loose, aggressive, frequent bluffer
- Balanced Bob: GTO-inspired, hard to exploit
- Tilting Tim: Emotional, makes poor decisions when losing
- Chatty Charlie: Talkative, tries to get reads through chat
POST /api/agents
{
"skillLevel": "intermediate",
"personality": "aggressive-annie",
"enableLLM": true,
"tableId": "table-123"
}POST /api/agents/{agentId}/decision
{
"gameState": {
"hand": ["As", "Kd"],
"communityCards": ["Qh", "Js", "Tc"],
"pot": 1000,
"toCall": 200,
"position": "button"
}
}npm test # Run all tests
npm test -- --watch # Watch mode
npm test -- agents/ # Test specific directorynpm run simulate -- --hands 1000 # Run 1000 hand simulation
npm run simulate -- --tournament # Tournament simulation
npm run simulate -- --heads-up # Heads-up matchesnpm run perf # Run performance benchmarks
npm run load-test # Stress test with multiple agentsAccess real-time metrics at https://your-worker.dev/metrics:
- Decision latency (p50, p95, p99)
- LLM usage and costs
- Cache hit rates
- Agent win rates by personality
- Error rates and timeouts
# View real-time logs
wrangler tail
# Filter by agent
wrangler tail --search "agent-id:123"
# Debug specific decisions
wrangler tail --search "decision-debug"- Decision Caching: Similar game states reuse previous decisions
- Tiered Logic: Simple decisions bypass LLM entirely
- Daily Budgets: Automatic fallback when limits reached
- Batch Processing: Group similar decisions when possible
- Rule-based agents: ~$0.001 per game
- Hybrid agents: ~$0.005 per game
- Full LLM agents: ~$0.01 per game
- Agent Timeout: Increase
AGENT_DECISION_TIMEOUTin environment - High Latency: Check cache configuration and Worker location
- LLM Errors: Verify API keys and model availability
- Memory Limits: Reduce
DECISION_CACHE_SIZEif needed
Enable detailed logging:
# Set in wrangler.toml
[vars]
DEBUG_MODE = "true"
LOG_LEVEL = "verbose"We welcome contributions! Please see CONTRIBUTING.md for guidelines.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open a Pull Request
- TypeScript with strict mode
- ESLint + Prettier formatting
- 100% type coverage required
- Comprehensive test coverage
- API keys stored in Cloudflare Secrets
- Input validation on all game states
- Rate limiting per agent and table
- Regular security audits
Please report security vulnerabilities to security@libratuslounge.com
This project is licensed under the MIT License - see LICENSE for details.
- Primo Poker for the platform integration
- Cloudflare Workers team for the infrastructure
- The poker AI research community
- β Basic agent implementation
- β Cloudflare Workers deployment
- π Personality system
- π LLM integration
- π Multi-table tournament support
- π Advanced opponent modeling
- π Real-time learning system
- π Mobile app for monitoring
- π Additional poker variants (PLO, Stud)
- π Agent marketplace
- π Custom personality creator
- π Tournament hosting platform
Built with β€οΈ by the LibratusLounge team