This is a tic-tac-toe game where a human is going to play against AI.# Unbeatable Tic Tac Toe Game. This is a Python implementation of the classic Tic Tac Toe game, where you can play against an unbeatable AI opponent. The AI uses the minimax algorithm to make optimal moves and ensure it never loses.
Here are the steps to play the Tic-Tac-Toe game:
- Run the Python code called tictactoe.py to initiate the game. To run this code, you need to make sure you have Pygame and Numpy installed. You can install Pygame using the following command:
pip install pygame
andpip install numpy
- The game board will be presented on the screen, displaying a 3x3 grid.
- By default, the game is configured in AI mode, enabling you to play against an AI opponent that cannot be defeated. To switch to player vs. player mode, press the 'g' key on your keyboard.
- In AI mode, you have the option to adjust the AI level. Press the '0' key to set it to random moves or the '1' key to set it to the impossible level.
- To make a move, select any unoccupied square on the game board by clicking on it.
- After you make your move, the AI opponent will automatically generate its move.
- If desired, you can restart the game at any point by pressing the 'r' key on your keyboard.
Have fun !!!