Skip to content

giansimone/tic-tac-toe-cpp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

License

Tic-Tac-Toe in C++

A text-based Cimplementation of the classic Tic-Tac-Toe game developed in C++.

Features

  • Playable on a 3x3 grid.
  • Randomly selects the first player (X or O).
  • Detect wins, draws, and invalid moves.
  • Option to play again after a game ends.
  • Clean and simple text-based interface.

Getting Started

Prerequisites

  • A C++ compiler (e.g., clang++ or g++).
  • make build tool.

Building the Project

  1. Clone the repository:
  git clone https://github.com/giansimone/tic-tac-toe-cpp.git
  1. Navigate the project directory:
  cd tic-tac-toe-cpp
  1. Build the project:
  make
  1. To build the project in debug mode:
  make debug
  1. To build the project in release mode:
  make release
  1. To clean the build files:
  make clean

Running the game

After building, run the game using:

  ./bin/tictactoe

How to Play

  1. The game starts with an empty grid.
  2. The first player is randomly chosen.
  3. Players take turns entering the row and column numbers where they want to place their mark.
  • The board positions are numbered as follows:
    1 | 2 | 3
    --+---+--
    4 | 5 | 6
    --+---+--
    7 | 8 | 9
    
  1. The game continues until there is a winner or the game ends in a draw.
  2. The game announces the result and asks if you want to play again.
  3. Enter 'y' or 'n' to continue or exit the game.

License

This project is licensed under the MIT License. See the LICENSE file for details.

About

A text-based C++ implementation of the Tic-Tac-Toe game.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published