Download presentation
Presentation is loading. Please wait.
1
Game Playing Fifth Lecture 2019/4/11
2
Contents: Minimax algorithm Resource limits - pruning
Games of chance Example: Tic Tac Toe 2019/4/11
3
Types of games 2019/4/11 EIE426-AICV
4
Game tree (2-player, deterministic, turns)
2019/4/11
5
Game Trees You learn about how programs can play games, such as checkers and chess. p = d = 2 The ply of a game tree, p = d, where d is the depth of a tree. 2019/4/11
6
Game Trees (cont.) A game tree is a representation
That is a semantic tree In which Nodes denote board configurations Branches denote moves With writers that Establish that a node is for the maximizer or for the minimizer Connect a board configuration with a board-configuration description With readers that Determine whether the node is for the maximizer of minimizer Produce a board configuration’s description Exhaustive Search Is Impossible! 2019/4/11
7
Minimax Perfect play for deterministic, perfect-information games
Idea: choose move to position with highest minimax value = best achievable payoff against best play Evaluations 2019/4/11
8
Minimax algorithm 2019/4/11
9
Properties of minimax Complete? Yes, if tree is finite (chess has specific rules for this) Optimal? Yes, against an optimal opponent. Otherwise?? Time? complexity O(b^m) Space? complexity O(bm) (depth-first exploration) For chess, b 35, m 100 for “reasonable” games => exact solution completely infeasible 2019/4/11
10
Resource limits Suppose we have 100 seconds, explore 10^4 nodes/second
=>10^6 nodes per move Standard approach: cutoff test, e.g., depth limit evaluation function = estimated desirability of position 2019/4/11
11
Evaluation functions For chess, typically linear weighted sum features
Eval(s) = w1 f1(s) + w2 f2(s) + … + wn fn(s) e.g., w1 = 9 with f1(s) = (number of white queens) - (number of black queens), etc. 2019/4/11
12
Exact values don't matter for deterministic games
Behaviour is preserved under any monotonic transformation of Eval Only the order matters: payoff in deterministic games acts as an ordinal utility function. 2019/4/11
13
Cutting off search MinimaxCutoff is identical to MinimaxValue except
1. Terminal? is replaced by Cutoff? 2. Utility is replaced by Eval Does it work in practice? b^m = 10^6, b=35 => m=4 4-ply lookahead is a hopeless chess player! 4-ply human novice 8-ply typical PC, human master 12-ply Deep Blue, Kasparov 2019/4/11
14
- pruning example The Principle:
If you have an idea that is surely bad, do not take time to see how truly awful it is. 2019/4/11
15
Another example The step number of the process Max Min Max 2019/4/11
16
Properties of - Pruning does not affect final result
Good move ordering improves effectiveness of pruning With “perfect ordering,” time complexity = O(bm/2) => doubles depth of search => can easily reach depth 8 and play good chess A simple example of the value of reasoning about which computations are relevant (a form of meta reasoning) 2019/4/11
17
Why is it called - ? is the best value (to max) found so far off the current path If V is worse than , max will avoid it => prune that branch Define similarly for min 2019/4/11
18
An Example of Game Tree 2019/4/11
19
Example: Tic Tac Toe 2019/4/11
20
Example: The Minimax Procedure Applied to Playing Tic-Tac-Toe
2019/4/11
21
Two-ply minimax applied to the opening move of tic-tac- toe
Min’s move 2019/4/11
22
Two-ply minimax applied to X’s second move of tic-tac- toe
2019/4/11
23
Two-ply minimax applied to X’s move near end game
2019/4/11
24
Summary Games are fun to work on! (and dangerous)
They illustrate several important points about AI perfection is unattainable => must approximate good idea to think about what to think about uncertainty constrains the assignment of values to states Games are to AI as grand prix racing is to automobile design 2019/4/11
25
End of Lecture 5 2019/4/11 EIE426-AICV
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.