This project implements a system to evaluate the ability of large language models (LLMs) to play Tic-Tac-Toe. It provides a framework for testing and comparing different LLM-based players against each other or against an ideal player implementation.
ttt_core.py: Contains the core game logic, including theTTTStateclass which represents the game state.ttt_players.py: Defines player classes, including theTTTPlayerIdealwhich implements an optimal strategy.ttt_llm.py: Implements theTTTPlayerLLMJsonclass for integrating LLMs as Tic-Tac-Toe players.toe2toe.py: Contains the main simulation logic for running games between players and calculating statistics.
- Tic-Tac-Toe game state management
- Ideal player implementation with optimal move selection
- Integration with LLMs for player behavior using OpenAI-compatible APIs
- Evaluation metrics for comparing LLM performance
- Flexible configuration for different LLM models and API endpoints
-
Clone the repository:
git clone https://github.com/the-crypt-keeper/toe2toe.git cd toe2toe -
Install the required dependencies:
pip install openai -
Set up your LLM API endpoint and credentials (if required).
To run a simulation between two LLM players:
-
Open
toe2toe.pyand configure theTTTPlayerLLMJsoninstances with your desired API endpoints and model names. -
Run the simulation:
python toe2toe.py
This will execute a series of games between the configured players and output the results and statistics.
- Modify the
system_promptandmove_templateinTTTPlayerLLMJsonto experiment with different prompting strategies. - Adjust the
num_gamesvariable intoe2toe.pyto change the number of games in each simulation. - Implement new player classes in
ttt_players.pyto test different strategies or integrate other AI models.
Contributions to improve the system or add new features are welcome. Please feel free to submit pull requests or open issues for discussion.
This project is open-source and available under the MIT License.