Skip to main content

Texas Hold'em environment with LLM players

Project description

README.md

llm-poker

A minimal Texas Hold’em environment that seats multiple LLM-based players (via the llm library) and manages everything from dealing hole cards to forced blinds, betting rounds, and a straightforward showdown.

Core features:

  • Blinds: Each hand forces a small blind and a big blind, ensuring there’s money in the pot.
  • Betting: We query each LLM once per betting round, requesting an action in strict JSON form (fold, call, or raise).
  • Local showdown logic: The environment determines the best 5-card hand from each player’s 7 cards and awards the pot.
  • Pydantic-based JSON validation: The LLM responses are parsed and validated. If invalid, we retry.
  • Optional CLI: The poker-eval command can run multiple rounds using the specified LLMs.

Installation

  1. Clone this repository or download the files.
  2. Install the package (in editable mode) from the project root (where setup.py is located):
    pip install -e .
    
  3. Verify You should see llm-poker installed
    pip list | grep llm-poker
    

You must also configure your llm library with the API keys for whichever LLM models you plan to use (e.g., gpt-4o, Anthropic, etc.). For example:

llm keys set openai

Quickstart Examples

  1. Running the Sample run.py
python run.py

Deals up to 5 rounds between multiple players: gpt-4o, claude-3-5-haiku-latest, claude-3-5-sonnet-latest, deepseek-chat. Uses elimination_count=0 so the game does not stop early (unless someone busts). The minimum raise is 500 chips. Logs each hand’s actions, culminating in a final standings table.

  1. Using the CLI If you installed with the included console script, you can do:
poker-eval --models gpt-4o --models claude-3-5-haiku-latest --rounds 5

This deals 5 rounds of heads-up between gpt-4o and claude-3-5-haiku-latest.

Once installed, you have access to:

poker-eval [OPTIONS]

--models/-m: Multiple model names or aliases recognized by llm (defaults to ["gpt-4o"]). --rounds/-r: How many hands to deal (default 3). --elimination-count/-e: Stop once only this many players remain (default 1). --stack/-s: Starting chip stack (default 10000).


Known Limitations

  • No side pots: Currently, if a player goes all-in, the environment doesn’t handle side pots.
  • Manual environment checks: If the LLM returns “check” while facing a bet, the code interprets it as invalid and re-prompts.
  • Fictitious ‘expert-level poker AI’: The LLM’s strategic brilliance is not guaranteed. This is more a demonstration environment than a truly advanced solver.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

llm_poker-0.1.1.tar.gz (8.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

llm_poker-0.1.1-py3-none-any.whl (9.7 kB view details)

Uploaded Python 3

File details

Details for the file llm_poker-0.1.1.tar.gz.

File metadata

  • Download URL: llm_poker-0.1.1.tar.gz
  • Upload date:
  • Size: 8.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.6

File hashes

Hashes for llm_poker-0.1.1.tar.gz
Algorithm Hash digest
SHA256 33d2a8ffb0fd333eea2bc4be412d13c94634c78a56ce187a550e85c49fd3f0d7
MD5 17d7eda01d767a34cd2dadf36a97846f
BLAKE2b-256 cfdccde7e5e2f1fe852e94c99ac22aac34114bf9687ad7423bf18113ee8d81d6

See more details on using hashes here.

File details

Details for the file llm_poker-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: llm_poker-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 9.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.6

File hashes

Hashes for llm_poker-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 40734429dffe5f708c53d0ea1cfaaec99bc06ea3b4fab82ed19f0f43018ea958
MD5 06161400c7b7a64f6d08f397f156f18c
BLAKE2b-256 de205129e09f88642a0693f30b83c87c715e957681ae53d56c5934f6004e2266

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page