This repository contains the code for a console-based Tic Tac Toe game written in C. The unique aspect of this program is its utilization of the Minimax algorithm with Alpha-Beta Pruning to drive the game AI. The AI is designed to make the most optimal move at every turn, ensuring a high level of difficulty.
The Minimax algorithm is a decision-making algorithm for minimax games, typically used in game theory and decision theory. It finds the optimal move for a player, assuming that the opponent is also playing optimally. In the context of this Tic Tac Toe game, it's used to decide the AI's next move by examining all the possible future game states (or the game tree) to pick the one which will be most beneficial for the AI.
However, traversing the entire game tree can be computationally expensive. That's where Alpha-Beta Pruning comes in. Alpha-Beta Pruning is an optimization technique for the Minimax algorithm. It reduces the computation by a significant amount by pruning the branches in the game tree which need not be explored because there already exists a better move available.
To clone and run this application, you'll need:
Open your terminal/command line and run the following command to clone this repository:
git clone https://github.com/moufidayoub11/tictactoe_minimax_alphabeta.git
Navigate into the cloned directory:
cd tictactoe_minimax_alphabeta
Compile the code:
gcc main.c -o tictactoe
Run the game:
./tictactoe
Follow the prompts in the console to play the game.
For more information on the Minimax algorithm and Alpha-Beta Pruning, check out the following resources: