Before you begin, ensure you have met the following requirements:
-
C++ Compiler
-
CMake (for building)
To build the project, follow these steps:
- Clone the repository to your local machine:
git clone https://github.com/realayna/tictac-toe-ai.git
- Navigate to the project directory:
cd tictac-toe-ai
- Create a build directory and navigate to it:
mkdir build
cd build
- Generate build files with CMake:
cmake ..
- Build the project:
make
After building the project, you can run the Tic-Tac-Toe game:
./tictac-toe-ai
- The game is played on a 3x3 board.
- You (PLAYER_O) play against the AI (PLAYER_X).
- Enter your moves by specifying the row and column (1-based) where you want to place your mark.
- The AI will take its turn immediately after you make your move.
- The game ends when there's a winner or a draw.
The AI opponent in this game is implemented using the minimax algorithm. It explores all possible moves to find the best one for the AI and make the game challenging for the player.
main.cpp
: Contains the main game loop and user interaction.tictactoe.h
: Header file defining constants, data structures, and function prototypes.tictactoe.cpp
: Implementation of game logic and AI using minimax.CMakeLists.txt
: CMake configuration file for building the project.
Contributions are welcome! If you'd like to contribute to this project, please follow these steps:
- Fork the repository.
- Create a new branch for your feature or bug fix.
- Make your changes and commit them with descriptive messages.
- Push your branch to your fork.
- Open a pull request to the main repository's
main
branch.