A simple and interactive console-based Tic-Tac-Toe game developed using C++. This project is perfect for beginners who want to understand core programming concepts like functions, loops, vectors, and basic game logic.
- Two-player mode (Player X vs Player O)
- Simple and clean command-line interface
- Real-time board display after each move
- Automatic win detection (rows, columns, diagonals)
- Tie detection
- Input validation (prevents invalid and repeated moves)
- Option to play again without restarting the program
- Language: C++
- Libraries:
<iostream><vector>
- Concepts Covered:
- Functions
- Loops
- Conditional statements
- Vectors
- User input/output
📦 Tic-Tac-Toe
┣ 📜 tic_tac_toe.cpp # Main game source code
┗ 📘 README.md # Project documentation
git clone https://github.com/your-username/tic-tac-toe-cpp.gitcd tic-tac-toe-cppg++ tic_tac_toe.cpp -o tic_tac_toe./tic_tac_toe💡 Windows Users: Run
tic_tac_toe.exe
-
The board consists of 9 positions (1–9)
-
Players take turns entering a position number
-
Player 1 uses X
-
Player 2 uses O
-
The first player to get three marks in a row, column, or diagonal wins
-
If all positions are filled and no one wins, the game ends in a tie.
-
displayBoard()→ Displays the current state of the board -
getPlayerMove()→ Takes and validates user input -
checkWin()→ Checks all possible winning combinations -
checkTie()→ Determines if the game is tied
The game runs until a win or tie condition is met.
X | O | X
O | X | O
X | | O
-
Single-player mode (play against computer)
-
Score tracking system
-
Colored terminal output
-
Graphical User Interface (GUI) version
Arpit Singh Tomar
If you like this project:
-
⭐ Star the repository
-
🍴 Fork it
-
🧑💻 Contribute improvements
🙌 Thank you for checking out this project!
Happy Coding 🚀