This is a classic Tic-Tac-Toe game built in modern C++ with a clean, object-oriented design. It features a challenging AI opponent that uses the Minimax algorithm to ensure it never loses. The game is played entirely in the console.
- Multiple Game Modes:
- Human vs. AI: Test your skills against an unbeatable AI.
- Human vs. Human: Play with a friend on the same machine.
- AI vs. AI: Watch two AI players battle it out.
- Unbeatable AI: The AI opponent uses the Minimax algorithm to determine the optimal move in any situation.
- Clean Codebase: The project is structured with a clear separation of concerns, using modern C++ practices like smart pointers and classes for the Game, Board, and Players.
- Easy to Build: Comes with a pre-configured VS Code build task for one-click compilation.
The project uses a standard and clean directory layout to keep the codebase organized:
.
├── build/ # Compiled output goes here
├── include/ # Header files (.hpp)
│ ├── Board.hpp
│ ├── Game.hpp
│ └── Player.hpp
├── src/ # Source files (.cpp)
│ ├── Board.cpp
│ ├── Game.cpp
│ ├── main.cpp
│ └── Player.cpp
├── .gitignore # Files to be ignored by Git
└── README.md # This filePrerequisites To build and run this project, you will need a C++ compiler that supports the C++17 standard (like g++).
- g++ compiler: Can be installed on Linux with
sudo apt-get install build-essentialor on Windows viaMinGW/MSYS2.
With VS Code (Recommended) Step by step:
- Open the project folder in Visual Studio Code.
- Press Ctrl+Shift+B (or Cmd+Shift+B on Mac) to run the default build task.
- The compiled executable will be created at build/game.
Manually from the Terminal Navigate to the root directory of the project and run the following command:
g++ -std=c++17 -Iinclude src/*.cpp -o build/gameAfter building the project, you can run the game from the root directory with this command:
./build/gameYou will be greeted with the main menu where you can select your desired game mode.
Note: All of the explanatory comments within the source code for this project were generated by an AI assistant. While they aim to be accurate and helpful, there is a possibility of error. If you find a comment that is incorrect, unclear, or misleading, please feel free to open an issue in the repository to report it. Your feedback is appreciated!
This project is currently unlicensed. Feel free to use and modify the code as you see fit.