SlideShare a Scribd company logo
1 of 76
Jarrar © 2014 1
Dr. Mustafa Jarrar
Sina Institute, University of Birzeit
mjarrar@birzeit.edu
www.jarrar.info
Mustafa Jarrar: Lecture Notes on Games,
Birzeit University, Palestine
Fall Semester, 2014
Artificial Intelligence
Chapter 6Chapter 6
Games
(adversarial search problems)
Jarrar © 2014 2
Watch this lecture and download the slides fromWatch this lecture and download the slides from
http://jarrar-courses.blogspot.com/2011/11/artificial-intelligence-fall-2011.html
Most information based on Chapter 5 of [1]
Reference:
Mustafa Jarrar: Lecture Notes on Conceptual Analyses
University of Birzeit, Palestine, 2015
Online Course
Watch Download Slides
Mustafa Jarrar
Birzeit University, Palestine
mjarrar@birzeit.edu
www.jarrar.info
Mustafa Jarrar: Online Courses – Watch and Download Slides
Jarrar © 2014 3
Can you plan ahead with these games
Jarrar © 2014 4
Game Tree (2-player, deterministic, turns)
Calculated by utility function,
depends on the game.
Last state,
game is over
How to see the game as a treeHow to see the game as a tree
Image from [2]
Jarrar © 2014 5
Your Moves
My Moves
My Moves
Your Moves
Your Moves
My Moves My Moves
My Moves
• Two players take turns making moves
• Board state fully known, deterministic evaluation of moves
• One player wins by defeating the other (or else there is a tie)
• Want a strategy to win, assuming the other person plays as well as possible
Two-Person Perfect Information Deterministic Game
Jarrar © 2014 6
Computer Games
• Playing games can be seen as a Search Problem
• Multiplayer games as multi-agent environments.
• Agents' goals are in conflict.
• Mostly deterministic and fully observable environments.
• Some games are not trivial search problems, thus needs AI
techniques, e.g. Chess has an average branching factor of 35, and
games often go to 50 moves by each player, so the search tree has
about 35100
or 10154
nodes.
• Finding optimal move: choosing a good move with time limits.
• Heuristic evaluation functions allow us to approximate the true utility
of a state without doing a complete search.
Jarrar © 2014 7
Minimax
• Create a utility function
– Evaluation of board/game state to determine how strong the
position of player 1 is.
– Player 1 wants to maximize the utility function
– Player 2 wants to minimize the utility function
• Minimax Tree
– Generate a new level for each move
– Levels alternate between “max” (player 1 moves) and “min”
(player 2 moves)
Jarrar © 2014 8
Minimax Tree
Max
Min
Max
Min
You are Max and your enemy is Min.You are Max and your enemy is Min.
You play with your enemy in this way.You play with your enemy in this way.
Jarrar © 2014 9
Minimax Tree Evaluation
• Assign utility values to leaves
– Sometimes called “board evaluation function”
– If leaf is a “final” state, assign the maximum or minimum possible
utility value (depending on who would win).
– If leaf is not a “final” state, must use some other heuristic, specific
to the game, to evaluate how good/bad the state is at that point
Jarrar © 2014 10
Minimax Tree
Max
Min
Max
Min
100
-24-8-14-73-100-5-70-12-470412-3212823
Terminal nodes: values calculated from the utility function,
evaluates how good/bad the state is at this point
Jarrar © 2014 11
Minimax Tree Evaluation
For the MAX player
1. Generate the game as deep as time permits
2. Apply the evaluation function to the leaf states
3. Back-up values
• At MIN assign minimum payoff move
• At MAX assign maximum payoff move
1. At root, MAX chooses the operator that led to the
highest payoff
Jarrar © 2014 12
Minimax Tree
-24-8-14-73-100-5-70-12-470412-3212823
Max
Min
Max
Min
Terminal nodes: values calculated from the utility function
Jarrar © 2014 13
Minimax Tree
100
-24-8-14-73-100-5-70-12-470412-3212823
28 -3 12 70 -4 -73 -14 -8
Max
Min
Max
Min
Other nodes: values calculated via minimax algorithm
Jarrar © 2014 14
Minimax Tree
100
-24-8-14-73-100-5-70-12-470412-3212823
21 -3 12 70 -4 -73 -14 -8
-3 -4 -73
Max
Min
Max
Min
Jarrar © 2014 15
Minimax Tree
100
-24-8-14-73-100-5-70-12-470412-3212823
21 -3 12 70 -4 -73 -14 -8
-3 -4 -73
-3
Max
Min
Max
Min
Jarrar © 2014 16
Minimax Tree
100
-24-8-14-73-100-5-70-12-470412-3212823
21 -3 12 70 -4 -73 -14 -8
-3 -4 -73
-3
Max
Min
Max
Min
The best next
move for Max
Jarrar © 2014 17
MiniMax Example-2
4 7 9 6 9 8 8 5 6 7 5 2 3 2 5 4 9 3
Terminal nodes: values calculated from the utility function
Max
Max
Min
Min
Based on [3]
Jarrar © 2014 18
MiniMax Example-2
4 7 9 6 9 8 8 5 6 7 5 2 3 2 5 4 9 3
4 7 6 2 6 3 4 5 1 2 5 4 1 2 6 3 4 3
Other nodes: values calculated via minimax algorithm
Max
Max
Min
Min
Jarrar © 2014 19
MiniMax Example-2
4 7 9 6 9 8 8 5 6 7 5 2 3 2 5 4 9 3
4 7 6 2 6 3 4 5 1 2 5 4 1 2 6 3 4 3
7 6 5 5 6 4
Max
Max
Min
Min
Jarrar © 2014 20
MiniMax Example-2
4 7 9 6 9 8 8 5 6 7 5 2 3 2 5 4 9 3
4 7 6 2 6 3 4 5 1 2 5 4 1 2 6 3 4 3
7 6 5 5 6 4
5 3 4
Max
Max
Min
Min
Jarrar © 2014 21
MiniMax Example-2
4 7 9 6 9 8 8 5 6 7 5 2 3 2 5 4 9 3
4 7 6 2 6 3 4 5 1 2 5 4 1 2 6 3 4 3
7 6 5 5 6 4
5 3 4
5 Max
Max
Min
Min
Jarrar © 2014 22
MiniMax Example-2
Max
Max
Min
Min
4 7 9 6 9 8 8 5 6 7 5 2 3 2 5 4 9 3
4 7 6 2 6 3 4 5 1 2 5 4 1 2 6 3 4 3
7 6 5 5 6 4
5 3 4
5
moves by Max and countermoves by Min
Jarrar © 2014 23
Properties of MiniMax
Complete? Yes (if tree is finite)
Space complexity? A complete evaluation takes space bm
(depth-first exploration)
For chess, b ≈ 35, m ≈100 for "reasonable" games
 exact solution completely infeasible, since it’s too big
Instead, we limit the depth based on various factors, including time
available.
»
• Optimal? Yes (against an optimal opponent)
• Time complexity? A complete evaluation
Jarrar © 2014 24
Alpha-Beta Pruning Algorithm
Jarrar © 2014 25
Pruning the Minimax Tree
• Since we have limited time available, we want to avoid
unnecessary computation in the minimax tree.
• Pruning: ways of determining that certain branches will not
be useful.
αα CutsCuts
• If the current max value is greater than the successor’s
min value, don’t explore that min subtree any more.
Jarrar © 2014 26
α Cut Example
10021 -3 12 70 -4 -73 -14
-3 -4
-3
-73
Max
Max
Min
Jarrar © 2014 27
α Cut Example
• Depth first search along path 1
21
Max
Max
Min
Jarrar © 2014 28
α Cut Example
• 21 is minimum so far (second level)
• Can’t evaluate yet at top level
21
21
Max
Max
Min
Jarrar © 2014 29
α Cut Example
• -3 is minimum so far (second level)
• -3 is maximum so far (top level)
21 -3
-3
-3Max
Max
Min
Jarrar © 2014 30
α Cut Example
• 12 is minimum so far (second level)
• -3 is still maximum (can’t use second node yet)
21 -3 12
-3
-3
12
Max
Max
Min
Jarrar © 2014 31
α Cut Example
• -70 is now minimum so far (second level)
• -3 is still maximum (can’t use second node yet)
21 -3 12 -70
-3
-3
-70
Max
Max
Min
Jarrar © 2014 32
α Cut Example
• Since second level node will never be > -70, it
will never be chosen by the previous level
• We can stop exploring that node
21 -3 12 -70
-3
-3
-70
Max
Max
Min
Jarrar © 2014 33
α Cut Example
• Evaluation at second level is again -73
10021 -3 12 -70 -4 -73
-3
-3
-70 -73
Max
Max
Min
Jarrar © 2014 34
α Cut Example
• Again, can apply α cut since the second level
node will never be > -73, and thus will never be
chosen by the previous level
10021 -3 12 -70 -4 -73
-3
-3
-70 -73
Max
Max
Min
Jarrar © 2014 35
α Cut Example
• As a result, we evaluated the Max node without
evaluating several of the possible paths
10021 -3 12 -70 -4 -73 -14
-3
-3
-70 -73
Max
Max
Min
Jarrar © 2014 36
β Cuts
• Similar idea to α cuts, but the other way around
• If the current minimum is less than the
successor’s max value, don’t look down that max
tree any more
Jarrar © 2014 37
β Cut Example
• Some subtrees at second level already have
values > min from previous, so we can stop
evaluating them.
10021 -3 12 70 -4 73 -14
Min
Min
Max 21
21
70 73
Jarrar © 2014 38
Alpha-Beta Example 2
[-∞, +∞]
– we assume a depth-first, left-to-right search as basic strategy
– the range of the possible values for each node are indicated
• initially [-∞, +∞]
• from Max’s or Min’s perspective
• these local values reflect the values of the sub-trees in that node;
the global values α and β are the best overall choices so far for Max or Min
[-∞, +∞]
α best choice for Max ?
β best choice for Min ?
Max
Min
Jarrar © 2014 39
Alpha-Beta Example 2
Max
Min[-∞, 7]
[-∞, +∞]
α best choice for Max ?
β best choice for Min 7
7
Jarrar © 2014 40
Alpha-Beta Example 2
Max
Min[-∞, 6]
[-∞, +∞]
α best choice for Max ?
β best choice for Min 6
7 6
Jarrar © 2014 41
Alpha-Beta Example 2
Max
Min5
[5, +∞]
α best choice for Max 5
β best choice for Min 5
7 6 5
– Min obtains the third value from a successor node
– this is the last value from this sub-tree, and the exact value is known
– Max now has a value for its first successor node, but hopes that something
better might still come
Jarrar © 2014 42
Alpha-Beta Example 2
Max
Min[-∞, 5]
[5, +∞]
α best choice for Max 5
β best choice for Min 3
7 6 5
– Min continues with the next sub-tree, and gets a better value
– Max has a better choice from its perspective, however, and will not consider a
move in the sub-tree currently explored by min
– Initially [-∞, +∞]
[-∞,3]
3
Jarrar © 2014 43
Alpha-Beta Example 2
Max
Min[-∞, 5]
[5, +∞]
α best choice for Max 5
β best choice for Min 3
7 6 5
– Min knows that Max won’t consider a move to this sub-tree, and abandons it
– this is a case of pruning, indicated by
[-∞,3]
3
Jarrar © 2014 44
Alpha-Beta Example 2
Max
Min[-∞, 5]
[5, +∞]
α best choice for Max 5
β best choice for Min 3
7 6 5
– Min explores the next sub-tree, and finds a value that is worse than the other
nodes at this level
– if Min is not able to find something lower, then Max will choose this branch, so
Min must explore more successor nodes
[-∞,3]
3
[-∞,6]
6
Jarrar © 2014 45
Alpha-Beta Example 2
Max
Min[-∞, 5]
[5, +∞]
α best choice for Max 5
β best choice for Min 3
7 6 5
– Min is lucky, and finds a value that is the same as the current worst value at
this level
– Max can choose this branch, or the other branch with the same value
[-∞,3]
3
[-∞,5]
6 5
Jarrar © 2014 46
Alpha-Beta Example 2
Max
Min[-∞, 5]
5
α best choice for Max 5
β best choice for Min 3
7 6 5
– Min could continue searching this sub-tree to see if there is a value that is less
than the current worst alternative in order to give Max as few choices as
possible
– this depends on the specific implementation
– Max knows the best value for its sub-tree
[-∞,3]
3
[-∞,5]
6 5
Jarrar © 2014 47
max
min
max
min
Exercise
Jarrar © 2014 48
max
min
max
min
10 9 14 2 4
10 14 4
10 4
10
Exercise (Solution)
Jarrar © 2014 49
α-β Pruning
• Pruning by these cuts does not affect final result
– May allow you to go much deeper in tree
• “Good” ordering of moves can make this pruning
much more efficient
– Evaluating “best” branch first yields better likelihood of
pruning later branches
– Perfect ordering reduces time to bm/2
instead of O(bd
)
– i.e. doubles the depth you can search to!
Jarrar © 2014 50
α-β Pruning
• Can store information along an entire path, not
just at most recent levels!
• Keep along the path:
α: best MAX value found on this path
(initialize to most negative utility value)
β: best MIN value found on this path
(initialize to most positive utility value)
Jarrar © 2014 51
Pruning at MAX node
α is possibly updated by the MAX of successors evaluated so far
• If the value that would be returned is ever > β, then stop work on this
branch
• If all children are evaluated without pruning, return the MAX of their
values
Jarrar © 2014 52
Pruning at MIN node
β is possibly updated by the MIN of successors evaluated so far
• If the value that would be returned is ever < α, then stop work on this
branch
• If all children are evaluated without pruning, return the MIN of their
values
Jarrar © 2014 53
Idea of α-β Pruning
• We know β on this path is 21
• So, when we get max=70, we
know this will never be used, so
we can stop here 100
21 -3
12 70 -4
21
21
70
Jarrar © 2014 54
Why is it called α-β?
• α is the value of the best (i.e., highest-
value) choice found so far at any
choice point along the path for max
• If v is worse than α, max will avoid it
 prune that branch
• Define β similarly for min
Jarrar © 2014 55
Imperfect Decisions
• Complete search is impractical for most games
• Alternative: search the tree only to a certain depth
– Requires a cutoff-test to determine where to stop
• Replaces the terminal test
• The nodes at that level effectively become terminal leave nodes
– Uses a heuristics-based evaluation function to estimate
the expected utility of the game from those leave nodes.
Jarrar © 2014 56
Utility Evaluation Function
• Very game-specific
• Take into account knowledge about game
• “Stupid” utility
– 1 if player 1 wins
– -1 if player 0 wins
– 0 if tie (or unknown)
– Only works if we can evaluate complete tree
– But, should form a basis for other evaluations
Jarrar © 2014 57
Utility Evaluation
• Need to assign a numerical value to the state
– Could assign a more complex utility value, but then the
min/max determination becomes trickier.
• Typically assign numerical values to lots of
individual factors:
– a = # player 1’s pieces - # player 2’s pieces
– b = 1 if player 1 has queen and player 2 does not, -1 if
the opposite, or 0 if the same
– c = 2 if player 1 has 2-rook advantage, 1 if a 1-rook
advantage, etc.
Jarrar © 2014 58
Utility Evaluation
• The individual factors are combined by some function
• Usually a linear weighted combination is used:
– u = αa + βb + χc
– Different ways to combine are also possible
• Notice: quality of utility function is based on:
– What features are evaluated
– How those features are scored
– How the scores are weighted/combined
• Absolute utility value doesn’t matter – relative value does.
Jarrar © 2014 59
Evaluation Functions
• If you had a perfect utility evaluation function, what
would it mean about the minimax tree?
You would never have to evaluate more than
one level deep!
• Typically, you can’t create such perfect utility
evaluations, though.
Jarrar © 2014 60
Evaluation Functions for Ordering
• As mentioned earlier, order of branch evaluation can make
a big difference in how well you can prune
• A good evaluation function might help you order your
available moves:
– Perform one move only
– Evaluate board at that level
– Recursively evaluate branches in order from best first move to
worst first move (or vice-versa if at a MIN node)
Jarrar © 2014 61
The following are extra Examples
(Self Study)
Jarrar © 2014 62
Example: Tic-Tac-Toe (evaluation function)
• Simple evaluation function
E(s) = (rx + cx + dx) - (ro + co + do)
where r,c,d are the numbers of row, column and diagonal lines still
available; x and o are the pieces of the two players.
• 1-ply lookahead
– start at the top of the tree
– evaluate all 9 choices for player 1
– pick the maximum E-value
• 2-ply lookahead
– also looks at the opponents possible move
• assuming that the opponents picks the minimum E-value
Jarrar © 2014 63
E(s12)
8
- 6
= 2
E(s13)
8
- 5
= 3
E(s14)
8
- 6
= 2
E(s15)
8
- 4
= 4
E(s16)
8
- 6
= 2
E(s17)
8
- 5
= 3
E(s18)
8
- 6
= 2
E(s19)
8
- 5
= 3
Tic-Tac-Toe 1-Ply
X X X
X X X
X X X
E(s11)
8
- 5
= 3
E(s0) = Max{E(s11), E(s1n)} = Max{2,3,4} = 4
Based on [3]
Jarrar © 2014 64
E(s2:16)
5
- 6
= -1
E(s2:15)
5
-6
= -1
E(s28)
5
- 5
= 0
E(s27)
6
- 5
= 1
E(s2:48)
5
- 4
= 1
E(s2:47)
6
- 4
= 2
E(s2:13)
5
- 6
= -1
E(s2:9)
5
- 6
= -1
E(s2:10)
5
-6
= -1
E(s2:11)
5
- 6
= -1
E(s2:12)
5
- 6
= -1
E(s2:14)
5
- 6
= -1
E(s25)
6
- 5
= 1
E(s21)
6
- 5
= 1
E(s22)
5
- 5
= 0
E(s23)
6
- 5
= 1
E(s24)
4
- 5
= -1
E(s26)
5
- 5
= 0
E(s1:6)
8
- 6
= 2
E(s1:7)
8
- 5
= 3
E(s1:8)
8
- 6
= 2
E(s1:9)
8
- 5
= 3
E(s1:5)
8
- 4
= 4
E(s1:3)
8
- 5
= 3
E(s1:2)
8
- 6
= 2
E(s1:1)
8
- 5
= 3
E(s2:45)
6
- 4
= 2
Tic-Tac-Toe 2-Ply
X X X
X X X
X X X
E(s1:4)
8
- 6
= 2
X O X
O
X
O
E(s2:41)
5
- 4
= 1
E(s2:42)
6
- 4
= 2
E(s2:43)
5
- 4
= 1
E(s2:44)
6
- 4
= 2
E(s2:46)
5
- 4
= 1
O X
O
X
O
X
O
X X
O
X
O
X
O
X
O
XX
O
X OO X X
O
X
O
X
O
X
O
X
O
X
O
X OX O X
O
O
E(s0) = Max{E(s11), E(s1n)} = Max{2,3,4} = 4
Jarrar © 2014 65
31
Checkers Case Study
• Initial board configuration
– Black single on 20
single on 21
king on 31
– Red single on 23
king on 22
– Evaluation function
E(s) = (5 x1 + x2) - (5r1 + r2)
where
x1 = black king advantage,
x2 = black single advantage,
r1 = red king advantage,
r2 = red single advantage
1 2 3 4
865
9 10 11 12
161413
17 18 19 20
242221
25 26 27 28
323029
7
15
23
Based on [4]
Jarrar © 2014 66
1
1
1 1 1 2
2
6
6
1
1
1 1 1 1 1
1
1 1 1 1 6
6
0
0
0 0 -4
-4
-4 -8
-8
-8 -8
-8
-8
1 0 -8 -8
1
20
->
16
21->17
31
->
26
31 -> 27
22 -> 17
22
->
18
22->25
22->26
23->26
23
->
27
21
->
14
16 -> 11
31->27
16->11
31->27
31->27
16->11
31
->
27
31->24
22->13
22->31
23
->
30
23
->
32
20->16
31->27
31->26
21->17
20->16
21->17
20->16
20->16
21->17
31
1 2 3 4
865
9 10 11 12
161413
17 18 19 20
242221
25 26 27 28
323029
7
15
23
MAX
MAX
MIN
Checkers MiniMax Example
Jarrar © 2014 67
1
1
1 1 1 2
2
6
6
1
1
1 1 1 1 1
1
1 1 1 1 6
6
0
0
0 0 -4
-4
-4 -8
-8
-8 -8
-8
-8
1 0 -4 -8
1
20
->
16
21->17
31
->
26
31 -> 27
22 -> 17
22
->
18
22->25
22->26
23->26
23
->
27
21
->
14
16 -> 11
31->27
16->11
31->27
31->27
16->11
31
->
27
31->24
22->18
22->31
23
->
30
23
->
32
20->16
31->27
31->26
21->17
20->16
21->17
20->16
20->16
21->17
31
1 2 3 4
865
9 10 11 12
161413
17 18 19 20
242221
25 26 27 28
323029
7
15
23
α 1
β 6
MAX
MAX
MIN
Checkers Alpha-Beta Example
Jarrar © 2014 68
1
1
1 1 1 2
2
6
6
1
1
1 1 1 1 1
1
1 1 1 1 6
6
0
0
0 0 -4
-4
-4 -8
-8
-8 -8
-8
-8
1 0 -4 -8
1
20
->
16
21->17
31
->
26
31 -> 27
22 -> 17
22
->
18
22->25
22->26
23->26
23
->
27
21
->
14
16 -> 11
31->27
16->11
31->27
31->27
16->11
31
->
27
31->24
22->18
22->31
23
->
30
23
->
32
20->16
31->27
31->26
21->17
20->16
21->17
20->16
20->16
21->17
31
1 2 3 4
865
9 10 11 12
161413
17 18 19 20
242221
25 26 27 28
323029
7
15
23
α 1
β 1
MAX
MAX
MIN
Checkers Alpha-Beta Example
Jarrar © 2014 69
1
1
1 1 1 2
2
6
6
1
1
1 1 1 1 1
1
1 1 1 1 6
6
0
0
0 0 -4
-4
-4 -8
-8
-8 -8
-8
-8
1 0 -4 -8
1
20
->
16
21->17
31
->
26
31 -> 27
22 -> 17
22
->
18
22->25
22->26
23->26
23
->
27
21
->
14
16 -> 11
31->27
16->11
31->27
31->22
16->11
31
->
27
31->24
22->18
22->31
23
->
30
23
->
32
20->16
31->27
31->26
21->17
20->16
21->17
20->16
20->16
21->17
31
1 2 3 4
865
9 10 11 12
161413
17 18 19 20
242221
25 26 27 28
323029
7
15
23
α 1
β 1
β− cutoff: no need to
examine further branches
MAX
MAX
MIN
Checkers Alpha-Beta Example
Jarrar © 2014 70
1
1
1 1 1 2
2
6
6
1
1
1 1 1 1 1
1
1 1 1 1 6
6
0
0
0 0 -4
-4
-4 -8
-8
-8 -8
-8
-8
1 0 -4 -8
1
20
->
16
21->17
31
->
26
31 -> 27
22 -> 17
22
->
18
22->25
22->26
23->26
23
->
27
21
->
14
16 -> 11
31->27
16->11
31->27
31->22
16->11
31
->
27
31->24
22->18
22->31
23
->
30
23
->
32
20->16
31->27
31->26
21->17
20->16
21->17
20->16
20->16
21->17
31
1 2 3 4
865
9 10 11 12
161413
17 18 19 20
242221
25 26 27 28
323029
7
15
23
α 1
β 1
MAX
MAX
MIN
Checkers Alpha-Beta Example
Jarrar © 2014 71
1
1
1 1 1 2
2
6
6
1
1
1 1 1 1 1
1
1 1 1 1 6
6
0
0
0 0 -4
-4
-4 -8
-8
-8 -8
-8
-8
1 0 -4 -8
1
20
->
16
21->17
31
->
26
31 -> 27
22 -> 17
22
->
18
22->25
22->26
23->26
23
->
27
21
->
14
16 -> 11
31->27
16->11
31->27
31->22
16->11
31
->
27
31->24
22->18
22->31
23
->
30
23
->
32
20->16
31->27
31->26
21->17
20->16
21->17
20->16
20->16
21->17
31
1 2 3 4
865
9 10 11 12
161413
17 18 19 20
242221
25 26 27 28
323029
7
15
23
α 1
β 1
β− cutoff: no need to
examine further branches
MAX
MAX
MIN
Checkers Alpha-Beta Example
Jarrar © 2014 72
1
1
1 1 1 2
2
6
6
1
1
1 1 1 1 1
1
1 1 1 1 6
6
0
0
0 0 -4
-4
-4 -8
-8
-8 -8
-8
-8
1 0 -4 -8
1
20
->
16
21->17
31
->
26
31 -> 27
22 -> 17
22
->
18
22->25
22->26
23->26
23
->
27
21
->
14
16 -> 11
31->27
16->11
31->27
31->22
16->11
31
->
27
31->24
22->18
22->31
23
->
30
23
->
32
20->16
31->27
31->26
21->17
20->16
21->17
20->16
20->16
21->17
31
1 2 3 4
865
9 10 11 12
161413
17 18 19 20
242221
25 26 27 28
323029
7
15
23
α 1
β 1
MAX
MAX
MIN
Checkers Alpha-Beta Example
Jarrar © 2014 73
1
1
1 1 1 2
2
6
6
1
1
1 1 1 1 1
1
1 1 1 1 6
6
0
0
0 0 -4
-4
-4 -8
-8
-8 -8
-8
-8
1 0 -4 -8
1
20
->
16
21->17
31
->
26
31 -> 27
22 -> 17
22
->
18
22->25
22->26
23->26
23
->
27
21
->
14
16 -> 11
31->27
16->11
31->27
31->22
16->11
31
->
27
31->24
22->13
22->31
23
->
30
23
->
32
20->16
31->27
31->26
21->17
20->16
21->17
20->16
20->16
21->17
31
1 2 3 4
865
9 10 11 12
161413
17 18 19 20
242221
25 26 27 28
323029
7
15
23
α 1
β 0
MAX
MAX
MIN
Checkers Alpha-Beta Example
Jarrar © 2014 74
Checkers Alpha-Beta Example
1
1
1 1 1 2
2
6
6
1
1
1 1 1 1 1
1
1 1 1 1 6
6
0
0
0 0 -4
-4
-4 -8
-8
-8 -8
-8
-8
1 0 -4 -8
1
20
->
16
21->17
31
->
26
31 -> 27
22 -> 17
22
->
18
22->25
22->26
23->26
23
->
27
21
->
14
16 -> 11
31->27
16->11
31->27
31->22
16->11
31
->
27
31->24
22->18
22->31
23
->
30
23
->
32
20->16
31->27
31->26
21->17
20->16
21->17
20->16
20->16
21->17
31
1 2 3 4
865
9 10 11 12
161413
17 18 19 20
242221
25 26 27 28
323029
7
15
23
α 1
β -4
α− cutoff: no need to
examine further branches
MAX
MAX
MIN
Jarrar © 2014 75
22->31
1
1
1 1 1 2
2
6
6
1
1
1 1 1 1 1
1
1 1 1 1 6
6
0
0
0 0 -4
-4
-4 -8
-8
-8 -8
-8
-8
1 0 -4 -8
1
20
->
16
21->17
31
->
26
31 -> 27
22 -> 17
22
->
18
22->25
22->26
23->26
23
->
27
21
->
14
16 -> 11
31->27
16->11
31->27
31->22
16->11
31
->
27
31->24
22->18
23
->
30
23
->
32
20->16
31->27
31->26
21->17
20->16
21->17
20->16
20->16
21->17
31
1 2 3 4
865
9 10 11 12
161413
17 18 19 20
242221
25 26 27 28
323029
7
15
23
α 1
β -8 MAX
MAX
MIN
Checkers Alpha-Beta Example
Jarrar © 2014 76
References
[1][1] S. Russell and P. Norvig: Artificial Intelligence: A Modern ApproachS. Russell and P. Norvig: Artificial Intelligence: A Modern Approach
Prentice Hall, 2003, Second EditionPrentice Hall, 2003, Second Edition
[2][2] Nilufer Onden: Lecture Notes on Artificial IntelligenceNilufer Onden: Lecture Notes on Artificial Intelligence
http://www.cs.mtu.edu/~nilufer/classes/cs4811/2014-spring/lecture-slides/cs4811-ch05-adversarial-http://www.cs.mtu.edu/~nilufer/classes/cs4811/2014-spring/lecture-slides/cs4811-ch05-adversarial-
search.pdfsearch.pdf
[3][3] Samy Abu Nasser: Lecture Notes on Artificial IntelligenceSamy Abu Nasser: Lecture Notes on Artificial Intelligence
http://up.edu.ps/ocw/repositories/academic/up/bs/it/ITLS4213/022009/data/ITLS4213.101_11042009.ppthttp://up.edu.ps/ocw/repositories/academic/up/bs/it/ITLS4213/022009/data/ITLS4213.101_11042009.ppt
[4][4] Franz Kurfess: Lecture Notes on Artificial IntelligenceFranz Kurfess: Lecture Notes on Artificial Intelligence
http://users.csc.calpoly.edu/~fkurfess/Courses/Artificial-Intelligence/F09/Slides/3-Search.ppthttp://users.csc.calpoly.edu/~fkurfess/Courses/Artificial-Intelligence/F09/Slides/3-Search.ppt

More Related Content

What's hot

Clustering
ClusteringClustering
Clusteringbutest
 
CC282 Unsupervised Learning (Clustering) Lecture 7 slides for ...
CC282 Unsupervised Learning (Clustering) Lecture 7 slides for ...CC282 Unsupervised Learning (Clustering) Lecture 7 slides for ...
CC282 Unsupervised Learning (Clustering) Lecture 7 slides for ...butest
 
Machine learning hands on clustering
Machine learning hands on clusteringMachine learning hands on clustering
Machine learning hands on clusteringDr. Dragos Crintea
 
Sigmod11 outsource shortest path
Sigmod11 outsource shortest pathSigmod11 outsource shortest path
Sigmod11 outsource shortest pathredhatdb
 
Clustering: Large Databases in data mining
Clustering: Large Databases in data miningClustering: Large Databases in data mining
Clustering: Large Databases in data miningZHAO Sam
 
Clustering, k-means clustering
Clustering, k-means clusteringClustering, k-means clustering
Clustering, k-means clusteringMegha Sharma
 
Birch Algorithm With Solved Example
Birch Algorithm With Solved ExampleBirch Algorithm With Solved Example
Birch Algorithm With Solved Examplekailash shaw
 
GBM package in r
GBM package in rGBM package in r
GBM package in rmark_landry
 
RDataMining slides-clustering-with-r
RDataMining slides-clustering-with-rRDataMining slides-clustering-with-r
RDataMining slides-clustering-with-rYanchang Zhao
 
K means and dbscan
K means and dbscanK means and dbscan
K means and dbscanYan Xu
 
K means clustering
K means clusteringK means clustering
K means clusteringAhmedasbasb
 
Rabbit challenge 3 DNN Day2
Rabbit challenge 3 DNN Day2Rabbit challenge 3 DNN Day2
Rabbit challenge 3 DNN Day2TOMMYLINK1
 

What's hot (20)

Clustering part 1
Clustering part 1Clustering part 1
Clustering part 1
 
Clustering
ClusteringClustering
Clustering
 
CC282 Unsupervised Learning (Clustering) Lecture 7 slides for ...
CC282 Unsupervised Learning (Clustering) Lecture 7 slides for ...CC282 Unsupervised Learning (Clustering) Lecture 7 slides for ...
CC282 Unsupervised Learning (Clustering) Lecture 7 slides for ...
 
Hierachical clustering
Hierachical clusteringHierachical clustering
Hierachical clustering
 
Machine learning hands on clustering
Machine learning hands on clusteringMachine learning hands on clustering
Machine learning hands on clustering
 
Fuzzy c means manual work
Fuzzy c means manual workFuzzy c means manual work
Fuzzy c means manual work
 
Sigmod11 outsource shortest path
Sigmod11 outsource shortest pathSigmod11 outsource shortest path
Sigmod11 outsource shortest path
 
Lesson 39
Lesson 39Lesson 39
Lesson 39
 
Clustering: Large Databases in data mining
Clustering: Large Databases in data miningClustering: Large Databases in data mining
Clustering: Large Databases in data mining
 
Lesson 38
Lesson 38Lesson 38
Lesson 38
 
Clustering, k-means clustering
Clustering, k-means clusteringClustering, k-means clustering
Clustering, k-means clustering
 
Birch Algorithm With Solved Example
Birch Algorithm With Solved ExampleBirch Algorithm With Solved Example
Birch Algorithm With Solved Example
 
Lesson 36
Lesson 36Lesson 36
Lesson 36
 
GBM package in r
GBM package in rGBM package in r
GBM package in r
 
RDataMining slides-clustering-with-r
RDataMining slides-clustering-with-rRDataMining slides-clustering-with-r
RDataMining slides-clustering-with-r
 
K means and dbscan
K means and dbscanK means and dbscan
K means and dbscan
 
K means clustering
K means clusteringK means clustering
K means clustering
 
Birch
BirchBirch
Birch
 
Clique and sting
Clique and stingClique and sting
Clique and sting
 
Rabbit challenge 3 DNN Day2
Rabbit challenge 3 DNN Day2Rabbit challenge 3 DNN Day2
Rabbit challenge 3 DNN Day2
 

Viewers also liked

Jarrar: Introduction to logic and Logic Agents
Jarrar: Introduction to logic and Logic Agents Jarrar: Introduction to logic and Logic Agents
Jarrar: Introduction to logic and Logic Agents Mustafa Jarrar
 
Introduction to Artificial Intelligence
Introduction to Artificial Intelligence Introduction to Artificial Intelligence
Introduction to Artificial Intelligence Mustafa Jarrar
 
Adnan: Introduction to Natural Language Processing
Adnan: Introduction to Natural Language Processing Adnan: Introduction to Natural Language Processing
Adnan: Introduction to Natural Language Processing Mustafa Jarrar
 
Jarrar: Description Logic
Jarrar: Description LogicJarrar: Description Logic
Jarrar: Description LogicMustafa Jarrar
 
Jarrar: Introduction to Information Retrieval
Jarrar: Introduction to Information RetrievalJarrar: Introduction to Information Retrieval
Jarrar: Introduction to Information RetrievalMustafa Jarrar
 
Jarrar: Propositional Logic Inference Methods
Jarrar: Propositional Logic Inference MethodsJarrar: Propositional Logic Inference Methods
Jarrar: Propositional Logic Inference MethodsMustafa Jarrar
 
Jarrar: Probabilistic Language Modeling - Introduction to N-grams
Jarrar: Probabilistic Language Modeling - Introduction to N-gramsJarrar: Probabilistic Language Modeling - Introduction to N-grams
Jarrar: Probabilistic Language Modeling - Introduction to N-gramsMustafa Jarrar
 
Jarrar: Introduction to Natural Language Processing
Jarrar: Introduction to Natural Language ProcessingJarrar: Introduction to Natural Language Processing
Jarrar: Introduction to Natural Language ProcessingMustafa Jarrar
 
Habash: Arabic Natural Language Processing
Habash: Arabic Natural Language ProcessingHabash: Arabic Natural Language Processing
Habash: Arabic Natural Language ProcessingMustafa Jarrar
 
Jarrar: Informed Search
Jarrar: Informed Search  Jarrar: Informed Search
Jarrar: Informed Search Mustafa Jarrar
 

Viewers also liked (10)

Jarrar: Introduction to logic and Logic Agents
Jarrar: Introduction to logic and Logic Agents Jarrar: Introduction to logic and Logic Agents
Jarrar: Introduction to logic and Logic Agents
 
Introduction to Artificial Intelligence
Introduction to Artificial Intelligence Introduction to Artificial Intelligence
Introduction to Artificial Intelligence
 
Adnan: Introduction to Natural Language Processing
Adnan: Introduction to Natural Language Processing Adnan: Introduction to Natural Language Processing
Adnan: Introduction to Natural Language Processing
 
Jarrar: Description Logic
Jarrar: Description LogicJarrar: Description Logic
Jarrar: Description Logic
 
Jarrar: Introduction to Information Retrieval
Jarrar: Introduction to Information RetrievalJarrar: Introduction to Information Retrieval
Jarrar: Introduction to Information Retrieval
 
Jarrar: Propositional Logic Inference Methods
Jarrar: Propositional Logic Inference MethodsJarrar: Propositional Logic Inference Methods
Jarrar: Propositional Logic Inference Methods
 
Jarrar: Probabilistic Language Modeling - Introduction to N-grams
Jarrar: Probabilistic Language Modeling - Introduction to N-gramsJarrar: Probabilistic Language Modeling - Introduction to N-grams
Jarrar: Probabilistic Language Modeling - Introduction to N-grams
 
Jarrar: Introduction to Natural Language Processing
Jarrar: Introduction to Natural Language ProcessingJarrar: Introduction to Natural Language Processing
Jarrar: Introduction to Natural Language Processing
 
Habash: Arabic Natural Language Processing
Habash: Arabic Natural Language ProcessingHabash: Arabic Natural Language Processing
Habash: Arabic Natural Language Processing
 
Jarrar: Informed Search
Jarrar: Informed Search  Jarrar: Informed Search
Jarrar: Informed Search
 

Similar to Jarrar: Games

Jarrar.lecture notes.aai.2011s.ch6.games
Jarrar.lecture notes.aai.2011s.ch6.gamesJarrar.lecture notes.aai.2011s.ch6.games
Jarrar.lecture notes.aai.2011s.ch6.gamesPalGov
 
Minmax and alpha beta pruning.pptx
Minmax and alpha beta pruning.pptxMinmax and alpha beta pruning.pptx
Minmax and alpha beta pruning.pptxPriyadharshiniG41
 
21CSC206T_UNIT3.pptx.pdf ARITIFICIAL INTELLIGENCE
21CSC206T_UNIT3.pptx.pdf ARITIFICIAL INTELLIGENCE21CSC206T_UNIT3.pptx.pdf ARITIFICIAL INTELLIGENCE
21CSC206T_UNIT3.pptx.pdf ARITIFICIAL INTELLIGENCEudayvanand
 
AI3391 Artificial intelligence Session 15 Min Max Algorithm.pptx
AI3391 Artificial intelligence Session 15  Min Max Algorithm.pptxAI3391 Artificial intelligence Session 15  Min Max Algorithm.pptx
AI3391 Artificial intelligence Session 15 Min Max Algorithm.pptxAsst.prof M.Gokilavani
 
9SearchAdversarial (1).pptx
9SearchAdversarial (1).pptx9SearchAdversarial (1).pptx
9SearchAdversarial (1).pptxumairshams6
 

Similar to Jarrar: Games (7)

Jarrar.lecture notes.aai.2011s.ch6.games
Jarrar.lecture notes.aai.2011s.ch6.gamesJarrar.lecture notes.aai.2011s.ch6.games
Jarrar.lecture notes.aai.2011s.ch6.games
 
Minmax and alpha beta pruning.pptx
Minmax and alpha beta pruning.pptxMinmax and alpha beta pruning.pptx
Minmax and alpha beta pruning.pptx
 
Capgemini 1
Capgemini 1Capgemini 1
Capgemini 1
 
21CSC206T_UNIT3.pptx.pdf ARITIFICIAL INTELLIGENCE
21CSC206T_UNIT3.pptx.pdf ARITIFICIAL INTELLIGENCE21CSC206T_UNIT3.pptx.pdf ARITIFICIAL INTELLIGENCE
21CSC206T_UNIT3.pptx.pdf ARITIFICIAL INTELLIGENCE
 
Min-Max algorithm
Min-Max algorithmMin-Max algorithm
Min-Max algorithm
 
AI3391 Artificial intelligence Session 15 Min Max Algorithm.pptx
AI3391 Artificial intelligence Session 15  Min Max Algorithm.pptxAI3391 Artificial intelligence Session 15  Min Max Algorithm.pptx
AI3391 Artificial intelligence Session 15 Min Max Algorithm.pptx
 
9SearchAdversarial (1).pptx
9SearchAdversarial (1).pptx9SearchAdversarial (1).pptx
9SearchAdversarial (1).pptx
 

More from Mustafa Jarrar

Clustering Arabic Tweets for Sentiment Analysis
Clustering Arabic Tweets for Sentiment AnalysisClustering Arabic Tweets for Sentiment Analysis
Clustering Arabic Tweets for Sentiment AnalysisMustafa Jarrar
 
Classifying Processes and Basic Formal Ontology
Classifying Processes  and Basic Formal OntologyClassifying Processes  and Basic Formal Ontology
Classifying Processes and Basic Formal OntologyMustafa Jarrar
 
Discrete Mathematics Course Outline
Discrete Mathematics Course OutlineDiscrete Mathematics Course Outline
Discrete Mathematics Course OutlineMustafa Jarrar
 
Business Process Implementation
Business Process ImplementationBusiness Process Implementation
Business Process ImplementationMustafa Jarrar
 
Business Process Design and Re-engineering
Business Process Design and Re-engineeringBusiness Process Design and Re-engineering
Business Process Design and Re-engineeringMustafa Jarrar
 
BPMN 2.0 Analytical Constructs
BPMN 2.0 Analytical ConstructsBPMN 2.0 Analytical Constructs
BPMN 2.0 Analytical ConstructsMustafa Jarrar
 
BPMN 2.0 Descriptive Constructs
BPMN 2.0 Descriptive Constructs  BPMN 2.0 Descriptive Constructs
BPMN 2.0 Descriptive Constructs Mustafa Jarrar
 
Introduction to Business Process Management
Introduction to Business Process ManagementIntroduction to Business Process Management
Introduction to Business Process ManagementMustafa Jarrar
 
Customer Complaint Ontology
Customer Complaint Ontology Customer Complaint Ontology
Customer Complaint Ontology Mustafa Jarrar
 
Subset, Equality, and Exclusion Rules
Subset, Equality, and Exclusion RulesSubset, Equality, and Exclusion Rules
Subset, Equality, and Exclusion RulesMustafa Jarrar
 
Schema Modularization in ORM
Schema Modularization in ORMSchema Modularization in ORM
Schema Modularization in ORMMustafa Jarrar
 
On Computer Science Trends and Priorities in Palestine
On Computer Science Trends and Priorities in PalestineOn Computer Science Trends and Priorities in Palestine
On Computer Science Trends and Priorities in PalestineMustafa Jarrar
 
Lessons from Class Recording & Publishing of Eight Online Courses
Lessons from Class Recording & Publishing of Eight Online CoursesLessons from Class Recording & Publishing of Eight Online Courses
Lessons from Class Recording & Publishing of Eight Online CoursesMustafa Jarrar
 
Presentation curras paper-emnlp2014-final
Presentation curras paper-emnlp2014-finalPresentation curras paper-emnlp2014-final
Presentation curras paper-emnlp2014-finalMustafa Jarrar
 
Jarrar: Future Internet in Horizon 2020 Calls
Jarrar: Future Internet in Horizon 2020 CallsJarrar: Future Internet in Horizon 2020 Calls
Jarrar: Future Internet in Horizon 2020 CallsMustafa Jarrar
 
Riestra: How to Design and engineer Competitive Horizon 2020 Proposals
Riestra: How to Design and engineer Competitive Horizon 2020 ProposalsRiestra: How to Design and engineer Competitive Horizon 2020 Proposals
Riestra: How to Design and engineer Competitive Horizon 2020 ProposalsMustafa Jarrar
 
Bouquet: SIERA Workshop on The Pillars of Horizon2020
Bouquet: SIERA Workshop on The Pillars of Horizon2020Bouquet: SIERA Workshop on The Pillars of Horizon2020
Bouquet: SIERA Workshop on The Pillars of Horizon2020Mustafa Jarrar
 
Jarrar: Sparql Project
Jarrar: Sparql ProjectJarrar: Sparql Project
Jarrar: Sparql ProjectMustafa Jarrar
 
Jarrar: Logical Foundation of Ontology Engineering
Jarrar: Logical Foundation of Ontology EngineeringJarrar: Logical Foundation of Ontology Engineering
Jarrar: Logical Foundation of Ontology EngineeringMustafa Jarrar
 
Jarrar: Stepwise Methodologies for Developing Ontologies
Jarrar: Stepwise Methodologies for Developing OntologiesJarrar: Stepwise Methodologies for Developing Ontologies
Jarrar: Stepwise Methodologies for Developing OntologiesMustafa Jarrar
 

More from Mustafa Jarrar (20)

Clustering Arabic Tweets for Sentiment Analysis
Clustering Arabic Tweets for Sentiment AnalysisClustering Arabic Tweets for Sentiment Analysis
Clustering Arabic Tweets for Sentiment Analysis
 
Classifying Processes and Basic Formal Ontology
Classifying Processes  and Basic Formal OntologyClassifying Processes  and Basic Formal Ontology
Classifying Processes and Basic Formal Ontology
 
Discrete Mathematics Course Outline
Discrete Mathematics Course OutlineDiscrete Mathematics Course Outline
Discrete Mathematics Course Outline
 
Business Process Implementation
Business Process ImplementationBusiness Process Implementation
Business Process Implementation
 
Business Process Design and Re-engineering
Business Process Design and Re-engineeringBusiness Process Design and Re-engineering
Business Process Design and Re-engineering
 
BPMN 2.0 Analytical Constructs
BPMN 2.0 Analytical ConstructsBPMN 2.0 Analytical Constructs
BPMN 2.0 Analytical Constructs
 
BPMN 2.0 Descriptive Constructs
BPMN 2.0 Descriptive Constructs  BPMN 2.0 Descriptive Constructs
BPMN 2.0 Descriptive Constructs
 
Introduction to Business Process Management
Introduction to Business Process ManagementIntroduction to Business Process Management
Introduction to Business Process Management
 
Customer Complaint Ontology
Customer Complaint Ontology Customer Complaint Ontology
Customer Complaint Ontology
 
Subset, Equality, and Exclusion Rules
Subset, Equality, and Exclusion RulesSubset, Equality, and Exclusion Rules
Subset, Equality, and Exclusion Rules
 
Schema Modularization in ORM
Schema Modularization in ORMSchema Modularization in ORM
Schema Modularization in ORM
 
On Computer Science Trends and Priorities in Palestine
On Computer Science Trends and Priorities in PalestineOn Computer Science Trends and Priorities in Palestine
On Computer Science Trends and Priorities in Palestine
 
Lessons from Class Recording & Publishing of Eight Online Courses
Lessons from Class Recording & Publishing of Eight Online CoursesLessons from Class Recording & Publishing of Eight Online Courses
Lessons from Class Recording & Publishing of Eight Online Courses
 
Presentation curras paper-emnlp2014-final
Presentation curras paper-emnlp2014-finalPresentation curras paper-emnlp2014-final
Presentation curras paper-emnlp2014-final
 
Jarrar: Future Internet in Horizon 2020 Calls
Jarrar: Future Internet in Horizon 2020 CallsJarrar: Future Internet in Horizon 2020 Calls
Jarrar: Future Internet in Horizon 2020 Calls
 
Riestra: How to Design and engineer Competitive Horizon 2020 Proposals
Riestra: How to Design and engineer Competitive Horizon 2020 ProposalsRiestra: How to Design and engineer Competitive Horizon 2020 Proposals
Riestra: How to Design and engineer Competitive Horizon 2020 Proposals
 
Bouquet: SIERA Workshop on The Pillars of Horizon2020
Bouquet: SIERA Workshop on The Pillars of Horizon2020Bouquet: SIERA Workshop on The Pillars of Horizon2020
Bouquet: SIERA Workshop on The Pillars of Horizon2020
 
Jarrar: Sparql Project
Jarrar: Sparql ProjectJarrar: Sparql Project
Jarrar: Sparql Project
 
Jarrar: Logical Foundation of Ontology Engineering
Jarrar: Logical Foundation of Ontology EngineeringJarrar: Logical Foundation of Ontology Engineering
Jarrar: Logical Foundation of Ontology Engineering
 
Jarrar: Stepwise Methodologies for Developing Ontologies
Jarrar: Stepwise Methodologies for Developing OntologiesJarrar: Stepwise Methodologies for Developing Ontologies
Jarrar: Stepwise Methodologies for Developing Ontologies
 

Recently uploaded

Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxfnnc6jmgwh
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Nikki Chapple
 
React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkPixlogix Infotech
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 

Recently uploaded (20)

Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
 
React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App Framework
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 

Jarrar: Games

  • 1. Jarrar © 2014 1 Dr. Mustafa Jarrar Sina Institute, University of Birzeit mjarrar@birzeit.edu www.jarrar.info Mustafa Jarrar: Lecture Notes on Games, Birzeit University, Palestine Fall Semester, 2014 Artificial Intelligence Chapter 6Chapter 6 Games (adversarial search problems)
  • 2. Jarrar © 2014 2 Watch this lecture and download the slides fromWatch this lecture and download the slides from http://jarrar-courses.blogspot.com/2011/11/artificial-intelligence-fall-2011.html Most information based on Chapter 5 of [1] Reference: Mustafa Jarrar: Lecture Notes on Conceptual Analyses University of Birzeit, Palestine, 2015 Online Course Watch Download Slides Mustafa Jarrar Birzeit University, Palestine mjarrar@birzeit.edu www.jarrar.info Mustafa Jarrar: Online Courses – Watch and Download Slides
  • 3. Jarrar © 2014 3 Can you plan ahead with these games
  • 4. Jarrar © 2014 4 Game Tree (2-player, deterministic, turns) Calculated by utility function, depends on the game. Last state, game is over How to see the game as a treeHow to see the game as a tree Image from [2]
  • 5. Jarrar © 2014 5 Your Moves My Moves My Moves Your Moves Your Moves My Moves My Moves My Moves • Two players take turns making moves • Board state fully known, deterministic evaluation of moves • One player wins by defeating the other (or else there is a tie) • Want a strategy to win, assuming the other person plays as well as possible Two-Person Perfect Information Deterministic Game
  • 6. Jarrar © 2014 6 Computer Games • Playing games can be seen as a Search Problem • Multiplayer games as multi-agent environments. • Agents' goals are in conflict. • Mostly deterministic and fully observable environments. • Some games are not trivial search problems, thus needs AI techniques, e.g. Chess has an average branching factor of 35, and games often go to 50 moves by each player, so the search tree has about 35100 or 10154 nodes. • Finding optimal move: choosing a good move with time limits. • Heuristic evaluation functions allow us to approximate the true utility of a state without doing a complete search.
  • 7. Jarrar © 2014 7 Minimax • Create a utility function – Evaluation of board/game state to determine how strong the position of player 1 is. – Player 1 wants to maximize the utility function – Player 2 wants to minimize the utility function • Minimax Tree – Generate a new level for each move – Levels alternate between “max” (player 1 moves) and “min” (player 2 moves)
  • 8. Jarrar © 2014 8 Minimax Tree Max Min Max Min You are Max and your enemy is Min.You are Max and your enemy is Min. You play with your enemy in this way.You play with your enemy in this way.
  • 9. Jarrar © 2014 9 Minimax Tree Evaluation • Assign utility values to leaves – Sometimes called “board evaluation function” – If leaf is a “final” state, assign the maximum or minimum possible utility value (depending on who would win). – If leaf is not a “final” state, must use some other heuristic, specific to the game, to evaluate how good/bad the state is at that point
  • 10. Jarrar © 2014 10 Minimax Tree Max Min Max Min 100 -24-8-14-73-100-5-70-12-470412-3212823 Terminal nodes: values calculated from the utility function, evaluates how good/bad the state is at this point
  • 11. Jarrar © 2014 11 Minimax Tree Evaluation For the MAX player 1. Generate the game as deep as time permits 2. Apply the evaluation function to the leaf states 3. Back-up values • At MIN assign minimum payoff move • At MAX assign maximum payoff move 1. At root, MAX chooses the operator that led to the highest payoff
  • 12. Jarrar © 2014 12 Minimax Tree -24-8-14-73-100-5-70-12-470412-3212823 Max Min Max Min Terminal nodes: values calculated from the utility function
  • 13. Jarrar © 2014 13 Minimax Tree 100 -24-8-14-73-100-5-70-12-470412-3212823 28 -3 12 70 -4 -73 -14 -8 Max Min Max Min Other nodes: values calculated via minimax algorithm
  • 14. Jarrar © 2014 14 Minimax Tree 100 -24-8-14-73-100-5-70-12-470412-3212823 21 -3 12 70 -4 -73 -14 -8 -3 -4 -73 Max Min Max Min
  • 15. Jarrar © 2014 15 Minimax Tree 100 -24-8-14-73-100-5-70-12-470412-3212823 21 -3 12 70 -4 -73 -14 -8 -3 -4 -73 -3 Max Min Max Min
  • 16. Jarrar © 2014 16 Minimax Tree 100 -24-8-14-73-100-5-70-12-470412-3212823 21 -3 12 70 -4 -73 -14 -8 -3 -4 -73 -3 Max Min Max Min The best next move for Max
  • 17. Jarrar © 2014 17 MiniMax Example-2 4 7 9 6 9 8 8 5 6 7 5 2 3 2 5 4 9 3 Terminal nodes: values calculated from the utility function Max Max Min Min Based on [3]
  • 18. Jarrar © 2014 18 MiniMax Example-2 4 7 9 6 9 8 8 5 6 7 5 2 3 2 5 4 9 3 4 7 6 2 6 3 4 5 1 2 5 4 1 2 6 3 4 3 Other nodes: values calculated via minimax algorithm Max Max Min Min
  • 19. Jarrar © 2014 19 MiniMax Example-2 4 7 9 6 9 8 8 5 6 7 5 2 3 2 5 4 9 3 4 7 6 2 6 3 4 5 1 2 5 4 1 2 6 3 4 3 7 6 5 5 6 4 Max Max Min Min
  • 20. Jarrar © 2014 20 MiniMax Example-2 4 7 9 6 9 8 8 5 6 7 5 2 3 2 5 4 9 3 4 7 6 2 6 3 4 5 1 2 5 4 1 2 6 3 4 3 7 6 5 5 6 4 5 3 4 Max Max Min Min
  • 21. Jarrar © 2014 21 MiniMax Example-2 4 7 9 6 9 8 8 5 6 7 5 2 3 2 5 4 9 3 4 7 6 2 6 3 4 5 1 2 5 4 1 2 6 3 4 3 7 6 5 5 6 4 5 3 4 5 Max Max Min Min
  • 22. Jarrar © 2014 22 MiniMax Example-2 Max Max Min Min 4 7 9 6 9 8 8 5 6 7 5 2 3 2 5 4 9 3 4 7 6 2 6 3 4 5 1 2 5 4 1 2 6 3 4 3 7 6 5 5 6 4 5 3 4 5 moves by Max and countermoves by Min
  • 23. Jarrar © 2014 23 Properties of MiniMax Complete? Yes (if tree is finite) Space complexity? A complete evaluation takes space bm (depth-first exploration) For chess, b ≈ 35, m ≈100 for "reasonable" games  exact solution completely infeasible, since it’s too big Instead, we limit the depth based on various factors, including time available. » • Optimal? Yes (against an optimal opponent) • Time complexity? A complete evaluation
  • 24. Jarrar © 2014 24 Alpha-Beta Pruning Algorithm
  • 25. Jarrar © 2014 25 Pruning the Minimax Tree • Since we have limited time available, we want to avoid unnecessary computation in the minimax tree. • Pruning: ways of determining that certain branches will not be useful. αα CutsCuts • If the current max value is greater than the successor’s min value, don’t explore that min subtree any more.
  • 26. Jarrar © 2014 26 α Cut Example 10021 -3 12 70 -4 -73 -14 -3 -4 -3 -73 Max Max Min
  • 27. Jarrar © 2014 27 α Cut Example • Depth first search along path 1 21 Max Max Min
  • 28. Jarrar © 2014 28 α Cut Example • 21 is minimum so far (second level) • Can’t evaluate yet at top level 21 21 Max Max Min
  • 29. Jarrar © 2014 29 α Cut Example • -3 is minimum so far (second level) • -3 is maximum so far (top level) 21 -3 -3 -3Max Max Min
  • 30. Jarrar © 2014 30 α Cut Example • 12 is minimum so far (second level) • -3 is still maximum (can’t use second node yet) 21 -3 12 -3 -3 12 Max Max Min
  • 31. Jarrar © 2014 31 α Cut Example • -70 is now minimum so far (second level) • -3 is still maximum (can’t use second node yet) 21 -3 12 -70 -3 -3 -70 Max Max Min
  • 32. Jarrar © 2014 32 α Cut Example • Since second level node will never be > -70, it will never be chosen by the previous level • We can stop exploring that node 21 -3 12 -70 -3 -3 -70 Max Max Min
  • 33. Jarrar © 2014 33 α Cut Example • Evaluation at second level is again -73 10021 -3 12 -70 -4 -73 -3 -3 -70 -73 Max Max Min
  • 34. Jarrar © 2014 34 α Cut Example • Again, can apply α cut since the second level node will never be > -73, and thus will never be chosen by the previous level 10021 -3 12 -70 -4 -73 -3 -3 -70 -73 Max Max Min
  • 35. Jarrar © 2014 35 α Cut Example • As a result, we evaluated the Max node without evaluating several of the possible paths 10021 -3 12 -70 -4 -73 -14 -3 -3 -70 -73 Max Max Min
  • 36. Jarrar © 2014 36 β Cuts • Similar idea to α cuts, but the other way around • If the current minimum is less than the successor’s max value, don’t look down that max tree any more
  • 37. Jarrar © 2014 37 β Cut Example • Some subtrees at second level already have values > min from previous, so we can stop evaluating them. 10021 -3 12 70 -4 73 -14 Min Min Max 21 21 70 73
  • 38. Jarrar © 2014 38 Alpha-Beta Example 2 [-∞, +∞] – we assume a depth-first, left-to-right search as basic strategy – the range of the possible values for each node are indicated • initially [-∞, +∞] • from Max’s or Min’s perspective • these local values reflect the values of the sub-trees in that node; the global values α and β are the best overall choices so far for Max or Min [-∞, +∞] α best choice for Max ? β best choice for Min ? Max Min
  • 39. Jarrar © 2014 39 Alpha-Beta Example 2 Max Min[-∞, 7] [-∞, +∞] α best choice for Max ? β best choice for Min 7 7
  • 40. Jarrar © 2014 40 Alpha-Beta Example 2 Max Min[-∞, 6] [-∞, +∞] α best choice for Max ? β best choice for Min 6 7 6
  • 41. Jarrar © 2014 41 Alpha-Beta Example 2 Max Min5 [5, +∞] α best choice for Max 5 β best choice for Min 5 7 6 5 – Min obtains the third value from a successor node – this is the last value from this sub-tree, and the exact value is known – Max now has a value for its first successor node, but hopes that something better might still come
  • 42. Jarrar © 2014 42 Alpha-Beta Example 2 Max Min[-∞, 5] [5, +∞] α best choice for Max 5 β best choice for Min 3 7 6 5 – Min continues with the next sub-tree, and gets a better value – Max has a better choice from its perspective, however, and will not consider a move in the sub-tree currently explored by min – Initially [-∞, +∞] [-∞,3] 3
  • 43. Jarrar © 2014 43 Alpha-Beta Example 2 Max Min[-∞, 5] [5, +∞] α best choice for Max 5 β best choice for Min 3 7 6 5 – Min knows that Max won’t consider a move to this sub-tree, and abandons it – this is a case of pruning, indicated by [-∞,3] 3
  • 44. Jarrar © 2014 44 Alpha-Beta Example 2 Max Min[-∞, 5] [5, +∞] α best choice for Max 5 β best choice for Min 3 7 6 5 – Min explores the next sub-tree, and finds a value that is worse than the other nodes at this level – if Min is not able to find something lower, then Max will choose this branch, so Min must explore more successor nodes [-∞,3] 3 [-∞,6] 6
  • 45. Jarrar © 2014 45 Alpha-Beta Example 2 Max Min[-∞, 5] [5, +∞] α best choice for Max 5 β best choice for Min 3 7 6 5 – Min is lucky, and finds a value that is the same as the current worst value at this level – Max can choose this branch, or the other branch with the same value [-∞,3] 3 [-∞,5] 6 5
  • 46. Jarrar © 2014 46 Alpha-Beta Example 2 Max Min[-∞, 5] 5 α best choice for Max 5 β best choice for Min 3 7 6 5 – Min could continue searching this sub-tree to see if there is a value that is less than the current worst alternative in order to give Max as few choices as possible – this depends on the specific implementation – Max knows the best value for its sub-tree [-∞,3] 3 [-∞,5] 6 5
  • 47. Jarrar © 2014 47 max min max min Exercise
  • 48. Jarrar © 2014 48 max min max min 10 9 14 2 4 10 14 4 10 4 10 Exercise (Solution)
  • 49. Jarrar © 2014 49 α-β Pruning • Pruning by these cuts does not affect final result – May allow you to go much deeper in tree • “Good” ordering of moves can make this pruning much more efficient – Evaluating “best” branch first yields better likelihood of pruning later branches – Perfect ordering reduces time to bm/2 instead of O(bd ) – i.e. doubles the depth you can search to!
  • 50. Jarrar © 2014 50 α-β Pruning • Can store information along an entire path, not just at most recent levels! • Keep along the path: α: best MAX value found on this path (initialize to most negative utility value) β: best MIN value found on this path (initialize to most positive utility value)
  • 51. Jarrar © 2014 51 Pruning at MAX node α is possibly updated by the MAX of successors evaluated so far • If the value that would be returned is ever > β, then stop work on this branch • If all children are evaluated without pruning, return the MAX of their values
  • 52. Jarrar © 2014 52 Pruning at MIN node β is possibly updated by the MIN of successors evaluated so far • If the value that would be returned is ever < α, then stop work on this branch • If all children are evaluated without pruning, return the MIN of their values
  • 53. Jarrar © 2014 53 Idea of α-β Pruning • We know β on this path is 21 • So, when we get max=70, we know this will never be used, so we can stop here 100 21 -3 12 70 -4 21 21 70
  • 54. Jarrar © 2014 54 Why is it called α-β? • α is the value of the best (i.e., highest- value) choice found so far at any choice point along the path for max • If v is worse than α, max will avoid it  prune that branch • Define β similarly for min
  • 55. Jarrar © 2014 55 Imperfect Decisions • Complete search is impractical for most games • Alternative: search the tree only to a certain depth – Requires a cutoff-test to determine where to stop • Replaces the terminal test • The nodes at that level effectively become terminal leave nodes – Uses a heuristics-based evaluation function to estimate the expected utility of the game from those leave nodes.
  • 56. Jarrar © 2014 56 Utility Evaluation Function • Very game-specific • Take into account knowledge about game • “Stupid” utility – 1 if player 1 wins – -1 if player 0 wins – 0 if tie (or unknown) – Only works if we can evaluate complete tree – But, should form a basis for other evaluations
  • 57. Jarrar © 2014 57 Utility Evaluation • Need to assign a numerical value to the state – Could assign a more complex utility value, but then the min/max determination becomes trickier. • Typically assign numerical values to lots of individual factors: – a = # player 1’s pieces - # player 2’s pieces – b = 1 if player 1 has queen and player 2 does not, -1 if the opposite, or 0 if the same – c = 2 if player 1 has 2-rook advantage, 1 if a 1-rook advantage, etc.
  • 58. Jarrar © 2014 58 Utility Evaluation • The individual factors are combined by some function • Usually a linear weighted combination is used: – u = αa + βb + χc – Different ways to combine are also possible • Notice: quality of utility function is based on: – What features are evaluated – How those features are scored – How the scores are weighted/combined • Absolute utility value doesn’t matter – relative value does.
  • 59. Jarrar © 2014 59 Evaluation Functions • If you had a perfect utility evaluation function, what would it mean about the minimax tree? You would never have to evaluate more than one level deep! • Typically, you can’t create such perfect utility evaluations, though.
  • 60. Jarrar © 2014 60 Evaluation Functions for Ordering • As mentioned earlier, order of branch evaluation can make a big difference in how well you can prune • A good evaluation function might help you order your available moves: – Perform one move only – Evaluate board at that level – Recursively evaluate branches in order from best first move to worst first move (or vice-versa if at a MIN node)
  • 61. Jarrar © 2014 61 The following are extra Examples (Self Study)
  • 62. Jarrar © 2014 62 Example: Tic-Tac-Toe (evaluation function) • Simple evaluation function E(s) = (rx + cx + dx) - (ro + co + do) where r,c,d are the numbers of row, column and diagonal lines still available; x and o are the pieces of the two players. • 1-ply lookahead – start at the top of the tree – evaluate all 9 choices for player 1 – pick the maximum E-value • 2-ply lookahead – also looks at the opponents possible move • assuming that the opponents picks the minimum E-value
  • 63. Jarrar © 2014 63 E(s12) 8 - 6 = 2 E(s13) 8 - 5 = 3 E(s14) 8 - 6 = 2 E(s15) 8 - 4 = 4 E(s16) 8 - 6 = 2 E(s17) 8 - 5 = 3 E(s18) 8 - 6 = 2 E(s19) 8 - 5 = 3 Tic-Tac-Toe 1-Ply X X X X X X X X X E(s11) 8 - 5 = 3 E(s0) = Max{E(s11), E(s1n)} = Max{2,3,4} = 4 Based on [3]
  • 64. Jarrar © 2014 64 E(s2:16) 5 - 6 = -1 E(s2:15) 5 -6 = -1 E(s28) 5 - 5 = 0 E(s27) 6 - 5 = 1 E(s2:48) 5 - 4 = 1 E(s2:47) 6 - 4 = 2 E(s2:13) 5 - 6 = -1 E(s2:9) 5 - 6 = -1 E(s2:10) 5 -6 = -1 E(s2:11) 5 - 6 = -1 E(s2:12) 5 - 6 = -1 E(s2:14) 5 - 6 = -1 E(s25) 6 - 5 = 1 E(s21) 6 - 5 = 1 E(s22) 5 - 5 = 0 E(s23) 6 - 5 = 1 E(s24) 4 - 5 = -1 E(s26) 5 - 5 = 0 E(s1:6) 8 - 6 = 2 E(s1:7) 8 - 5 = 3 E(s1:8) 8 - 6 = 2 E(s1:9) 8 - 5 = 3 E(s1:5) 8 - 4 = 4 E(s1:3) 8 - 5 = 3 E(s1:2) 8 - 6 = 2 E(s1:1) 8 - 5 = 3 E(s2:45) 6 - 4 = 2 Tic-Tac-Toe 2-Ply X X X X X X X X X E(s1:4) 8 - 6 = 2 X O X O X O E(s2:41) 5 - 4 = 1 E(s2:42) 6 - 4 = 2 E(s2:43) 5 - 4 = 1 E(s2:44) 6 - 4 = 2 E(s2:46) 5 - 4 = 1 O X O X O X O X X O X O X O X O XX O X OO X X O X O X O X O X O X O X OX O X O O E(s0) = Max{E(s11), E(s1n)} = Max{2,3,4} = 4
  • 65. Jarrar © 2014 65 31 Checkers Case Study • Initial board configuration – Black single on 20 single on 21 king on 31 – Red single on 23 king on 22 – Evaluation function E(s) = (5 x1 + x2) - (5r1 + r2) where x1 = black king advantage, x2 = black single advantage, r1 = red king advantage, r2 = red single advantage 1 2 3 4 865 9 10 11 12 161413 17 18 19 20 242221 25 26 27 28 323029 7 15 23 Based on [4]
  • 66. Jarrar © 2014 66 1 1 1 1 1 2 2 6 6 1 1 1 1 1 1 1 1 1 1 1 1 6 6 0 0 0 0 -4 -4 -4 -8 -8 -8 -8 -8 -8 1 0 -8 -8 1 20 -> 16 21->17 31 -> 26 31 -> 27 22 -> 17 22 -> 18 22->25 22->26 23->26 23 -> 27 21 -> 14 16 -> 11 31->27 16->11 31->27 31->27 16->11 31 -> 27 31->24 22->13 22->31 23 -> 30 23 -> 32 20->16 31->27 31->26 21->17 20->16 21->17 20->16 20->16 21->17 31 1 2 3 4 865 9 10 11 12 161413 17 18 19 20 242221 25 26 27 28 323029 7 15 23 MAX MAX MIN Checkers MiniMax Example
  • 67. Jarrar © 2014 67 1 1 1 1 1 2 2 6 6 1 1 1 1 1 1 1 1 1 1 1 1 6 6 0 0 0 0 -4 -4 -4 -8 -8 -8 -8 -8 -8 1 0 -4 -8 1 20 -> 16 21->17 31 -> 26 31 -> 27 22 -> 17 22 -> 18 22->25 22->26 23->26 23 -> 27 21 -> 14 16 -> 11 31->27 16->11 31->27 31->27 16->11 31 -> 27 31->24 22->18 22->31 23 -> 30 23 -> 32 20->16 31->27 31->26 21->17 20->16 21->17 20->16 20->16 21->17 31 1 2 3 4 865 9 10 11 12 161413 17 18 19 20 242221 25 26 27 28 323029 7 15 23 α 1 β 6 MAX MAX MIN Checkers Alpha-Beta Example
  • 68. Jarrar © 2014 68 1 1 1 1 1 2 2 6 6 1 1 1 1 1 1 1 1 1 1 1 1 6 6 0 0 0 0 -4 -4 -4 -8 -8 -8 -8 -8 -8 1 0 -4 -8 1 20 -> 16 21->17 31 -> 26 31 -> 27 22 -> 17 22 -> 18 22->25 22->26 23->26 23 -> 27 21 -> 14 16 -> 11 31->27 16->11 31->27 31->27 16->11 31 -> 27 31->24 22->18 22->31 23 -> 30 23 -> 32 20->16 31->27 31->26 21->17 20->16 21->17 20->16 20->16 21->17 31 1 2 3 4 865 9 10 11 12 161413 17 18 19 20 242221 25 26 27 28 323029 7 15 23 α 1 β 1 MAX MAX MIN Checkers Alpha-Beta Example
  • 69. Jarrar © 2014 69 1 1 1 1 1 2 2 6 6 1 1 1 1 1 1 1 1 1 1 1 1 6 6 0 0 0 0 -4 -4 -4 -8 -8 -8 -8 -8 -8 1 0 -4 -8 1 20 -> 16 21->17 31 -> 26 31 -> 27 22 -> 17 22 -> 18 22->25 22->26 23->26 23 -> 27 21 -> 14 16 -> 11 31->27 16->11 31->27 31->22 16->11 31 -> 27 31->24 22->18 22->31 23 -> 30 23 -> 32 20->16 31->27 31->26 21->17 20->16 21->17 20->16 20->16 21->17 31 1 2 3 4 865 9 10 11 12 161413 17 18 19 20 242221 25 26 27 28 323029 7 15 23 α 1 β 1 β− cutoff: no need to examine further branches MAX MAX MIN Checkers Alpha-Beta Example
  • 70. Jarrar © 2014 70 1 1 1 1 1 2 2 6 6 1 1 1 1 1 1 1 1 1 1 1 1 6 6 0 0 0 0 -4 -4 -4 -8 -8 -8 -8 -8 -8 1 0 -4 -8 1 20 -> 16 21->17 31 -> 26 31 -> 27 22 -> 17 22 -> 18 22->25 22->26 23->26 23 -> 27 21 -> 14 16 -> 11 31->27 16->11 31->27 31->22 16->11 31 -> 27 31->24 22->18 22->31 23 -> 30 23 -> 32 20->16 31->27 31->26 21->17 20->16 21->17 20->16 20->16 21->17 31 1 2 3 4 865 9 10 11 12 161413 17 18 19 20 242221 25 26 27 28 323029 7 15 23 α 1 β 1 MAX MAX MIN Checkers Alpha-Beta Example
  • 71. Jarrar © 2014 71 1 1 1 1 1 2 2 6 6 1 1 1 1 1 1 1 1 1 1 1 1 6 6 0 0 0 0 -4 -4 -4 -8 -8 -8 -8 -8 -8 1 0 -4 -8 1 20 -> 16 21->17 31 -> 26 31 -> 27 22 -> 17 22 -> 18 22->25 22->26 23->26 23 -> 27 21 -> 14 16 -> 11 31->27 16->11 31->27 31->22 16->11 31 -> 27 31->24 22->18 22->31 23 -> 30 23 -> 32 20->16 31->27 31->26 21->17 20->16 21->17 20->16 20->16 21->17 31 1 2 3 4 865 9 10 11 12 161413 17 18 19 20 242221 25 26 27 28 323029 7 15 23 α 1 β 1 β− cutoff: no need to examine further branches MAX MAX MIN Checkers Alpha-Beta Example
  • 72. Jarrar © 2014 72 1 1 1 1 1 2 2 6 6 1 1 1 1 1 1 1 1 1 1 1 1 6 6 0 0 0 0 -4 -4 -4 -8 -8 -8 -8 -8 -8 1 0 -4 -8 1 20 -> 16 21->17 31 -> 26 31 -> 27 22 -> 17 22 -> 18 22->25 22->26 23->26 23 -> 27 21 -> 14 16 -> 11 31->27 16->11 31->27 31->22 16->11 31 -> 27 31->24 22->18 22->31 23 -> 30 23 -> 32 20->16 31->27 31->26 21->17 20->16 21->17 20->16 20->16 21->17 31 1 2 3 4 865 9 10 11 12 161413 17 18 19 20 242221 25 26 27 28 323029 7 15 23 α 1 β 1 MAX MAX MIN Checkers Alpha-Beta Example
  • 73. Jarrar © 2014 73 1 1 1 1 1 2 2 6 6 1 1 1 1 1 1 1 1 1 1 1 1 6 6 0 0 0 0 -4 -4 -4 -8 -8 -8 -8 -8 -8 1 0 -4 -8 1 20 -> 16 21->17 31 -> 26 31 -> 27 22 -> 17 22 -> 18 22->25 22->26 23->26 23 -> 27 21 -> 14 16 -> 11 31->27 16->11 31->27 31->22 16->11 31 -> 27 31->24 22->13 22->31 23 -> 30 23 -> 32 20->16 31->27 31->26 21->17 20->16 21->17 20->16 20->16 21->17 31 1 2 3 4 865 9 10 11 12 161413 17 18 19 20 242221 25 26 27 28 323029 7 15 23 α 1 β 0 MAX MAX MIN Checkers Alpha-Beta Example
  • 74. Jarrar © 2014 74 Checkers Alpha-Beta Example 1 1 1 1 1 2 2 6 6 1 1 1 1 1 1 1 1 1 1 1 1 6 6 0 0 0 0 -4 -4 -4 -8 -8 -8 -8 -8 -8 1 0 -4 -8 1 20 -> 16 21->17 31 -> 26 31 -> 27 22 -> 17 22 -> 18 22->25 22->26 23->26 23 -> 27 21 -> 14 16 -> 11 31->27 16->11 31->27 31->22 16->11 31 -> 27 31->24 22->18 22->31 23 -> 30 23 -> 32 20->16 31->27 31->26 21->17 20->16 21->17 20->16 20->16 21->17 31 1 2 3 4 865 9 10 11 12 161413 17 18 19 20 242221 25 26 27 28 323029 7 15 23 α 1 β -4 α− cutoff: no need to examine further branches MAX MAX MIN
  • 75. Jarrar © 2014 75 22->31 1 1 1 1 1 2 2 6 6 1 1 1 1 1 1 1 1 1 1 1 1 6 6 0 0 0 0 -4 -4 -4 -8 -8 -8 -8 -8 -8 1 0 -4 -8 1 20 -> 16 21->17 31 -> 26 31 -> 27 22 -> 17 22 -> 18 22->25 22->26 23->26 23 -> 27 21 -> 14 16 -> 11 31->27 16->11 31->27 31->22 16->11 31 -> 27 31->24 22->18 23 -> 30 23 -> 32 20->16 31->27 31->26 21->17 20->16 21->17 20->16 20->16 21->17 31 1 2 3 4 865 9 10 11 12 161413 17 18 19 20 242221 25 26 27 28 323029 7 15 23 α 1 β -8 MAX MAX MIN Checkers Alpha-Beta Example
  • 76. Jarrar © 2014 76 References [1][1] S. Russell and P. Norvig: Artificial Intelligence: A Modern ApproachS. Russell and P. Norvig: Artificial Intelligence: A Modern Approach Prentice Hall, 2003, Second EditionPrentice Hall, 2003, Second Edition [2][2] Nilufer Onden: Lecture Notes on Artificial IntelligenceNilufer Onden: Lecture Notes on Artificial Intelligence http://www.cs.mtu.edu/~nilufer/classes/cs4811/2014-spring/lecture-slides/cs4811-ch05-adversarial-http://www.cs.mtu.edu/~nilufer/classes/cs4811/2014-spring/lecture-slides/cs4811-ch05-adversarial- search.pdfsearch.pdf [3][3] Samy Abu Nasser: Lecture Notes on Artificial IntelligenceSamy Abu Nasser: Lecture Notes on Artificial Intelligence http://up.edu.ps/ocw/repositories/academic/up/bs/it/ITLS4213/022009/data/ITLS4213.101_11042009.ppthttp://up.edu.ps/ocw/repositories/academic/up/bs/it/ITLS4213/022009/data/ITLS4213.101_11042009.ppt [4][4] Franz Kurfess: Lecture Notes on Artificial IntelligenceFranz Kurfess: Lecture Notes on Artificial Intelligence http://users.csc.calpoly.edu/~fkurfess/Courses/Artificial-Intelligence/F09/Slides/3-Search.ppthttp://users.csc.calpoly.edu/~fkurfess/Courses/Artificial-Intelligence/F09/Slides/3-Search.ppt