Professional Documents
Culture Documents
CSE 481
ARTIFICIAL INTELLIGENCE
ADVERSARIAL SEARCH AND GAMES
Conventional Search
C S E 4 8 1 : A RT I F I C I A L I N T E L L I G E N C E
In conventional search
C S E 4 8 1 : A RT I F I C I A L I N T E L L I G E N C E
C S E 4 8 1 : A RT I F I C I A L I N T E L L I G E N C E
2. Successor Function
A list of (move, state) pairs specifying legal moves
3. Terminal Test
Detects a terminal state (i.e., detects if the game is finished)
4. Utility Function
Returns a numerical value for terminal states
Possibly as simple as 1 for win, 0 for lose, and -1 for draw
C S E 4 8 1 : A RT I F I C I A L I N T E L L I G E N C E
C S E 4 8 1 : A RT I F I C I A L I N T E L L I G E N C E
C S E 4 8 1 : A RT I F I C I A L I N T E L L I G E N C E
(VAL)
represents
the
Opponent node or MIN
node
C S E 4 8 1 : A RT I F I C I A L I N T E L L I G E N C E
C S E 4 8 1 : A RT I F I C I A L I N T E L L I G E N C E
C S E 4 8 1 : A RT I F I C I A L I N T E L L I G E N C E
10
C S E 4 8 1 : A RT I F I C I A L I N T E L L I G E N C E
11
C S E 4 8 1 : A RT I F I C I A L I N T E L L I G E N C E
12
Extending minimax
C S E 4 8 1 : A RT I F I C I A L I N T E L L I G E N C E
13
C S E 4 8 1 : A RT I F I C I A L I N T E L L I G E N C E
14
- pruning example
C S E 4 8 1 : A RT I F I C I A L I N T E L L I G E N C E
15
- pruning example
C S E 4 8 1 : A RT I F I C I A L I N T E L L I G E N C E
16
- pruning example
C S E 4 8 1 : A RT I F I C I A L I N T E L L I G E N C E
17
- pruning example
C S E 4 8 1 : A RT I F I C I A L I N T E L L I G E N C E
18
- pruning example
- Pruning Algorithm
C S E 4 8 1 : A RT I F I C I A L I N T E L L I G E N C E
19
C S E 4 8 1 : A RT I F I C I A L I N T E L L I G E N C E
20
=-
=+
=-
=+
=-
=+
MAX
MIN
MAX
MIN
MAX
C S E 4 8 1 : A RT I F I C I A L I N T E L L I G E N C E
21
=-
=+
=-
=+
=-
=3
3
MAX
MIN
MAX
MIN
MAX
2) Look at first computed final configuration value. Its 3. Parent is a MIN node, so
set the (min) value to 3
C S E 4 8 1 : A RT I F I C I A L I N T E L L I G E N C E
22
=-
=+
MIN
=3
=+
=3
=+
=-
= 33
3
MAX
MAX
MIN
MAX
3) Look at next value, 5. Since parent is a MIN node, we want the minimum of
3 and 5 which is 3. Parent MIN node is done fill (max) value of its parent MAX
node. Always set for MAX nodes and for MIN nodes. Copy the state of the MAX parent
node into the second unevaluated MIN child
C S E 4 8 1 : A RT I F I C I A L I N T E L L I G E N C E
23
=-
=+
MIN
=3
=+
=3
=2
=-
= 33
3
MAX
MAX
MIN
MAX
4) Look at next value, 2. Since parent node is MIN with =+, 2 is smaller, change
C S E 4 8 1 : A RT I F I C I A L I N T E L L I G E N C E
24
=-
=+
=3
=+ 3
=-
= 33
3
MAX
MIN
=3
=2
2
2
MAX
MIN
MAX
5) Now, the MIN parent node has a max value of 3 and MIN value of 2. The value of the 2nd child
does not matter. if it is >2, 2 will be selected for MIN node. If it is <2, it will be selected for MIN node,
but since it is <3 it will not get selected for the parent max node. Thus, we prune the right sub-tree of
the MIN node. Propagate MAX value up the tree
C S E 4 8 1 : A RT I F I C I A L I N T E L L I G E N C E
25
MIN
=-
=3
=3
=2
2
2
MAX
=-
=3
MAX
MIN
MAX
6) MAX node is now done and we can set the value of its parent and propagate node
state to sibling sub-trees left-most path
C S E 4 8 1 : A RT I F I C I A L I N T E L L I G E N C E
26
MIN
=-
=3
=3
=2
2
2
MAX
=-
=3
10
MAX
MIN
MAX
7) The next node is 10. 10 is not smaller than 3, so state of parent does not change. We
still have to look at the 2nd child since is still
C S E 4 8 1 : A RT I F I C I A L I N T E L L I G E N C E
27
MAX
=-
=3
=3
=+ 3
=-
= 33
3
=3
=2
2
2
MIN
=4
=3
4
=-
=3
4
MIN
10
MAX
MAX
8) The next node is 4. Smallest value goes to the parent MIN node. MIN sub-tree is
done, so the parent MAX node gets the (max) value from the child. Note that if the
MAX node had a 2nd sub-tree, we can prune it since >
C S E 4 8 1 : A RT I F I C I A L I N T E L L I G E N C E
28
MAX
=-
=3 3
=3
=+ 3
=-
= 33
3
=3
=2
2
2
=3
=+
=4
=3
4
=-
4 = 3
10
=3
=+
=3
=+
MIN
MAX
MIN
MAX
9) Continue propagating value up the tree, modifying the corresponding and values.
Also, propagate the state of root node down the left-most path of the right sub-tree
C S E 4 8 1 : A RT I F I C I A L I N T E L L I G E N C E
29
MAX
=-
=3 3
=3
=+ 3
=-
= 33
3
=3
=2
2
2
=3
=+
MIN
=4
=3
4
=-
4 = 3
=3
=+
2
=3
2 = 2
MIN
10
MAX
MAX
10) Next value is a 2. We set the (min) value of the MIN parent to 2. Since no other
children exist, we propagate the value up the tree
C S E 4 8 1 : A RT I F I C I A L I N T E L L I G E N C E
30
MAX
=-
=3 3
=3
=+ 3
=-
= 33
3
=3
=2
2
2
=3
=2
MIN
=4
=3
4
=-
4 = 3
=3
=+
2
=3
2 = 2
MIN
10
MAX
MAX
11) We have a value for the 3rd level MAX node, now we can modify the (min) value of
the MIN parent to 2. Now, we have a situation that > and thus the value of the
rightmost sub-tree of the MIN node does not matter, so we prune the whole sub-tree
C S E 4 8 1 : A RT I F I C I A L I N T E L L I G E N C E
31
=-
=3 3
=3
=+ 3
=-
= 33
3
=3
=2
2
2
MAX
=3
2=2
=4
=3
4
=-
4 = 3
10
=3
=+
2
=3
2 = 2
2
MIN
MAX
MIN
MAX
12) Finally, no more nodes remain, we propagate values up the tree. The root has a value of 3 that
comes from the left-most child. Thus, the player should choose the left-most childs move in order to
maximize his/her winnings. The result is the same as with the original minimax algorithm, but we did not
visit all nodes of the tree
C S E 4 8 1 : A RT I F I C I A L I N T E L L I G E N C E
32
C S E 4 8 1 : A RT I F I C I A L I N T E L L I G E N C E
33
C S E 4 8 1 : A RT I F I C I A L I N T E L L I G E N C E
34
C S E 4 8 1 : A RT I F I C I A L I N T E L L I G E N C E
35