A Python-based Tic-Tac-Toe game for single-player and two-player modes, featuring a saving and loading system and variable difficulty levels.
This Tic-Tac-Toe game allows players to:
- Play against a computer (single-player) with two difficulty levels: Easy and Medium.
- Compete against another player in a two-player mode.
- Save game progress and resume at any time.
The game provides an intuitive interface, ensures valid moves, and includes a mechanism to block winning moves in the Medium difficulty level.
-
Game Modes:
- Single-player mode with Easy and Medium difficulties.
- Two-player mode.
-
Saving and Loading:
- Save game state to a file.
- Load and resume a saved game.
-
Game Logic:
- Win detection for rows, columns, and diagonals.
- Computer AI to make random moves (Easy) or block opponent's winning moves (Medium).
-
Error Handling:
- Invalid input detection.
- Prevention of overwriting filled positions.
- Clone or download the repository to your local machine.
- Ensure Python 3.6 or higher is installed.
- Run the
main.pyfile to start the game:python main.py
- Follow the on-screen instructions to choose a game mode and difficulty level.
-
Prerequisites:
- Python 3.6 or higher.
-
Steps:
- Clone the repository:
git clone https://github.com/neverneeth/tic-tac-toe.git
- Navigate to the project directory:
cd tic-tac-toe - Run the game:
python main.py
- Clone the repository:
-
Controls:
- Enter a number between 1-9 to place your mark on the grid.
- Save progress anytime by entering 'S'.
-
Game Rules:
- A player wins by forming a row, column, or diagonal of their mark ('O' or 'X').
- The game ends in a draw if the grid is full with no winner.
- Add a "Hard" difficulty level with advanced AI strategies.
- Improve user interface with a graphical display using libraries like
tkinterorpygame. - Enable multiplayer mode over a network.
Enjoy playing Tic-Tac-Toe!