This repository contains a Tic Tac Toe game implemented in Python using Pygame. It features a graphical interface, AI opponent, and sound effects. The AI uses the Alpha-Beta pruning algorithm for optimal moves.
- Graphical Interface: Draws the Tic Tac Toe grid and updates it interactively.
- AI Opponent: An AI opponent using the Alpha-Beta pruning algorithm.
- Sound Effects: Sounds for player and AI moves, along with game notifications.
- Dynamic Score Tracking: Keeps track of wins, losses, and draws.
-
Clone the repository:
git clone https://github.com/am94an/TicTacToe.git cd TikTakToe -
Install required dependencies:
pip install pygame
-
Ensure you have Python 3.x installed.
-
Run the game:
python tic_tac_toe.py
-
Follow the instructions on the screen.
- Press any key to start.
- Make moves by clicking on the grid.
- Press 'R' to restart or 'Q' to quit after the game ends.
- Manages the game state, board updates, and checks for winners.
- Implements the Alpha-Beta pruning algorithm for optimal AI decisions.
- Handle drawing the board, start screen, end screen, and score screen.
- The main game loop that handles events and alternates turns between the player and AI.
-
Game Loop:
- The game alternates turns between the player (X) and AI (O).
- The game ends when there is a winner or a draw.
-
AI Logic:
- Uses Alpha-Beta pruning for efficient decision-making.
- The AI prioritizes winning moves, blocking the player, and minimizing/maximizing scores.
-
Pygame Interface:
- Draws the grid and game elements dynamically.
- Handles mouse input for player moves.
-
Sound Effects:
- Uses Pygame's mixer to play sound effects for moves and game notifications.
- Multiplayer Mode: Add support for two players.
- Difficulty Levels: Allow players to choose between Easy, Medium, and Hard AI.
- Mobile Compatibility: Develop a mobile-friendly version.
- Enhanced Graphics: Improve the visual appeal with animations and better designs.
Feel free to fork this repository, make changes, and create pull requests. Contributions are welcome!
This project is licensed under the MIT License. See the LICENSE file for details.
- Pygame Documentation
- Inspiration from classic Tic Tac Toe games.