0% found this document useful (0 votes)
102 views1 page

MiniMax Algorithm

This document describes the MiniMax algorithm for game playing and decision making. It explains the core steps of the algorithm: 1. Generate all possible future moves from the current position and evaluate each move recursively using MiniMax. 2. Keep track of the best move by comparing the evaluation of each possible future position to a "best score". 3. Return the move leading to the position with the highest evaluation from the player's perspective as the recommended move.

Uploaded by

Rashi Baranwal
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)
102 views1 page

MiniMax Algorithm

This document describes the MiniMax algorithm for game playing and decision making. It explains the core steps of the algorithm: 1. Generate all possible future moves from the current position and evaluate each move recursively using MiniMax. 2. Keep track of the best move by comparing the evaluation of each possible future position to a "best score". 3. Return the move leading to the position with the highest evaluation from the player's perspective as the recommended move.

Uploaded by

Rashi Baranwal
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/ 1

B.S.

= - 2 For A
MiniMax Algorithm B.P= A-C-I Value = -2
A
18 February 2022 14:07 Path= A-C-I

Algorithm: MINIMAX(Position, Depth, Player)


B.S.=6
1. DEEP-ENOUGH(Position, Depth), Then return the structure B.P= B-F
B C B.S.=2 D
VALUE= STATIC(Position, Player) B.P=C-I
PATH= NIL
This indicate that there is no path from this node and that its value is
that determined by static evaluation function. For D
Value =4
E F G H I J K
2. Otherwise, generate one more ply of the tree by calling the function Path= D-J
MOVE-GEN( Position, Player) and setting SUCCESSORS to the list its New value= -4
9 -6 0 0 -2 -4 -3
return.

3. If SUCCESSOR is empty, then there are no moves to be made, so return For D


MiniMax (A,0,P1) For F
the same structure that would have been returned if DEEP-ENOUGH had R.S.= Minimax(D,1,P2)
1. False R.S.=MiniMax( F,2,P1)
returned true. 1.False
2. MOVE-GEN(A,P1) 1. TRUE
3. False 2. MOVE-GEN(D,P2)
3. False
4. If SUCCESSORS is not empty, then examine each element in turn and keep 4. SUCC(B,C,D) Value= STATIC(F,P1)
4. SUCC(J,K)
track of the best one. This is done as follows Value=-6
For J
For B Path= NIL R.S. = MiniMax(J,2,P1)
Initialize BEST-SCORE to the minimum value that STATIC can return. R.S.= Minimax(B,1,P2) New Value= -(-6)=6 1. TRUE
IT will be updated to reflect the best score that can be achieved by 1. False Value= STATIC (J,P1)
an element of SUCCESSORS for each element SUCC of SUCCESSORS, 2. MOVE-GEN(B,P2) For G Value=-4
do the following: 3. False R.S.= MiniMax(G,2,P1) Path=NIL
4. SUCC(E,F,G) 1. TRUE New Value= -(-4)=4
(a) Set RESULT-SUCC to
Value= STATIC(G,P1)
MINIMAX (SUCC, Depth +1,OPPOSITE (player))
This recursive call to MINIMAX will actually carry out the For E Value=0
exploration of SUCC. R.S= MiniMax(E,2,P1) Path= NIL
(b) SET NEW-VALUE to - VALUE(RESULT-SUCC), This will cause it to reflect the 1. TRUE New Value=0
merits of the position from the opposite perspective from that of the next Value =STATIC(E,P1)
lower level. Value=9 So B.S.=6
(c) If NEW-VALUE > BEST -SCORE, Then we have found a SUCCESSOR that is Path=NIL B.P.= B-F
better than any that have been examined so far. Record this by doing the New value= -9
following: Path= B-E
(i) SET BEST-SCORE to NEW-VALUE
(ii) The Best Known path is now from CURRENT to SUCC and then on to the
appropriate path down from SUCC as determined by the recursive call to
For B
MINIMAX. So set BEST-PATH to the result of attaching SUCC to the front 1. TRUE
of PATH(RESULT-SUCC) For C
Value= STATIC(B,P2)
R.S.=MiniMax(C,1,P2) Value=6
5. Now that all the successor have been examined, we know the value of 1. False Path=B-F
position as well as which path to take from it. So return the structure 2. MOVE-GEM(C,P2) New value=-6
VALUE=BEST-SCORE 3. False
PATH=BEST PATH 4. SUCC(H,I) For I
R.S= MiniMax=(I,2,P1)
For H 1. TRUE
R.S= MinMax(H,2,P1) Value= STATIC(I,P1)
For C 1. TRUE Value =-2
Value =2 Value= STATIC(H,P1)
Path=NIL
Path= C-I Value=0
Path=NIL
New Value=-(-2)=2
New Value = -2
New Value=0

New Section 1 Page 1

You might also like