Play Tic-Tac-Toe in Python! Includes user-friendly gameplay for 2 players or against the computer.
This is a Python-based Tic-Tac-Toe game that allows both multiplayer and single-player modes. In single-player mode, the player competes against the computer, which uses the Minimax algorithm to make optimal moves.
- Multiplayer mode: Play against a friend on the same device.
- Single-player mode: Play against the computer with AI powered by the Minimax algorithm.
- Terminal-based interface: The game runs in the command line/terminal.
- Optimal AI: In single-player mode, the AI makes the best possible moves using Minimax to ensure it doesn’t lose.
-
Clone this repository to your local machine.
-
Ensure you have Python 3 installed.
-
No additional libraries are required for this project as it only uses built-in Python modules.
- The game will prompt each player to input their move (row and column) on the board.
- Players alternate turns, and the first one to align three marks (either 'X' or 'O') wins.
- The player will input their move (row and column), and then the AI will make its move using the Minimax algorithm.
- The AI will always attempt to make the best possible move, and it's nearly impossible for the player to win if playing optimally.
When running the game in single-player mode, the game interface will look like this: