![Page 1: CSC242: Intro to AI - University of Rochester · Alpha-Beta Pruning How can we make MiniMax run faster, without sacrificing optimality?! During MINIMAX search keep track of! α:](https://reader033.vdocuments.net/reader033/viewer/2022052518/5f0ad3ba7e708231d42d88f0/html5/thumbnails/1.jpg)
CSC242: Intro to AIAdversarial Search
Part II
![Page 2: CSC242: Intro to AI - University of Rochester · Alpha-Beta Pruning How can we make MiniMax run faster, without sacrificing optimality?! During MINIMAX search keep track of! α:](https://reader033.vdocuments.net/reader033/viewer/2022052518/5f0ad3ba7e708231d42d88f0/html5/thumbnails/2.jpg)
Today
How to improve MINIMAX to make it more practical
Details of Othello project
How to generalize MINIMAX for uncertainty and hidden information
![Page 3: CSC242: Intro to AI - University of Rochester · Alpha-Beta Pruning How can we make MiniMax run faster, without sacrificing optimality?! During MINIMAX search keep track of! α:](https://reader033.vdocuments.net/reader033/viewer/2022052518/5f0ad3ba7e708231d42d88f0/html5/thumbnails/3.jpg)
Player
Opponent
Player
Opponent
m
n
•••
Alpha-Beta Pruning
![Page 4: CSC242: Intro to AI - University of Rochester · Alpha-Beta Pruning How can we make MiniMax run faster, without sacrificing optimality?! During MINIMAX search keep track of! α:](https://reader033.vdocuments.net/reader033/viewer/2022052518/5f0ad3ba7e708231d42d88f0/html5/thumbnails/4.jpg)
Alpha-Beta PruningHow can we make MiniMax run faster, without sacrificing optimality?
During MINIMAX search keep track of
α: value of best choice so far for MAX (lower bound on MAX utility)
β: value of best choice so far for MIN (upper bound on MIN utility)
Prune when value of node is known to be worse than α (for MAX) or β (for MIN)
![Page 5: CSC242: Intro to AI - University of Rochester · Alpha-Beta Pruning How can we make MiniMax run faster, without sacrificing optimality?! During MINIMAX search keep track of! α:](https://reader033.vdocuments.net/reader033/viewer/2022052518/5f0ad3ba7e708231d42d88f0/html5/thumbnails/5.jpg)
A
B C D
MAX
MIN
312 8 2 4 6 14 2 5
3 2 2
3
![Page 6: CSC242: Intro to AI - University of Rochester · Alpha-Beta Pruning How can we make MiniMax run faster, without sacrificing optimality?! During MINIMAX search keep track of! α:](https://reader033.vdocuments.net/reader033/viewer/2022052518/5f0ad3ba7e708231d42d88f0/html5/thumbnails/6.jpg)
A
B C D
MAX
MIN
[-∞,+∞]
![Page 7: CSC242: Intro to AI - University of Rochester · Alpha-Beta Pruning How can we make MiniMax run faster, without sacrificing optimality?! During MINIMAX search keep track of! α:](https://reader033.vdocuments.net/reader033/viewer/2022052518/5f0ad3ba7e708231d42d88f0/html5/thumbnails/7.jpg)
A
B C D
MAX
MIN
[-∞,+∞]
[-∞,+∞]
![Page 8: CSC242: Intro to AI - University of Rochester · Alpha-Beta Pruning How can we make MiniMax run faster, without sacrificing optimality?! During MINIMAX search keep track of! α:](https://reader033.vdocuments.net/reader033/viewer/2022052518/5f0ad3ba7e708231d42d88f0/html5/thumbnails/8.jpg)
A
B C D
MAX
MIN
[-∞,+∞]
[-∞,+12]
12
![Page 9: CSC242: Intro to AI - University of Rochester · Alpha-Beta Pruning How can we make MiniMax run faster, without sacrificing optimality?! During MINIMAX search keep track of! α:](https://reader033.vdocuments.net/reader033/viewer/2022052518/5f0ad3ba7e708231d42d88f0/html5/thumbnails/9.jpg)
A
B C D
MAX
MIN
[-∞,+∞]
[-∞,+3]
12 3
![Page 10: CSC242: Intro to AI - University of Rochester · Alpha-Beta Pruning How can we make MiniMax run faster, without sacrificing optimality?! During MINIMAX search keep track of! α:](https://reader033.vdocuments.net/reader033/viewer/2022052518/5f0ad3ba7e708231d42d88f0/html5/thumbnails/10.jpg)
A
B C D
MAX
MIN
[-∞,+∞]
[-∞,+3]
12 3 8
![Page 11: CSC242: Intro to AI - University of Rochester · Alpha-Beta Pruning How can we make MiniMax run faster, without sacrificing optimality?! During MINIMAX search keep track of! α:](https://reader033.vdocuments.net/reader033/viewer/2022052518/5f0ad3ba7e708231d42d88f0/html5/thumbnails/11.jpg)
A
B C D
MAX
MIN
[3,-∞]
[-∞,+3]
12 3 8
![Page 12: CSC242: Intro to AI - University of Rochester · Alpha-Beta Pruning How can we make MiniMax run faster, without sacrificing optimality?! During MINIMAX search keep track of! α:](https://reader033.vdocuments.net/reader033/viewer/2022052518/5f0ad3ba7e708231d42d88f0/html5/thumbnails/12.jpg)
A
B C D
MAX
MIN
[3,-∞]
[-∞,+3]
12 3 8
[3,-∞]
![Page 13: CSC242: Intro to AI - University of Rochester · Alpha-Beta Pruning How can we make MiniMax run faster, without sacrificing optimality?! During MINIMAX search keep track of! α:](https://reader033.vdocuments.net/reader033/viewer/2022052518/5f0ad3ba7e708231d42d88f0/html5/thumbnails/13.jpg)
A
B C D
MAX
MIN
[3,-∞]
[-∞,+3]
12 3 8
[3,-∞]
2
![Page 14: CSC242: Intro to AI - University of Rochester · Alpha-Beta Pruning How can we make MiniMax run faster, without sacrificing optimality?! During MINIMAX search keep track of! α:](https://reader033.vdocuments.net/reader033/viewer/2022052518/5f0ad3ba7e708231d42d88f0/html5/thumbnails/14.jpg)
A
B C D
MAX
MIN
[3,-∞]
[-∞,+3]
12 3 8
[3,2]
2
![Page 15: CSC242: Intro to AI - University of Rochester · Alpha-Beta Pruning How can we make MiniMax run faster, without sacrificing optimality?! During MINIMAX search keep track of! α:](https://reader033.vdocuments.net/reader033/viewer/2022052518/5f0ad3ba7e708231d42d88f0/html5/thumbnails/15.jpg)
A
B C D
MAX
MIN
[3,-∞]
[-∞,+3]
12 3 8
[3,2]
2
![Page 16: CSC242: Intro to AI - University of Rochester · Alpha-Beta Pruning How can we make MiniMax run faster, without sacrificing optimality?! During MINIMAX search keep track of! α:](https://reader033.vdocuments.net/reader033/viewer/2022052518/5f0ad3ba7e708231d42d88f0/html5/thumbnails/16.jpg)
A
B C D
MAX
MIN
[3,-∞]
[-∞,+3]
12 3 8
[3,2]
2
[3,-∞]
![Page 17: CSC242: Intro to AI - University of Rochester · Alpha-Beta Pruning How can we make MiniMax run faster, without sacrificing optimality?! During MINIMAX search keep track of! α:](https://reader033.vdocuments.net/reader033/viewer/2022052518/5f0ad3ba7e708231d42d88f0/html5/thumbnails/17.jpg)
A
B C D
MAX
MIN
[3,-∞]
[-∞,+3]
12 3 8
[3,2]
2
[3,14]
14
![Page 18: CSC242: Intro to AI - University of Rochester · Alpha-Beta Pruning How can we make MiniMax run faster, without sacrificing optimality?! During MINIMAX search keep track of! α:](https://reader033.vdocuments.net/reader033/viewer/2022052518/5f0ad3ba7e708231d42d88f0/html5/thumbnails/18.jpg)
A
B C D
MAX
MIN
[3,-∞]
[-∞,+3]
12 3 8
[3,2]
2
[3,14]
14
![Page 19: CSC242: Intro to AI - University of Rochester · Alpha-Beta Pruning How can we make MiniMax run faster, without sacrificing optimality?! During MINIMAX search keep track of! α:](https://reader033.vdocuments.net/reader033/viewer/2022052518/5f0ad3ba7e708231d42d88f0/html5/thumbnails/19.jpg)
A
B C D
MAX
MIN
[3,-∞]
[-∞,+3]
12 3 8
[3,2]
2
[3,2]
14 2
![Page 20: CSC242: Intro to AI - University of Rochester · Alpha-Beta Pruning How can we make MiniMax run faster, without sacrificing optimality?! During MINIMAX search keep track of! α:](https://reader033.vdocuments.net/reader033/viewer/2022052518/5f0ad3ba7e708231d42d88f0/html5/thumbnails/20.jpg)
A
B C D
MAX
MIN
[3,-∞]
[-∞,+3]
12 3 8
[3,2]
2
[3,2]
14 2
![Page 21: CSC242: Intro to AI - University of Rochester · Alpha-Beta Pruning How can we make MiniMax run faster, without sacrificing optimality?! During MINIMAX search keep track of! α:](https://reader033.vdocuments.net/reader033/viewer/2022052518/5f0ad3ba7e708231d42d88f0/html5/thumbnails/21.jpg)
A
B C D
MAX
MIN
[3,-∞]
[-∞,+3]
12 3 8
[3,2]
2
[3,2]
14 2
![Page 22: CSC242: Intro to AI - University of Rochester · Alpha-Beta Pruning How can we make MiniMax run faster, without sacrificing optimality?! During MINIMAX search keep track of! α:](https://reader033.vdocuments.net/reader033/viewer/2022052518/5f0ad3ba7e708231d42d88f0/html5/thumbnails/22.jpg)
Alpha-Beta H-Minimax
AlphaBeta(origin, 0, -inf, +inf, player) !function AlphaBeta(state, depth, alpha, beta, player) if CutoffTest(state, depth) then return Eval(State) if player == +1 then for each action in Actions(state, player) beta = max(beta, AlphaBeta(Result(state,action), depth+1, alpha, beta, -player)) if beta <= alpha then break /* beta cut-off */ return alpha else /* player == -1 */ for each action in Actions(state, player) alpha = min(alpha,AlphaBeta(Result(state,action), depth+1, alpha, beta, -player)) if beta <= alpha then break /* alpha cut-off */ return beta end
![Page 23: CSC242: Intro to AI - University of Rochester · Alpha-Beta Pruning How can we make MiniMax run faster, without sacrificing optimality?! During MINIMAX search keep track of! α:](https://reader033.vdocuments.net/reader033/viewer/2022052518/5f0ad3ba7e708231d42d88f0/html5/thumbnails/23.jpg)
Alpha-Beta H-Minimax
AlphaBeta(origin, 0, -inf, +inf, player) !function AlphaBeta(state, depth, alpha, beta, player) if CutoffTest(state, depth) then return Eval(State) if player == +1 then for each action in Actions(state, player) beta = max(beta, AlphaBeta(Result(state,action), depth+1, alpha, beta, -player)) if beta <= alpha then break /* beta cut-off */ return alpha else /* player == -1 */ for each action in Actions(state, player) alpha = min(alpha,AlphaBeta(Result(state,action), depth+1, alpha, beta, -player)) if beta <= alpha then break /* alpha cut-off */ return beta end
![Page 24: CSC242: Intro to AI - University of Rochester · Alpha-Beta Pruning How can we make MiniMax run faster, without sacrificing optimality?! During MINIMAX search keep track of! α:](https://reader033.vdocuments.net/reader033/viewer/2022052518/5f0ad3ba7e708231d42d88f0/html5/thumbnails/24.jpg)
Alpha-Beta H-Minimax
AlphaBeta(origin, 0, -inf, +inf, player) !function AlphaBeta(state, depth, alpha, beta, player) if CutoffTest(state, depth) then return Eval(State) if player == +1 then for each action in Actions(state, player) beta = max(beta, AlphaBeta(Result(state,action), depth+1, alpha, beta, -player)) if beta <= alpha then break /* beta cut-off */ return alpha else /* player == -1 */ for each action in Actions(state, player) alpha = min(alpha,AlphaBeta(Result(state,action), depth+1, alpha, beta, -player)) if beta <= alpha then break /* alpha cut-off */ return beta end
![Page 25: CSC242: Intro to AI - University of Rochester · Alpha-Beta Pruning How can we make MiniMax run faster, without sacrificing optimality?! During MINIMAX search keep track of! α:](https://reader033.vdocuments.net/reader033/viewer/2022052518/5f0ad3ba7e708231d42d88f0/html5/thumbnails/25.jpg)
Alpha-Beta H-Minimax
AlphaBeta(origin, 0, -inf, +inf, player) !function AlphaBeta(state, depth, alpha, beta, player) if CutoffTest(state, depth) then return Eval(State) if player == +1 then for each action in Actions(state, player) beta = max(beta, AlphaBeta(Result(state,action), depth+1, alpha, beta, -player)) if beta <= alpha then break /* beta cut-off */ return alpha else /* player == -1 */ for each action in Actions(state, player) alpha = min(alpha,AlphaBeta(Result(state,action), depth+1, alpha, beta, -player)) if beta <= alpha then break /* alpha cut-off */ return beta end
![Page 26: CSC242: Intro to AI - University of Rochester · Alpha-Beta Pruning How can we make MiniMax run faster, without sacrificing optimality?! During MINIMAX search keep track of! α:](https://reader033.vdocuments.net/reader033/viewer/2022052518/5f0ad3ba7e708231d42d88f0/html5/thumbnails/26.jpg)
Alpha-Beta H-Minimax
AlphaBeta(origin, 0, -inf, +inf, player) !function AlphaBeta(state, depth, alpha, beta, player) if CutoffTest(state, depth) then return Eval(State) if player == +1 then for each action in Actions(state, player) beta = max(beta, AlphaBeta(Result(state,action), depth+1, alpha, beta, -player)) if beta <= alpha then break /* beta cut-off */ return alpha else /* player == -1 */ for each action in Actions(state, player) alpha = min(alpha,AlphaBeta(Result(state,action), depth+1, alpha, beta, -player)) if beta <= alpha then break /* alpha cut-off */ return beta end
![Page 27: CSC242: Intro to AI - University of Rochester · Alpha-Beta Pruning How can we make MiniMax run faster, without sacrificing optimality?! During MINIMAX search keep track of! α:](https://reader033.vdocuments.net/reader033/viewer/2022052518/5f0ad3ba7e708231d42d88f0/html5/thumbnails/27.jpg)
Alpha-Beta H-Minimax
AlphaBeta(origin, 0, -inf, +inf, player) !function AlphaBeta(state, depth, alpha, beta, player) if CutoffTest(state, depth) then return Eval(State) if player == +1 then for each action in Actions(state, player) beta = max(beta, AlphaBeta(Result(state,action), depth+1, alpha, beta, -player)) if beta <= alpha then break /* beta cut-off */ return alpha else /* player == -1 */ for each action in Actions(state, player) alpha = min(alpha,AlphaBeta(Result(state,action), depth+1, alpha, beta, -player)) if beta <= alpha then break /* alpha cut-off */ return beta end
![Page 28: CSC242: Intro to AI - University of Rochester · Alpha-Beta Pruning How can we make MiniMax run faster, without sacrificing optimality?! During MINIMAX search keep track of! α:](https://reader033.vdocuments.net/reader033/viewer/2022052518/5f0ad3ba7e708231d42d88f0/html5/thumbnails/28.jpg)
Alpha-Beta H-Minimax
AlphaBeta(origin, 0, -inf, +inf, player) !function AlphaBeta(state, depth, alpha, beta, player) if CutoffTest(state, depth) then return Eval(State) if player == +1 then for each action in Actions(state, player) beta = max(beta, AlphaBeta(Result(state,action), depth+1, alpha, beta, -player)) if beta <= alpha then break /* beta cut-off */ return alpha else /* player == -1 */ for each action in Actions(state, player) alpha = min(alpha,AlphaBeta(Result(state,action), depth+1, alpha, beta, -player)) if beta <= alpha then break /* alpha cut-off */ return beta end
![Page 29: CSC242: Intro to AI - University of Rochester · Alpha-Beta Pruning How can we make MiniMax run faster, without sacrificing optimality?! During MINIMAX search keep track of! α:](https://reader033.vdocuments.net/reader033/viewer/2022052518/5f0ad3ba7e708231d42d88f0/html5/thumbnails/29.jpg)
Alpha-Beta H-Minimax
AlphaBeta(origin, 0, -inf, +inf, player) !function AlphaBeta(state, depth, alpha, beta, player) if CutoffTest(state, depth) then return Eval(State) if player == +1 then for each action in Actions(state, player) beta = max(beta, AlphaBeta(Result(state,action), depth+1, alpha, beta, -player)) if beta <= alpha then break /* beta cut-off */ return alpha else /* player == -1 */ for each action in Actions(state, player) alpha = min(alpha,AlphaBeta(Result(state,action), depth+1, alpha, beta, -player)) if beta <= alpha then break /* alpha cut-off */ return beta end
![Page 30: CSC242: Intro to AI - University of Rochester · Alpha-Beta Pruning How can we make MiniMax run faster, without sacrificing optimality?! During MINIMAX search keep track of! α:](https://reader033.vdocuments.net/reader033/viewer/2022052518/5f0ad3ba7e708231d42d88f0/html5/thumbnails/30.jpg)
Alpha-Beta H-Minimax
AlphaBeta(origin, 0, -inf, +inf, player) !function AlphaBeta(state, depth, alpha, beta, player) if CutoffTest(state, depth) then return Eval(State) if player == +1 then for each action in Actions(state, player) beta = max(beta, AlphaBeta(Result(state,action), depth+1, alpha, beta, -player)) if beta <= alpha then break /* beta cut-off */ return alpha else /* player == -1 */ for each action in Actions(state, player) alpha = min(alpha,AlphaBeta(Result(state,action), depth+1, alpha, beta, -player)) if beta <= alpha then break /* alpha cut-off */ return beta end
![Page 31: CSC242: Intro to AI - University of Rochester · Alpha-Beta Pruning How can we make MiniMax run faster, without sacrificing optimality?! During MINIMAX search keep track of! α:](https://reader033.vdocuments.net/reader033/viewer/2022052518/5f0ad3ba7e708231d42d88f0/html5/thumbnails/31.jpg)
Alpha-Beta H-Minimax
AlphaBeta(origin, 0, -inf, +inf, player) !function AlphaBeta(state, depth, alpha, beta, player) if CutoffTest(state, depth) then return Eval(State) if player == +1 then for each action in Actions(state, player) beta = max(beta, AlphaBeta(Result(state,action), depth+1, alpha, beta, -player)) if beta <= alpha then break /* beta cut-off */ return alpha else /* player == -1 */ for each action in Actions(state, player) alpha = min(alpha,AlphaBeta(Result(state,action), depth+1, alpha, beta, -player)) if beta <= alpha then break /* alpha cut-off */ return beta end
![Page 32: CSC242: Intro to AI - University of Rochester · Alpha-Beta Pruning How can we make MiniMax run faster, without sacrificing optimality?! During MINIMAX search keep track of! α:](https://reader033.vdocuments.net/reader033/viewer/2022052518/5f0ad3ba7e708231d42d88f0/html5/thumbnails/32.jpg)
Alpha-Beta H-Minimax Returning Movefunction AlphaBeta(state, depth, alpha, beta, player) if CutoffTest(state, depth) then return (Eval(State), null) best = null /* to handle case where no move is possible */ if player == +1 then for each action in Actions(state, player) child = Result(state, action) value = AlphaBeta(child, depth+1, alpha, beta, -player) if value > alpha then alpha = value best = action if beta <= alpha then break /* beta cut-off */ return (alpha, best) else /* player == -1 */ for each action in Actions(state, player) child = Result(state, action) value = AlphaBeta(child, depth+1, alpha, beta, -player) if value < beta then beta = value best = action if beta <= alpha then break /* alpha cut-off */ return (beta, best) en
![Page 33: CSC242: Intro to AI - University of Rochester · Alpha-Beta Pruning How can we make MiniMax run faster, without sacrificing optimality?! During MINIMAX search keep track of! α:](https://reader033.vdocuments.net/reader033/viewer/2022052518/5f0ad3ba7e708231d42d88f0/html5/thumbnails/33.jpg)
Alpha-Beta H-Minimax Returning Movefunction AlphaBeta(state, depth, alpha, beta, player) if CutoffTest(state, depth) then return (Eval(State), null) best = null /* to handle case where no move is possible */ if player == +1 then for each action in Actions(state, player) child = Result(state, action) value = AlphaBeta(child, depth+1, alpha, beta, -player) if value > alpha then alpha = value best = action if beta <= alpha then break /* beta cut-off */ return (alpha, best) else /* player == -1 */ for each action in Actions(state, player) child = Result(state, action) value = AlphaBeta(child, depth+1, alpha, beta, -player) if value < beta then beta = value best = action if beta <= alpha then break /* alpha cut-off */ return (beta, best) en
![Page 34: CSC242: Intro to AI - University of Rochester · Alpha-Beta Pruning How can we make MiniMax run faster, without sacrificing optimality?! During MINIMAX search keep track of! α:](https://reader033.vdocuments.net/reader033/viewer/2022052518/5f0ad3ba7e708231d42d88f0/html5/thumbnails/34.jpg)
Alpha-Beta H-Minimax Returning Movefunction AlphaBeta(state, depth, alpha, beta, player) if CutoffTest(state, depth) then return (Eval(State), null) best = null /* to handle case where no move is possible */ if player == +1 then for each action in Actions(state, player) child = Result(state, action) value = AlphaBeta(child, depth+1, alpha, beta, -player) if value > alpha then alpha = value best = action if beta <= alpha then break /* beta cut-off */ return (alpha, best) else /* player == -1 */ for each action in Actions(state, player) child = Result(state, action) value = AlphaBeta(child, depth+1, alpha, beta, -player) if value < beta then beta = value best = action if beta <= alpha then break /* alpha cut-off */ return (beta, best) en
![Page 35: CSC242: Intro to AI - University of Rochester · Alpha-Beta Pruning How can we make MiniMax run faster, without sacrificing optimality?! During MINIMAX search keep track of! α:](https://reader033.vdocuments.net/reader033/viewer/2022052518/5f0ad3ba7e708231d42d88f0/html5/thumbnails/35.jpg)
Alpha-Beta H-Minimax Returning Movefunction AlphaBeta(state, depth, alpha, beta, player) if CutoffTest(state, depth) then return (Eval(State), null) best = null /* to handle case where no move is possible */ if player == +1 then for each action in Actions(state, player) child = Result(state, action) value = AlphaBeta(child, depth+1, alpha, beta, -player) if value > alpha then alpha = value best = action if beta <= alpha then break /* beta cut-off */ return (alpha, best) /* best is ignored if not needed */ else /* player == -1 */ for each action in Actions(state, player) child = Result(state, action) value = AlphaBeta(child, depth+1, alpha, beta, -player) if value < beta then beta = value best = action if beta <= alpha then break /* alpha cut-off */ return (beta, best) en
![Page 36: CSC242: Intro to AI - University of Rochester · Alpha-Beta Pruning How can we make MiniMax run faster, without sacrificing optimality?! During MINIMAX search keep track of! α:](https://reader033.vdocuments.net/reader033/viewer/2022052518/5f0ad3ba7e708231d42d88f0/html5/thumbnails/36.jpg)
Alpha-Beta Pruning
Still MINIMAX search
Optimal (if you search to the terminals)
Optimal with respect to your heuristic function otherwise
![Page 37: CSC242: Intro to AI - University of Rochester · Alpha-Beta Pruning How can we make MiniMax run faster, without sacrificing optimality?! During MINIMAX search keep track of! α:](https://reader033.vdocuments.net/reader033/viewer/2022052518/5f0ad3ba7e708231d42d88f0/html5/thumbnails/37.jpg)
Alpha-Beta Pruning Analysis
![Page 38: CSC242: Intro to AI - University of Rochester · Alpha-Beta Pruning How can we make MiniMax run faster, without sacrificing optimality?! During MINIMAX search keep track of! α:](https://reader033.vdocuments.net/reader033/viewer/2022052518/5f0ad3ba7e708231d42d88f0/html5/thumbnails/38.jpg)
Alpha-Beta Pruning Analysis
Always explore the best successor first: O(bm/2)
Ideal case:
Explore twice as deep a tree in same time
Branching factor: b1/2 =p
b
![Page 39: CSC242: Intro to AI - University of Rochester · Alpha-Beta Pruning How can we make MiniMax run faster, without sacrificing optimality?! During MINIMAX search keep track of! α:](https://reader033.vdocuments.net/reader033/viewer/2022052518/5f0ad3ba7e708231d42d88f0/html5/thumbnails/39.jpg)
Alpha-Beta Pruning Analysis
Explore successors in random order:
Branching factor:
Random case:
Explore 4/3 as deep a tree in same time
b3/4
O(b3m/4)
![Page 40: CSC242: Intro to AI - University of Rochester · Alpha-Beta Pruning How can we make MiniMax run faster, without sacrificing optimality?! During MINIMAX search keep track of! α:](https://reader033.vdocuments.net/reader033/viewer/2022052518/5f0ad3ba7e708231d42d88f0/html5/thumbnails/40.jpg)
Alpha-Beta Pruning Analysis
“Smart” case: Example: in chess, expand a successor early if it is a capture
Use the static evaluation function to determine the order for expanding children
![Page 41: CSC242: Intro to AI - University of Rochester · Alpha-Beta Pruning How can we make MiniMax run faster, without sacrificing optimality?! During MINIMAX search keep track of! α:](https://reader033.vdocuments.net/reader033/viewer/2022052518/5f0ad3ba7e708231d42d88f0/html5/thumbnails/41.jpg)
Alpha-Beta Summary
Easy bookkeeping modification of basic MINIMAX algorithm
Not hard to come up with “useful” node orderings
Even random gets you 33% deeper search
Works with other ways of improving game tree search
![Page 42: CSC242: Intro to AI - University of Rochester · Alpha-Beta Pruning How can we make MiniMax run faster, without sacrificing optimality?! During MINIMAX search keep track of! α:](https://reader033.vdocuments.net/reader033/viewer/2022052518/5f0ad3ba7e708231d42d88f0/html5/thumbnails/42.jpg)
Project 1: Othello (Reversi)
Write a (champion!) Othello player
Phase I: 4-Ply Alpha-Beta Search
Phase II: Time-limited Search
Phase III: Time-budgeted Search
![Page 43: CSC242: Intro to AI - University of Rochester · Alpha-Beta Pruning How can we make MiniMax run faster, without sacrificing optimality?! During MINIMAX search keep track of! α:](https://reader033.vdocuments.net/reader033/viewer/2022052518/5f0ad3ba7e708231d42d88f0/html5/thumbnails/43.jpg)
What We Give You
Othello GUI program
Binary code for a player (to play against your program)
Pseudocode for alpha-beta heuristic game tree search
![Page 44: CSC242: Intro to AI - University of Rochester · Alpha-Beta Pruning How can we make MiniMax run faster, without sacrificing optimality?! During MINIMAX search keep track of! α:](https://reader033.vdocuments.net/reader033/viewer/2022052518/5f0ad3ba7e708231d42d88f0/html5/thumbnails/44.jpg)
What You Give Us
Othello player program
Reads moves from <stdin>, writes moves to <stdout>
Runs on Linux (at least)
Written in any language - Java, C++, Python, Ruby, Lisp, …
Write-up describing your design choices (worth 25% of project grade)
![Page 45: CSC242: Intro to AI - University of Rochester · Alpha-Beta Pruning How can we make MiniMax run faster, without sacrificing optimality?! During MINIMAX search keep track of! α:](https://reader033.vdocuments.net/reader033/viewer/2022052518/5f0ad3ba7e708231d42d88f0/html5/thumbnails/45.jpg)
Input / Output Language
Input: Moves by opponent
1 8 # upper left hand corner
Output: Moves by player
8 1 # lower right hand corner
Our program determines if a player wins or makes and illegal moves (immediate loss)
![Page 46: CSC242: Intro to AI - University of Rochester · Alpha-Beta Pruning How can we make MiniMax run faster, without sacrificing optimality?! During MINIMAX search keep track of! α:](https://reader033.vdocuments.net/reader033/viewer/2022052518/5f0ad3ba7e708231d42d88f0/html5/thumbnails/46.jpg)
Project Subtasks
Choose data structures and programming language
Turn alpha-beta pseudocode into real code
Design, implement, and test
Move generator (Actions(state,player))
Transition function (Apply(state,action))
Static evaluator (Eval(state))
Cut-off test (CutoffTest(state,depth))
![Page 47: CSC242: Intro to AI - University of Rochester · Alpha-Beta Pruning How can we make MiniMax run faster, without sacrificing optimality?! During MINIMAX search keep track of! α:](https://reader033.vdocuments.net/reader033/viewer/2022052518/5f0ad3ba7e708231d42d88f0/html5/thumbnails/47.jpg)
Phases
Phase I tests correct implementation of move generator and your static evaluation function
Phases II and III will require a more sophisticated cut-off function
Use your time per move or time budget for game wisely
Real-time decision making!
![Page 48: CSC242: Intro to AI - University of Rochester · Alpha-Beta Pruning How can we make MiniMax run faster, without sacrificing optimality?! During MINIMAX search keep track of! α:](https://reader033.vdocuments.net/reader033/viewer/2022052518/5f0ad3ba7e708231d42d88f0/html5/thumbnails/48.jpg)
Teams
Posted by 7pm tonight on course web page:
2 person teams (randomly assigned by me)
Specification of the <stdio> input/output language
GUI is currently in beta-test - email Dan Scarafoni <[email protected]> to join the beta test and/or report bugs
Final release no later than Sunday
![Page 49: CSC242: Intro to AI - University of Rochester · Alpha-Beta Pruning How can we make MiniMax run faster, without sacrificing optimality?! During MINIMAX search keep track of! α:](https://reader033.vdocuments.net/reader033/viewer/2022052518/5f0ad3ba7e708231d42d88f0/html5/thumbnails/49.jpg)
GUI Demo (?)
![Page 50: CSC242: Intro to AI - University of Rochester · Alpha-Beta Pruning How can we make MiniMax run faster, without sacrificing optimality?! During MINIMAX search keep track of! α:](https://reader033.vdocuments.net/reader033/viewer/2022052518/5f0ad3ba7e708231d42d88f0/html5/thumbnails/50.jpg)
Beyond Deterministic Games of Perfect Information
![Page 51: CSC242: Intro to AI - University of Rochester · Alpha-Beta Pruning How can we make MiniMax run faster, without sacrificing optimality?! During MINIMAX search keep track of! α:](https://reader033.vdocuments.net/reader033/viewer/2022052518/5f0ad3ba7e708231d42d88f0/html5/thumbnails/51.jpg)
Types of GamesDeterministic (no chance)
Nondeterministic(dice, cards, etc.)
Perfect information (fully observable)
Imperfect information (partially observable)
Zero-sum (total payoff the same in any game) Arbitrary utility functions
![Page 52: CSC242: Intro to AI - University of Rochester · Alpha-Beta Pruning How can we make MiniMax run faster, without sacrificing optimality?! During MINIMAX search keep track of! α:](https://reader033.vdocuments.net/reader033/viewer/2022052518/5f0ad3ba7e708231d42d88f0/html5/thumbnails/52.jpg)
Stochastic Games
• A player’s possible moves depend on chance (random) elements, e.g., dice
• Must generalize our notion of a game tree to include “chance” nodes
1 2 3 4 5 6 7 8 9 10 11 12
24 23 22 21 20 19 18 17 16 15 14 13
0
25
![Page 53: CSC242: Intro to AI - University of Rochester · Alpha-Beta Pruning How can we make MiniMax run faster, without sacrificing optimality?! During MINIMAX search keep track of! α:](https://reader033.vdocuments.net/reader033/viewer/2022052518/5f0ad3ba7e708231d42d88f0/html5/thumbnails/53.jpg)
CHANCE
MIN
MAX
CHANCE
MAX
. . .
. . .
B
1
. . .1,11/36
1,21/18
TERMINAL
1,21/18
......
.........
......
1,11/36
...
...... ......
...C
. . .
1/186,5 6,6
1/36
1/186,5 6,6
1/36
2 –11–1
![Page 54: CSC242: Intro to AI - University of Rochester · Alpha-Beta Pruning How can we make MiniMax run faster, without sacrificing optimality?! During MINIMAX search keep track of! α:](https://reader033.vdocuments.net/reader033/viewer/2022052518/5f0ad3ba7e708231d42d88f0/html5/thumbnails/54.jpg)
H T
+1 -1
P(H)=0.5 P(T)=0.5
?
![Page 55: CSC242: Intro to AI - University of Rochester · Alpha-Beta Pruning How can we make MiniMax run faster, without sacrificing optimality?! During MINIMAX search keep track of! α:](https://reader033.vdocuments.net/reader033/viewer/2022052518/5f0ad3ba7e708231d42d88f0/html5/thumbnails/55.jpg)
H T
+1 -1
P(H)=0.5 P(T)=0.5
?
![Page 56: CSC242: Intro to AI - University of Rochester · Alpha-Beta Pruning How can we make MiniMax run faster, without sacrificing optimality?! During MINIMAX search keep track of! α:](https://reader033.vdocuments.net/reader033/viewer/2022052518/5f0ad3ba7e708231d42d88f0/html5/thumbnails/56.jpg)
H T
+1 -1
P(H)=0.5 P(T)=0.5
0
![Page 57: CSC242: Intro to AI - University of Rochester · Alpha-Beta Pruning How can we make MiniMax run faster, without sacrificing optimality?! During MINIMAX search keep track of! α:](https://reader033.vdocuments.net/reader033/viewer/2022052518/5f0ad3ba7e708231d42d88f0/html5/thumbnails/57.jpg)
H T
+1 -1
P(H)=0.75 P(T)=0.25
?
![Page 58: CSC242: Intro to AI - University of Rochester · Alpha-Beta Pruning How can we make MiniMax run faster, without sacrificing optimality?! During MINIMAX search keep track of! α:](https://reader033.vdocuments.net/reader033/viewer/2022052518/5f0ad3ba7e708231d42d88f0/html5/thumbnails/58.jpg)
H T
+1 -1
P(H)=0.75 P(T)=0.25
+0.5
![Page 59: CSC242: Intro to AI - University of Rochester · Alpha-Beta Pruning How can we make MiniMax run faster, without sacrificing optimality?! During MINIMAX search keep track of! α:](https://reader033.vdocuments.net/reader033/viewer/2022052518/5f0ad3ba7e708231d42d88f0/html5/thumbnails/59.jpg)
Expectation
• Weighted average of possibilities
!
• Sum of the possible outcomes weighted by the likelihood of their occurrence
!
• What you would expect to win in the long run
![Page 60: CSC242: Intro to AI - University of Rochester · Alpha-Beta Pruning How can we make MiniMax run faster, without sacrificing optimality?! During MINIMAX search keep track of! α:](https://reader033.vdocuments.net/reader033/viewer/2022052518/5f0ad3ba7e708231d42d88f0/html5/thumbnails/60.jpg)
Expecti-Minimax
• Same as MINIMAX for MIN and MAX nodes
• Same backing up utilities from terminal nodes
• Take expectation over chance nodes
• Weighted average of possible outcomes
![Page 61: CSC242: Intro to AI - University of Rochester · Alpha-Beta Pruning How can we make MiniMax run faster, without sacrificing optimality?! During MINIMAX search keep track of! α:](https://reader033.vdocuments.net/reader033/viewer/2022052518/5f0ad3ba7e708231d42d88f0/html5/thumbnails/61.jpg)
CHANCE
MIN
MAX
CHANCE
MAX
. . .
. . .
B
1
. . .1,11/36
1,21/18
TERMINAL
1,21/18
......
.........
......
1,11/36
...
...... ......
...C
. . .
1/186,5 6,6
1/36
1/186,5 6,6
1/36
2 –11–1
![Page 62: CSC242: Intro to AI - University of Rochester · Alpha-Beta Pruning How can we make MiniMax run faster, without sacrificing optimality?! During MINIMAX search keep track of! α:](https://reader033.vdocuments.net/reader033/viewer/2022052518/5f0ad3ba7e708231d42d88f0/html5/thumbnails/62.jpg)
Expecti-Minimax
8>>><
>>>:
Utility(s) if Terminal-Test(s)
maxa EMinimax(Result(S, a)) if Player(s) = max
mina EMinimax(Result(S, a)) if Player(s) = min
Pr P (r)EMinimax(Result(S, r)) if Player(s) = chance
EMinimax(s) =
![Page 63: CSC242: Intro to AI - University of Rochester · Alpha-Beta Pruning How can we make MiniMax run faster, without sacrificing optimality?! During MINIMAX search keep track of! α:](https://reader033.vdocuments.net/reader033/viewer/2022052518/5f0ad3ba7e708231d42d88f0/html5/thumbnails/63.jpg)
Partial Observability
• Some of the state of the world is hidden (unobservable)
• There is some uncertainty about the state of the world
![Page 64: CSC242: Intro to AI - University of Rochester · Alpha-Beta Pruning How can we make MiniMax run faster, without sacrificing optimality?! During MINIMAX search keep track of! α:](https://reader033.vdocuments.net/reader033/viewer/2022052518/5f0ad3ba7e708231d42d88f0/html5/thumbnails/64.jpg)
Partially-Observable Games
• Some of the state of the game is hidden from the player(s)
• Interesting because:
• Valuable real-world games (e.g., poker)
• Partial observability arises all the time in real-world problems
![Page 65: CSC242: Intro to AI - University of Rochester · Alpha-Beta Pruning How can we make MiniMax run faster, without sacrificing optimality?! During MINIMAX search keep track of! α:](https://reader033.vdocuments.net/reader033/viewer/2022052518/5f0ad3ba7e708231d42d88f0/html5/thumbnails/65.jpg)
Partially-Observable Games
• Deterministic partial observability
• Opponent has hidden state
• Battleship, Stratego, Kriegspiel
![Page 66: CSC242: Intro to AI - University of Rochester · Alpha-Beta Pruning How can we make MiniMax run faster, without sacrificing optimality?! During MINIMAX search keep track of! α:](https://reader033.vdocuments.net/reader033/viewer/2022052518/5f0ad3ba7e708231d42d88f0/html5/thumbnails/66.jpg)
Partially-Observable Games
• Deterministic partial observability
• Opponent has hidden state
• Battleship, Stratego, Kriegspiel
• Stochastic partial observability
• Missing/hidden information is random
• Card games: bridge, hearts, poker (most)
![Page 67: CSC242: Intro to AI - University of Rochester · Alpha-Beta Pruning How can we make MiniMax run faster, without sacrificing optimality?! During MINIMAX search keep track of! α:](https://reader033.vdocuments.net/reader033/viewer/2022052518/5f0ad3ba7e708231d42d88f0/html5/thumbnails/67.jpg)
Stochastic Partially Observable Games
![Page 68: CSC242: Intro to AI - University of Rochester · Alpha-Beta Pruning How can we make MiniMax run faster, without sacrificing optimality?! During MINIMAX search keep track of! α:](https://reader033.vdocuments.net/reader033/viewer/2022052518/5f0ad3ba7e708231d42d88f0/html5/thumbnails/68.jpg)
![Page 69: CSC242: Intro to AI - University of Rochester · Alpha-Beta Pruning How can we make MiniMax run faster, without sacrificing optimality?! During MINIMAX search keep track of! α:](https://reader033.vdocuments.net/reader033/viewer/2022052518/5f0ad3ba7e708231d42d88f0/html5/thumbnails/69.jpg)
Weighted Minimax
• For each possible deal s:
• Assume s is the actual situation
• Compute Minimax or H-Minimax value of s
• Weight value by probability of s
• Take move that yields highest expected value over all the possible deals
![Page 70: CSC242: Intro to AI - University of Rochester · Alpha-Beta Pruning How can we make MiniMax run faster, without sacrificing optimality?! During MINIMAX search keep track of! α:](https://reader033.vdocuments.net/reader033/viewer/2022052518/5f0ad3ba7e708231d42d88f0/html5/thumbnails/70.jpg)
Weighted Minimax
argmax
a
X
s
P (s)Minimax(Result(s, a))
![Page 71: CSC242: Intro to AI - University of Rochester · Alpha-Beta Pruning How can we make MiniMax run faster, without sacrificing optimality?! During MINIMAX search keep track of! α:](https://reader033.vdocuments.net/reader033/viewer/2022052518/5f0ad3ba7e708231d42d88f0/html5/thumbnails/71.jpg)
Weighted Minimax
argmax
a
X
s
P (s)Minimax(Result(s, a))
✓4725
◆= 1.48338977⇥ 1013
✓2613
◆= 10, 400, 600
![Page 72: CSC242: Intro to AI - University of Rochester · Alpha-Beta Pruning How can we make MiniMax run faster, without sacrificing optimality?! During MINIMAX search keep track of! α:](https://reader033.vdocuments.net/reader033/viewer/2022052518/5f0ad3ba7e708231d42d88f0/html5/thumbnails/72.jpg)
Monte Carlo Methods
• Use a “representative” sample to approximate a large, complex distribution
![Page 73: CSC242: Intro to AI - University of Rochester · Alpha-Beta Pruning How can we make MiniMax run faster, without sacrificing optimality?! During MINIMAX search keep track of! α:](https://reader033.vdocuments.net/reader033/viewer/2022052518/5f0ad3ba7e708231d42d88f0/html5/thumbnails/73.jpg)
Monte Carlo Minimax
argmax
a
1
N
NX
i=1
Minimax(Result(si, a))
![Page 74: CSC242: Intro to AI - University of Rochester · Alpha-Beta Pruning How can we make MiniMax run faster, without sacrificing optimality?! During MINIMAX search keep track of! α:](https://reader033.vdocuments.net/reader033/viewer/2022052518/5f0ad3ba7e708231d42d88f0/html5/thumbnails/74.jpg)
![Page 75: CSC242: Intro to AI - University of Rochester · Alpha-Beta Pruning How can we make MiniMax run faster, without sacrificing optimality?! During MINIMAX search keep track of! α:](https://reader033.vdocuments.net/reader033/viewer/2022052518/5f0ad3ba7e708231d42d88f0/html5/thumbnails/75.jpg)
Summary
• Non-deterministic games
• Expecti-MINIMAX: Compute expected MINIMAX value over chance nodes
• Partially observable games
• Weighted MINIMAX: Compute expected value over possible hidden states
• When tree becomes too large, sample branches rather than explore exhaustively
![Page 76: CSC242: Intro to AI - University of Rochester · Alpha-Beta Pruning How can we make MiniMax run faster, without sacrificing optimality?! During MINIMAX search keep track of! α:](https://reader033.vdocuments.net/reader033/viewer/2022052518/5f0ad3ba7e708231d42d88f0/html5/thumbnails/76.jpg)
For Next Time: AIMA 6.0-6.4