This is a simple Tic-Tac-Toe game implemented using Python and Pygame, featuring a computer opponent that uses the Minimax algorithm to play optimally and is unbeatable.
- Single-player Mode: Play against the computer.
- AI Opponent: The computer uses the Minimax algorithm to make optimal moves.
- Graphical Interface: Built using Pygame for a simple and interactive gaming experience.
- Responsive Game Board: The game board dynamically updates as players make moves.
-
Clone the Repository:
git clone https://github.com/Navnoorsinghmahal/TicTacTactician.git
-
**Navigate to the Project Directory:
cd TicTacTactician
- Install the Required Dependencies: Ensure you have Python installed. Then, install the dependencies:
pip install pygame numpy
- Run the Game:
python tictactactician.py
- Objective: The goal is to get three of your marks in a row (horizontal, vertical, or diagonal) before the computer does.
- Player vs. AI: You play as the first player (X), and the computer plays as the second player (O).
- Gameplay: Click on any empty square to place your mark. The computer will automatically take its turn after yours.
The Minimax algorithm is used in this project to enable the AI to make the best possible move. It explores all possible game states and chooses the move that minimizes the possible loss for the worst-case scenario.
- Maximizing: The AI seeks to maximize its score by choosing moves that give it the highest possible outcome.
- Minimizing: When it’s the player’s turn, the AI assumes the player will make moves that minimize the AI's score.
TicTacTactician/
├── main.py # Main game script
├── README.md # Project README file
└── requirements.txt # Project dependencies
- Python: Core language used for development.
- Pygame: Library used to create the graphical interface and manage game events.
- NumPy: Library used for handling the game board as a 2D array.