Skip to content

devnek/tic-tac-toe

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tic-Tac-Toe

A simple Tic-Tac-Toe game written in C++ with unit tests using Google Test.

Prerequisites

  • CMake (version 3.14 or higher)
  • A C++ compiler supporting C++14 or higher.
  • Internet connection (to fetch Google Test automatically via CMake).

Building the Project

Generic Build (All Platforms)

  1. Create a build directory:
    mkdir build
    cd build
  2. Generate build files:
    cmake ..
  3. Build the project:
    cmake --build .

Windows

Using Visual Studio (MSVC)

  1. Open "Developer Command Prompt for VS".
  2. Navigate to the project root.
  3. Run:
    mkdir build
    cd build
    cmake ..
    cmake --build . --config Release
    The executable will be in build/Release/tic_tac_toe.exe.

Using MinGW/GCC

  1. Open your terminal (e.g., PowerShell or CMD).
  2. Run:
    mkdir build
    cd build
    cmake -G "MinGW Makefiles" ..
    cmake --build .

macOS (Clang)

  1. Open Terminal.
  2. Run:
    mkdir build
    cd build
    cmake ..
    make

Linux (GCC)

  1. Open Terminal.
  2. Run:
    mkdir build
    cd build
    cmake ..
    make

Running the Game

After building, run the executable:

  • Windows: build\tic_tac_toe.exe (or build\Release\tic_tac_toe.exe)
  • macOS/Linux: ./tic_tac_toe (inside the build directory)

Running Tests

To run the unit tests:

  1. Navigate to the build directory.
  2. Run the test executable:
    • Windows: build\tic_tac_toe_tests.exe (or build\Release\tic_tac_toe_tests.exe)
    • macOS/Linux: ./tic_tac_toe_tests
  3. Alternatively, use CTest:
    ctest --output-on-failure

Controls

The game uses a keyboard-based grid:

  • q w e
  • a s d
  • z x c

Each key corresponds to a position on the 3x3 board.

About

A minimalistic C++ Tic-Tac-Toe game featuring a logic-based AI and automated unit tests. Built with CMake for cross-platform compatibility and integrated with Google Test for robust verification.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors