Upload
ahmed-gad
View
171
Download
2
Embed Size (px)
Citation preview
AI Game Search
MENOUFIA UNIVERSITYFACULTY OF COMPUTERS AND INFORMATION
ALL DEPARTMENTSARTIFICIAL INTELLIGENCE
جامعة المنوفية
كلية الحاسبات والمعلومات
جميع األقسام
اإلصطناعيالذكاء
جامعة المنوفية
Ahmed Fawzy Gad
Minimax Game SearchTwo Players take turns:
Max and Min
Max : Maximizes Score.Min : Minimizes Score.
MAX
Minimax Game SearchTwo Players take turns:
Max and Min
Max : Maximizes Score.Min : Minimizes Score.
MAX
MIN
Minimax Game SearchTwo Players take turns:
Max and Min
Max : Maximizes Score.Min : Minimizes Score.
Special Case.Max is an expert.Min is a beginner.
MAX
MIN
Minimax Game Search
Which node to follow?No heuristic values.
A
B C
Hot to find heuristic values for other nodes?
Minimax Game Search
Which node to follow?No heuristic values.
A
B C
Hot to find heuristic values for other nodes?
Use children heuristics to calculate parent heuristic.
Minimax Game Search
Which node to follow?No heuristic values.
A
B C
Hot to find heuristic values for other nodes?
Use children heuristics to calculate parent heuristic.
Minimax Game Search Steps
Minimax Game Search
Which node to follow?No heuristic values.
A
B C
Hot to find heuristic values for other nodes?
Use children heuristics to calculate parent heuristic.
Minimax Game Search Steps
Calculate Heuristics
Minimax Game Search
Which node to follow?No heuristic values.
A
B C
Hot to find heuristic values for other nodes?
Use children heuristics to calculate parent heuristic.
Minimax Game Search Steps
Calculate Heuristics
Search
Phase 1 : Heuristic Value CalculationDepth-First Search
A
B
B
D
H I
C
D E
J
3 -2 5
B C
D E
H I J
Max
Phase 1 : Heuristic Value CalculationDepth-First Search
A
B
B
D
H I
C
D E
J
3 -2 5
B C
D E
H I J
Max
5
Phase 1 : Heuristic Value CalculationDepth-First Search
A
B
B
D
H I
C
D E
J
3 -2 5
B C
D E
H I J
Max
5
5
Phase 1 : Heuristic Value CalculationDepth-First Search
A
B
B
D
H I
C
D E
J
3 -2 5
B C
D E
H I J
Max
5
5
5
Phase 1 : Heuristic Value CalculationDepth-First Search
A
B
B
D
H I
C
D E
J
3 -2 5
B C
D E
H I J
Max
5
5
5
5
Phase 1 : Heuristic Value CalculationDepth-First Search
A
B
B
E
K L
C
D E
M
7 0 3
B C
D E
K L M
Max
5
5
Phase 1 : Heuristic Value CalculationDepth-First Search
A
B
B
E
K L
C
D E
M
7 0 3
B C
D E
K L M
Max
7
5
5
Phase 1 : Heuristic Value CalculationDepth-First Search
A
B
B
E
K L
C
D E
M
7 0 3
B C
D E
K L M
Max
7
7
5
5
Phase 1 : Heuristic Value CalculationDepth-First Search
A
B
B
E
K L
C
D E
M
7 0 3
B C
D E
K L M
Max
7
7
75
5
Phase 1 : Heuristic Value CalculationDepth-First Search
A
B
B
E
K L
C
D E
M
7 0 3
B C
D E
K L M
Max
7
7
7
Min
5
75
Phase 1 : Heuristic Value CalculationDepth-First Search
A
B
B
E
K L
C
D E
M
7 0 3
B C
D E
K L M
Max
7
7
7
Min5
55
75
Phase 1 : Heuristic Value CalculationDepth-First Search
A
B
B
E
K L
C
D E
M
7 0 3
B C
D E
K L M
Max
7
7
7
Min5
5
55
75
Phase 1 : Heuristic Value CalculationDepth-First Search
A
B
B
E
K L
C
D E
M
7 0 3
B C
D E
K L M
Max
7
7
7
Min5
5
55
7
5
5
Phase 1 : Heuristic Value CalculationDepth-First Search
A
B
C
F
N O
C
F G
P
0 -5 4
B C
N O P
5
F G
7
5
5
Phase 1 : Heuristic Value CalculationDepth-First Search
A
B
C
F
N O
C
F G
P
0 -5 4
B C
N O P
Max
5
F G
7
5
5
Phase 1 : Heuristic Value CalculationDepth-First Search
A
B
C
F
N O
C
F G
P
0 -5 4
B C
N O P
Max
4
5
F G
7
5
5
Phase 1 : Heuristic Value CalculationDepth-First Search
A
B
C
F
N O
C
F G
P
0 -5 4
B C
N O P
Max
4
5
4
F G
7
5
5
Phase 1 : Heuristic Value CalculationDepth-First Search
A
B
C
F
N O
C
F G
P
0 -5 4
B C
N O P
Max
4
5
4
F G4
7
5
5
Phase 1 : Heuristic Value CalculationDepth-First Search
A
B
C
F
N O
C
F G
P
0 -5 4
B C
N O P
Max
4
5
4
F G4
47
5
5
Phase 1 : Heuristic Value CalculationDepth-First Search
A
B
C
G
Q R
C
F G
S
-6 8 2
B C
Q R S
5
F G4
47
5
5
Phase 1 : Heuristic Value CalculationDepth-First Search
A
B
C
G
Q R
C
F G
S
-6 8 2
B C
Q R S
Max
5
F G4
47
5
5
Phase 1 : Heuristic Value CalculationDepth-First Search
A
B
C
G
Q R
C
F G
S
-6 8 2
B C
Q R S
Max
8
5
F G4
47
5
5
Phase 1 : Heuristic Value CalculationDepth-First Search
A
B
C
G
Q R
C
F G
S
-6 8 2
B C
Q R S
Max
8
5
8
F G4
47
5
5
Phase 1 : Heuristic Value CalculationDepth-First Search
A
B
C
G
Q R
C
F G
S
-6 8 2
B C
Q R S
Max
8
5
8
F G4 8
47
5
5
Phase 1 : Heuristic Value CalculationDepth-First Search
A
B
C
G
Q R
C
F G
S
-6 8 2
B C
Q R S
Max
8
5
8
F G4 8
Min
847
5
5
Phase 1 : Heuristic Value CalculationDepth-First Search
A
B
C
G
Q R
C
F G
S
-6 8 2
B C
Q R S
Max
8
5
8
F G4 8
Min4
4
847
5
5
Phase 1 : Heuristic Value CalculationDepth-First Search
A
B
C
G
Q R
C
F G
S
-6 8 2
B C
Q R S
Max
8
5
8
F G4 8
Min4
4
4
847
5
5
4
Max
Phase 1 : Heuristic Value CalculationDepth-First Search
A
B
C
G
Q R
C
F G
S
-6 8 2
B C
Q R S
Max
8
5
8
F G4 8
Min4
4
4
847
5
5
4
Max
Phase 1 : Heuristic Value CalculationDepth-First Search
A
B
C
G
Q R
C
F G
S
-6 8 2
B C
Q R S
Max
8
5
8
F G4 8
Min4
4
4
5
8
4
47
5
5
Max
Phase 1 : Heuristic Value CalculationDepth-First Search
A
B
C
G
Q R
C
F G
S
-6 8 2
B C
Q R S
Max
8
5
8
F G4 8
Min4
4
4
5
5
8
4
47
5
5
Max
Phase 1 : Heuristic Value CalculationDepth-First Search
A
B
C
G
Q R
C
F G
S
-6 8 2
B C
Q R S
Max
8
5
8
F G4 8
Min4
4
4
5
5
8
4
5
47
5
5
Max
Phase 1 : Heuristic Value CalculationDepth-First Search
A
B
C
G
Q R
C
F G
S
-6 8 2
B C
Q R S
Max
8
5
8
F G4 8
Min4
4
4
5
5
8
4
5
47
5
5
If both players play optimally then Max will win by a score 5.
Minimax Game Search Drawback• Expands all the tree
while not allexpanded nodes areuseful.
• In this example, justfew nodes of thewhole tree was usefulin reaching the goal.
Alpha-Beta Pruning = Minimax Except
• This game search strategy is a modification to Minimax game searchthat avoids exploring nodes that are not useful in the search.
• It gives the same results as Minimax but avoids exploring somenodes.
• In the previous example, the path explored using Minimax was A-B-D-J.
• Also the Alpha-Beta Pruning path will be A-B-D-J but withoutexploring all nodes as in Minimax.
Alpha-Beta Pruning Motivation
Never explore values that are not useful.
=Min(Max(1, 2, 5), Max(6, x, y), Max(1, 3, 4))
=Min(5, Max(6, x, y), 4)
=Min(Max(6, x, y), 4)
=4