Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

🎮 Tic-Tac-Toe Game in C++

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.


✨ Features

  • 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

🛠️ Technologies Used

  • Language: C++
  • Libraries:
    • <iostream>
    • <vector>
  • Concepts Covered:
    • Functions
    • Loops
    • Conditional statements
    • Vectors
    • User input/output

📂 Project Structure

📦 Tic-Tac-Toe

┣ 📜 tic_tac_toe.cpp # Main game source code

┗ 📘 README.md # Project documentation



▶️ How to Run the Project

1️⃣ Clone the Repository

git clone https://github.com/your-username/tic-tac-toe-cpp.git

2️⃣ Navigate to the Project Directory

cd tic-tac-toe-cpp

3️⃣ Compile the Program

g++ tic_tac_toe.cpp -o tic_tac_toe

4️⃣ Run the Game

./tic_tac_toe

💡 Windows Users: Run tic_tac_toe.exe


🎯 How to Play

  • 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.


🧠 Game Logic Overview

  • 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.


📸 Sample Output

 X | O | X

 O | X | O
 
 X |   | O

🚀 Future Improvements

  • Single-player mode (play against computer)

  • Score tracking system

  • Colored terminal output

  • Graphical User Interface (GUI) version


👨‍💻 Author

Arpit Singh Tomar


⭐ Support

If you like this project:

  • ⭐ Star the repository

  • 🍴 Fork it

  • 🧑‍💻 Contribute improvements


🙌 Thank you for checking out this project!

Happy Coding 🚀

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages