AI Ca1
AI Ca1
Presented By
Tic Tac Toe is a classic two-player pencil-and-paper game played on a 3x3 grid. The players take
turns placing their symbols (usually "X" for the first player and "O" for the second player) on an
empty cell in the grid.
The objective of the game is to create a straight line of three of your symbols (horizontally,
vertically, or diagonally) before your opponent does.
The first player to achieve this objective wins the game. If all cells are filled without either player
achieving a winning line, the game ends in a draw.
Rules of the Game:
3.Players can place their symbols in any empty cell on the grid during their turn
4.The objective is to create a straight line of three of your symbols (horizontally, vertically, or
diagonally).
5.If a player succeeds in creating a winning line, they win the game.
6.If all cells are filled without any player achieving a winning line, the game ends in a draw.
How Can AI Solve the Tic Tac Toe
Problem?
:
A. Minimax algorithm
B. Alpha-Beta Pruning(optimization of minimax )
MINIMAX
ALGORITHM:
How does it
work ?
The Minimax algorithm is a decision-making algorithm 1.Tree Representation: The game state is represented as a tree, where each node
used in two-player, zero-sum games like Tic Tac Toe, corresponds to a game position, and edges represent valid moves that lead to other
chess, checkers, and many others. positions.
It is designed to find the optimal move for a player by 2.Recursive Evaluation: Starting from the current game state, the algorithm
exploring the entire game tree. recursively evaluates all possible moves by assuming both players play optimally
3.Terminal Nodes: When the algorithm reaches a terminal node (a state where the
game ends), it assigns a score to that position.
4.Backtracking: As the algorithm explores deeper levels of the tree, it backtracks and
propagates the scores upward to evaluate the parent nodes.
5.Optimal Move: After evaluating all possible moves, the Minimax algorithm selects
the move that leads to the highest score at the root level.
Advantages :
Alpha-Beta Pruning:
Alpha-Beta Pruning maintains two
values, alpha and beta, which represent
the best known scores for the
During the recursive evaluation, the
algorithm prunes branches of the tree
where the evaluation of a node reveals
that it won't affect the final decision.
By pruning these branches, the
algorithm avoids unnecessary
evaluations, making the search much
To address the limitations of the faster while still guaranteeing the same
basic Minimax algorithm, Alpha- optimal move as the basic Minimax
algorithm.
Beta Pruning is used as an Alpha-Beta Pruning significantly
optimization. improves the performance of the
It helps reduce the number of Minimax algorithm and is widely used
nodes explored by eliminating in various AI applications for games and
optimization problems.
irrelevant branches, leading to a
faster and more efficient search.
When an AI algorithm, such as Minimax with
Alpha-Beta Pruning and a suitable heuristic,
is implemented for Tic Tac Toe, it becomes a
formidable opponent.
In most cases, the AI will play perfectly or
force a draw, given that the game is well-
implemented and the AI explores the entire
AI vs. Human game tree.
Gameplay: Humans, on the other hand, might make
mistakes or overlook certain strategic moves,
making it easier for the AI to win.
In general, AI will outperform human players
in Tic Tac Toe due to its ability to explore the
entire game tree and make optimal decisions
based on perfect information.
Humans might win against AI under some
circumstances if the AI is not fully optimized
or if the human player is highly skilled and
capable of exploiting certain weaknesses or
unpredictable patterns.
Challenges in
Implementing AI for
Tic Tac Toe: