Welcome to the AI Poker Game, a Python-based Texas Hold'em poker simulation where AI agents compete against each other using advanced strategies powered by OpenAI's GPT models.
- Features
- Installation
- Usage
- Requirements
- Environment Variables
- Project Structure
- Contributing
- License
- Acknowledgments
- AI Agents: Each player is an AI agent that makes decisions based on game state and poker theory.
- OpenAI Integration: Uses OpenAI's GPT models to simulate human-like decision-making and strategies.
- Texas Hold'em Rules: Implements the standard rules of Texas Hold'em poker.
- Hand Evaluation: Utilizes the
treys
library for accurate hand strength evaluation. - Expandable: Designed with modularity in mind, allowing for easy expansion and customization.
git clone https://github.com/your-username/your-repository.git
cd your-repository
python -m venv venv
Activate the virtual environment:
On macOS/Linux:
source venv/bin/activate
On Windows:
venv\Scripts\activate
pip install -r requirements.txt
Note: Ensure that you have a requirements.txt
file listing all the necessary packages.
The game requires an OpenAI API key to function. You need to set this key as an environment variable.
On macOS/Linux:
export OPENAI_API_KEY='your-api-key-here'
On Windows Command Prompt:
set OPENAI_API_KEY=your-api-key-here
Replace 'your-api-key-here'
with your actual OpenAI API key.
python main.py
Note: The game runs in the console and will display the actions of each AI agent throughout the game.
- Python 3.7 or higher
- An OpenAI API key with access to the GPT models (e.g., gpt-3.5-turbo or gpt-4)
- Python Libraries:
- openai
- treys
- python-dotenv (if you choose to use a .env file)
You can install all required libraries using the requirements.txt
file.
The game uses the following environment variable:
OPENAI_API_KEY
: Your OpenAI API key.
If you prefer to use a .env
file to store environment variables:
-
Install python-dotenv:
pip install python-dotenv
-
Create a
.env
file in the project's root directory:OPENAI_API_KEY=your-api-key-here
-
Update
ai_agent.py
to load the.env
file:from dotenv import load_dotenv load_dotenv()
-
Ensure
.env
is added to your.gitignore
file to prevent it from being committed to the repository.
βββ ai_agent.py
βββ card.py
βββ deck.py
βββ game.py
βββ hand_evaluator.py
βββ main.py
βββ player.py
βββ requirements.txt
βββ README.md
βββ .gitignore
ai_agent.py
: Contains the AIAgent class that uses OpenAI's API to make decisions.card.py
: Defines the Card class representing a playing card.deck.py
: Contains the Deck class for managing the deck of cards.game.py
: Implements the PokerGame class that runs the game logic.hand_evaluator.py
: Evaluates the strength of poker hands using the treys library.main.py
: The entry point of the application.player.py
: Defines the Player class.requirements.txt
: Lists all Python dependencies..gitignore
: Specifies files and directories to be ignored by Git.
Contributions are welcome! Please follow these steps:
- Fork the repository.
- Create a new branch for your feature or bug fix:
git checkout -b feature/your-feature-name
- Commit your changes:
git commit -am 'Add new feature'
- Push to the branch:
git push origin feature/your-feature-name
- Create a Pull Request on GitHub.
This project is licensed under the MIT License.
Note: Include a LICENSE file in your repository if you choose to use the MIT License or any other.
- OpenAI for providing the GPT models.
- The developers of the treys library for poker hand evaluation.
- Any other resources or individuals you wish to acknowledge.