This is a simple implementation of the classic Tic-Tac-Toe game. It can be played between two players on the same machine. The game will check for a winner after each move and declare the winner if there is one. If all positions are filled and there is no winner, it will declare the game as a draw.
- Two-player gameplay
- Checks for winner after every move
- Declares draw if all positions are filled without a winner
- User-friendly console interface
-
Clone this repository to your local machine.
git clone https://github.com/janisadhi/Tic-Tac-Toe.git cd Tic-Tac-Toe
-
Create a virtual environment.
On macOS/Linux:
python3 -m venv venv
On Windows:
python -m venv venv
-
Activate the virtual environment.
On macOS/Linux:
source venv/bin/activate
On Windows:
venv\Scripts\activate
-
Install the required dependencies from the
requirements.txt
file.pip install -r requirements.txt
-
Run the game using the following command:
python app.py
-
Follow the on-screen prompts to play the game.
- The game is played by two players. Player 1 uses
X
, and Player 2 usesO
. - Players take turns to place their mark on the 3x3 grid.
- The first player to align three marks in a row (vertically, horizontally, or diagonally) wins.
- If all positions are filled and no one wins, the game will declare a draw.
Player 1 (X) - Choose a position between 1-9: 1
Player 2 (O) - Choose a position between 1-9: 5
Player 1 (X) - Choose a position between 1-9: 9
Player 2 (O) - Choose a position between 1-9: 3
... and so on.
Player 1 wins!
- Python 3.x
- Dependencies listed in
requirements.txt