0% found this document useful (0 votes)
10 views6 pages

AI (Exp 6)

Artificial intelligence experiment

Uploaded by

dev606033
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views6 pages

AI (Exp 6)

Artificial intelligence experiment

Uploaded by

dev606033
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

UG Program in Artificial Intelligence & Data Science

Experiment 6

Experiment No. - 6

Date of Performance: 26/08/24

Date of Submission: 02/09/24

Program Execution/ Viva

formation/correction/ Answer to

ethical practices Documentation Timely sample Experiment Sign with


Date
(07) (02) Submission questions Total (15)

(03) (03)

6.1 Aim:

To implement adversarial search using the Minimax algorithm for a two-player game and demonstrate
the strategy for winning.

6.2 Course Outcome (CO):

CO 2: Apply the most suitable search strategy and represent a natural language description of statements
in logic and apply the inference rules to design problem-solving agents.

6.3 Problem Statement:

Implement the Minimax algorithm for a simple two-player game, such as Tic-Tac-Toe. Demonstrate
how the algorithm helps in finding the optimal strategy for the maximizing player.

Artificial Intelligence Lab (ADLR0503) A.Y. 2024-25 1-33


UG Program in Artificial Intelligence & Data Science

6.4 Related Theory:

The Minimax algorithm is a decision-making algorithm used in adversarial games, such as Tic-Tac-
Toe, Chess, and Checkers. It is designed to minimize the possible loss in a worst-case scenario, and it
assumes that both players (the maximizing and minimizing players) play optimally.

 Maximizing Player: The player who tries to maximize their chances of winning.
 Minimizing Player: The opponent who tries to minimize the maximizing player’s chances of winning.

The algorithm evaluates the game tree recursively:

 The maximizing player chooses the move that leads to the highest possible score.
 The minimizing player chooses the move that leads to the lowest possible score.

Example: Tic-Tac-Toe Game Tree

Consider the following Tic-Tac-Toe configuration where it’s the turn of the maximizing player (X):

X | O | X

O | X |

| O |

The maximizing player (X) has two possible moves: placing X in either the bottom-left or bottom-right
empty cell.

Minimax Algorithm Steps:

1. The algorithm recursively explores all possible moves.


2. The maximizing player evaluates each move based on the possible outcomes (win, lose, or draw).
3. The minimizing player, on their turn, tries to minimize the maximizing player's chances of winning.

Manual Solution using Minimax:

Let’s build the game tree manually:

1. Initial Board (X’s turn):

X | O | X X | O | X

O | X | OR O | X |

| O | X X | O |

Artificial Intelligence Lab (ADLR0503) A.Y. 2024-25 1-34


UG Program in Artificial Intelligence & Data Science

o Left board: X is placed in the bottom-left cell.


o Right board: X is placed in the bottom-right cell.
2. Opponent (O)’s Response: After the maximizing player (X) makes their move, the minimizing
player (O) responds:

For the left board:

X | O | X

O | X |

O | O | X

For the right board:

X | O | X

O | X |

X | O | O

3. Outcome Evaluation:
o Left board: The game results in a draw since neither player can win.
o Right board: The game results in a draw as well.
4. Minimax Decision: Since both options lead to a draw, the Minimax algorithm will choose the
first available move. The final move for X would be in the bottom-left cell (arbitrarily chosen
since both outcomes are equal).

6.5 Program Listing and Output:

Artificial Intelligence Lab (ADLR0503) A.Y. 2024-25 1-35


UG Program in Artificial Intelligence & Data Science

Artificial Intelligence Lab (ADLR0503) A.Y. 2024-25 1-36


UG Program in Artificial Intelligence & Data Science

6.6 Procedure:

1. Understand the Problem:

Artificial Intelligence Lab (ADLR0503) A.Y. 2024-25 1-37


UG Program in Artificial Intelligence & Data Science

o The objective is to implement the Minimax algorithm for a two-player game like Tic-Tac-Toe.
2. Define the Game Environment:
o Create a 3x3 grid for the Tic-Tac-Toe game.
3. Write the Evaluation Function:
o Implement a function to evaluate the board for win, loss, or draw conditions.
4. Implement Minimax:
o Write the Minimax function to recursively explore the game tree and return the best move for the
maximizing player.
5. Run the Program:
o Test the program with various configurations and verify that the algorithm returns the optimal
move.
6. Analyze the Output:
o The output should show the optimal value for the maximizing player, which in the case of a draw
would be 0.

6.7 Conclusion:

The implementation of the Minimax algorithm demonstrates its effectiveness in determining


optimal strategies in competitive environments. The algorithm constructs a game tree where
each node represents a possible state of the game, allowing players to backtrack from terminal
states to make informed decisions. This recursive evaluation not only guarantees that MAX
plays optimally but also assumes that MIN will do the same, creating a robust framework for
strategic decision-making.

6.8 Questions:

1. What is the Minimax algorithm, and how is it used in adversarial games?


2. How does the Minimax algorithm determine the best move for the maximizing player?
3. Explain the concept of game trees and how they are used in the Minimax algorithm.
4. Write a program to implement the Minimax algorithm for the game of Checkers.
5. What are the limitations of using the Minimax algorithm in large games such as Chess?
6. How can you improve the efficiency of Minimax using Alpha-Beta pruning?
7. What are the advantages of using a depth-limited version of Minimax for complex games?
8. In what situations might the Minimax algorithm fail to return an optimal result?
9. How does the evaluation function affect the performance of Minimax?
10. Discuss the impact of computational resources on the performance of Minimax in complex games.

Artificial Intelligence Lab (ADLR0503) A.Y. 2024-25 1-38

You might also like