This repository contains a Python-based implementation of the classic Tic Tac Toe game. It supports two modes:
- Console Mode: Play via the terminal/console.
- Graphical User Interface (GUI) Mode: A more interactive experience using a graphical interface powered by
tkinter
.
- Play against a simple AI opponent.
- Choose your marker (
X
orO
) and whether to go first. - Randomized AI strategy with basic logic for selecting moves.
- Simple, text-based board visualization.
- Interactive board implemented with
tkinter
. - Displays the current player and updates dynamically.
- Reset functionality to play multiple rounds.
- Automatic detection of winner or tie.
Ensure you have Python installed on your system. The game requires:
tkinter
(pre-installed with Python on most systems).
To check if tkinter
is installed, run the following command in Python:
import tkinter
Clone the repository:
git clone https://github.com/Victor-M16/Python-Tic-tac-toe-game.git
cd Python-Tic-tac-toe-game
Run the game from the terminal:
python main.py
Run the GUI version:
python gui.py
- You'll be prompted to select your marker (
X
orO
). - The game will randomly select who plays first.
- Enter your moves by specifying the row and column (1-3 for both).
- The game announces the winner or if it's a tie.
- Launch the game to see the 3x3 grid.
- Click on a cell to place your marker (
X
orO
). - The game will indicate the current player and announce the winner or a tie.
- Click Reset to start a new game.
| |
-----------
| X |
-----------
| | O
Your move
Feel free to modify the code for:
- Enhancing the AI logic in
ComputerPlayer
. - Improving GUI aesthetics in the
TicTacToe
class. - Adding new features like multiplayer support or sound effects.
This project was developed as a learning exercise following a tutorial. The implementation includes enhancements in logic and interactivity for both modes.
This project is open-source and available under the MIT License.