This project implements a classic Tic-Tac-Toe game where a player can play against an AI. The AI uses the Minimax algorithm with Alpha-Beta pruning to make decisions, making it a challenging opponent. The game is built using Python, with a simple graphical user interface (GUI) created with Tkinter.
- Play against a smart AI that calculates its moves using Minimax and Alpha-Beta pruning.
- Simple and intuitive GUI.
- Automatic detection of win, lose, or draw states.
Requirements
- Python 3.x
- Tkinter (usually comes with Python) Setup
- Clone this repository to your local machine.
git clone https://your-repository-link-here 2. Navigate to the cloned directory.
cd tic-tac-toe-minimax-alpha-beta
To start the game, simply run the Python script from your terminal or command prompt.
python tic_tac_toe.py Once the game window opens:
You will play as 'O', and the AI will play as 'X'. Click on any of the 9 squares to make your move. The AI will automatically make its move after you. The game ends when one player wins or there's a draw. A message box will appear announcing the winner or if it's a draw.
The AI's decision-making process uses the Minimax algorithm enhanced with Alpha-Beta pruning to evaluate the game state and determine the best possible move. This algorithm considers all possible moves, their implications, and the opponent's potential responses to select the optimal move.
Feel free to fork this repository and submit pull requests to contribute to this project. You can also open issues for bugs you've found or features you think should be added.
This project is open-sourced under the MIT License.
Youssef Aitbouddroub
This project was inspired by the desire to create a challenging Tic-Tac-Toe AI.