Creating a Poker AI might seem daunting, but with the right tools and instructions, you can dive into the world of artificial intelligence and game theory. In this blog, we will walk through the steps to set up and run your own Poker AI using Counterfactual Regret Minimization (CFR) concepts.
Prerequisites
Before we get started, ensure you have the following:
- Python 3.7 or newer installed on your system.
- The necessary development tools for installing Python packages.
Installation Steps
There are two primary ways to install the Poker AI package:
- From PyPI: Use the package manager:
pip install poker_ai
git clone https://github.com/fedden/poker_ai.git
cd path_to_poker_ai
pip install .
Exploring the Command Line Interface (CLI)
Once you’ve installed the package, you can interact with it through a command line interface. Here are some handy commands:
poker_ai --help
To get more specific help about certain functionalities, use:
poker_ai cluster --help
For starting training your agent:
poker_ai train start --help
Keep your commands organized as you prepare to execute actions like playing against your AI:
poker_ai play --help
Building a Poker Bot
To build an effective Poker AI, we need to cluster hero information to manage the vast number of potential card combinations. Think of it like sorting a massive library: instead of sorting every single book, you categorize books by genre so you can quickly find what you need. Here’s how to do that:
poker_ai cluster
This command will create a file called card_info_lut.joblib in your project directory, where the information is saved for later use.
Training Your Bot
We will utilize the MCCFR algorithm – like a marathon runner refining their pacing by running against their past self, our bot will adjust its strategy through iterative self-play. To commence training, execute this command:
poker_ai train start
This will generate a folder to hold your learned strategies, making it easy to resume later if needed.
Playing against Your Bot
At last, it’s time to test your bot! You can do so with the following command:
poker_ai play
Check the results.yaml file in your home directory to see who won the match!
Running Tests
Contributions to testing are welcome, as more tests mean a more reliable bot! Here is how to run tests on your setup:
cd path_to_poker_ai
pip install pytest
pytest
Building and Running the Docker Image
If you’re working within a Docker environment, you’re in for a treat. After creating the necessary lookup tables, build your Docker images:
docker build --build-arg LUT_DIR=research/blueprint_algo -f ParentDockerfile -t pokerai .
docker build -t pokeraitest .
docker run -it pokeraitest pytest
Troubleshooting
If you encounter any hiccups along the way, here are a few troubleshooting tips:
- Ensure you’re using the correct version of Python.
- If installed via source, verify that your paths are correct.
- Refer to the error messages during execution; they can guide you to the exact issue.
For more insights, updates, or to collaborate on AI development projects, stay connected with fxis.ai.
Conclusion
As you navigate through building and testing your Poker AI, remember that persistence is key. Each challenge is an opportunity to learn and grow in your understanding of AI and poker strategy. At fxis.ai, we believe that such advancements are crucial for the future of AI, as they enable more comprehensive and effective solutions. Our team is continually exploring new methodologies to push the envelope in artificial intelligence, ensuring that our clients benefit from the latest technological innovations.

