Presentation is loading. Please wait.

Presentation is loading. Please wait.

EA C461 – Artificial Intelligence Adversarial Search

Similar presentations


Presentation on theme: "EA C461 – Artificial Intelligence Adversarial Search"— Presentation transcript:

1 EA C461 – Artificial Intelligence Adversarial Search
S.P.Vimal

2 To discuss… Game Playing Optimal Decisions in Games Alpha-Beta Pruning
Minimax Algorithm Multiplayer Games Alpha-Beta Pruning Vimal EA C461- Artificial Intelligence

3 Game playing One of the very first tasks AI undertook
Chess, with average branching factor 35, with each player taking 50 steps, the number of nodes generated is Make decisions, apparently no optimal choice Inefficiencies penalized severely "Unpredictable" opponent  specifying a move for every possible opponent reply Time limits  unlikely to find goal, must approximate Vimal EA C461- Artificial Intelligence

4 Problems Two players Components of the problem MAX, MIN Initial State
Successor function Terminal Test Test of states where the game ends Utility function +1, 0, -1 Vimal EA C461- Artificial Intelligence

5 Game tree (2-player, deterministic, turns)
Vimal EA C461- Artificial Intelligence

6 Game strategy An optimal strategy leads to an outcome which is at least as good as playing against an infallible opponent One move Vimal EA C461- Artificial Intelligence

7 Minimax Value Minimax-Value (n) =
Utility(n) , if n is a terminal node MaxsεSuccessors(n) Minimax-Value(s) , if n is a Max Node MinsεSuccessors(n) Minimax-Value(s) , if n is a Min Node Optimal play for MAX assumes, MIN also plays optimally. Vimal EA C461- Artificial Intelligence

8 Minimax algorithm Vimal EA C461- Artificial Intelligence

9 Properties of minimax Complete? Yes (if tree is finite)
Optimal? Yes (against an optimal opponent) Time complexity? O(bm) Space complexity? O(bm) (depth-first exploration) For chess, b ≈ 35, m ≈100 for "reasonable" games  exact solution completely infeasible Vimal EA C461- Artificial Intelligence

10 Vimal EA C461- Artificial Intelligence

11 α-β Pruning Prune away those nodes which cannot possibly influence the final outcome Vimal EA C461- Artificial Intelligence

12 α-β pruning example Vimal EA C461- Artificial Intelligence

13 α-β pruning example Vimal EA C461- Artificial Intelligence

14 α-β pruning example Vimal EA C461- Artificial Intelligence

15 α-β pruning example Vimal EA C461- Artificial Intelligence

16 α-β pruning example What if successors are examined in a different order… Vimal EA C461- Artificial Intelligence

17 α-β Pruning Minimax (root) = max( min(3,12,8), min(2,x,y), min(14,5,2) ) = max( 3, min(2,x,y), 2 ) = max( 3, z, 2 ) , z ≤ 2 = 3 Vimal EA C461- Artificial Intelligence

18 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 A simple example of the value of reasoning about which computations are relevant (a form of metareasoning) Vimal EA C461- Artificial Intelligence

19 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 Vimal EA C461- Artificial Intelligence

20 Implementation The game tree is traversed in depth-first order.
Each non-leaf node will have a beta value and an alpha value stored. For each max node, the minimum beta value for all its min node ancestors is stored as beta. For each min node, the maximum alpha value for all its max node ancestors is stored as alpha. Initially, the root node is assigned an alpha value of negative infinity and a beta value of infinity. Vimal EA C461- Artificial Intelligence

21 Implementation The variable children is used to represent all of the children of the current node The following call means Vimal EA C461- Artificial Intelligence

22 A better beta is already found…
Vimal EA C461- Artificial Intelligence

23 A better alpha is already found…
Vimal EA C461- Artificial Intelligence

24 Trace alpha-beta Vimal EA C461- Artificial Intelligence

25 Resource limits Replace utility function with heuristic function
Gives an estimate of utility Replace terminal test by cur-off test Vimal EA C461- Artificial Intelligence

26 Evaluation functions Evaluation function should
Order the terminal state by it’s true utility Not take long time Correlate strongly with the actual chances of winning, for every non terminal states Works by calculating features of the state No of pawns possessed by each players, etc Groups features to make classes/categories of the state. Mostly evaluation function identifies the category in which the current state falls, and give an ordering of its successor with it’s expected utility. Vimal EA C461- Artificial Intelligence

27 Eval(s) = w1 f1(s) + w2 f2(s) + … + wn fn(s)
Evaluation functions Categorizing may be difficult Material value of each piece can be taken into account Pawn 1 Knight/bishop 3 Rook 5 Queen 9 Specific features like Good pawn structure King safty For chess, typically linear weighted sum of features Eval(s) = w1 f1(s) + w2 f2(s) + … + wn fn(s) Vimal EA C461- Artificial Intelligence

28 Evaluation functions Weighted linear combination of features may be poor considering the fact Bishops are more powerful in the endgame Pair of bishops slightly more worthies than a single bishop Importantly, the features are not the part of the rules of the game  They come out of experience Experience suggests that, secured material advantage has more chance of winning, when all other things being equal… A 3 point advantage near the end of the game is sufficient to ensure victory Bishop is indeed worth 3 pawns Vimal EA C461- Artificial Intelligence

29 Cutting off search Replace terminal test with the cutoff function
If CUTOFF-TEST (state, depth) then return EVAL (state) Apply evaluation functions only to quiescent positions, positions unlikely to exhibit a wild swing Generate around million nodes/second in latest PC Given 3 mins to make a move approximately 200 million nodes can be generated With b=35, this implies 5 levels of look ahead (minimax) With alpha-beta we get around 10 ply look ahead Vimal EA C461- Artificial Intelligence

30 Cutting off search Minimax
Selects optimal move, given the leave evaluations are exactly correct. Evaluations at leave are mostly estimations Evaluation functions can be probability distribution over a set of possible values MAX MIN 99 100 MAX 99 1000 1000 1000 100 101 102 100 Vimal EA C461- Artificial Intelligence

31 Chess in Gaming Literature
1957 – Herbert Simon – 10 years computer will beat human world champion 1997 – Deep Blue – defeated – Gary Kasparov – Six-Game Exhibition Match Deep Blue Running as parallel computer, 30 IBM RS/6000 running software search, 480 custom VLSI chess processors generates moves and orders them Hardware search for last few levels of the tree … 126 million nodes/second average with the peak speed of 300 million nodes/sec Vimal EA C461- Artificial Intelligence

32 Chess in Gaming Literature
Used standard iterative deepening alpha-beta search with transposition tables Max depth approx 40 plies Evaluation function with 8000 features About 4000 opening positions, consensus recommendations from the database of 700,000 grandmaster games Large solved end game database (all positions with 5 pieces, as many as 6 pieces) 2002 – FRITZ (on ordinary PC) – Vladimir Kramnik – drawn Vimal EA C461- Artificial Intelligence

33 Summary Games are fun to work on!
They illustrate several important points about AI perfection is unattainable  must approximate good idea to think about what to think about Vimal EA C461- Artificial Intelligence


Download ppt "EA C461 – Artificial Intelligence Adversarial Search"

Similar presentations


Ads by Google