Artificial Intelligence 1: game playing Lecturer: Tom Lenaerts SWITCH, Vlaams Interuniversitair Instituut voor Biotechnologie.

Slides:



Advertisements
Similar presentations
Chapter 6, Sec Adversarial Search.
Advertisements

Adversarial Search Chapter 6 Sections 1 – 4. Outline Optimal decisions α-β pruning Imperfect, real-time decisions.
Copyright © 2003 Pearson Education, Inc. Slide 1 Computer Systems Organization & Architecture Chapters 8-12 John D. Carpinelli.
Properties Use, share, or modify this drill on mathematic properties. There is too much material for a single class, so you’ll have to select for your.
PP Test Review Sections 6-1 to 6-6
Adversarial Search Chapter 6 Section 1 – 4. Types of Games.
Essential Cell Biology
PSSA Preparation.
Alpha-Beta Search. 2 Two-player games The object of a search is to find a path from the starting position to a goal position In a puzzle-type problem,
Adversarial Search We have experience in search where we assume that we are the only intelligent being and we have explicit control over the “world”. Lets.
Games & Adversarial Search Chapter 5. Games vs. search problems "Unpredictable" opponent  specifying a move for every possible opponent’s reply. Time.
February 7, 2006AI: Chapter 6: Adversarial Search1 Artificial Intelligence Chapter 6: Adversarial Search Michael Scherger Department of Computer Science.
Artificial Intelligence Adversarial search Fall 2008 professor: Luigi Ceccaroni.
CS 484 – Artificial Intelligence
Adversarial Search Chapter 6 Section 1 – 4.
Adversarial Search Chapter 5.
Lecture 12 Last time: CSPs, backtracking, forward checking Today: Game Playing.
Adversarial Search CSE 473 University of Washington.
Hoe schaakt een computer? Arnold Meijster. Why study games? Fun Historically major subject in AI Interesting subject of study because they are hard Games.
Adversarial Search Chapter 6.
Adversarial Search 對抗搜尋. Outline  Optimal decisions  α-β pruning  Imperfect, real-time decisions.
1 Adversarial Search Chapter 6 Section 1 – 4 The Master vs Machine: A Video.
10/19/2004TCSS435A Isabelle Bichindaritz1 Game and Tree Searching.
Games CPSC 386 Artificial Intelligence Ellen Walker Hiram College.
EIE426-AICV 1 Game Playing Filename: eie426-game-playing-0809.ppt.
G51IAI Introduction to AI Minmax and Alpha Beta Pruning Garry Kasparov and Deep Blue. © 1997, GM Gabriel Schwartzman's Chess Camera, courtesy IBM.
This time: Outline Game playing The minimax algorithm
Game Playing CSC361 AI CSC361: Game Playing.
UNIVERSITY OF SOUTH CAROLINA Department of Computer Science and Engineering CSCE 580 Artificial Intelligence Ch.6: Adversarial Search Fall 2008 Marco Valtorta.
1 search CS 331/531 Dr M M Awais A* Examples:. 2 search CS 331/531 Dr M M Awais 8-Puzzle f(N) = g(N) + h(N)
Adversarial Search: Game Playing Reading: Chess paper.
Games & Adversarial Search Chapter 6 Section 1 – 4.
Notes adapted from lecture notes for CMSC 421 by B.J. Dorr
Adversarial Search Chapter 5 Adapted from Tom Lenaerts’ lecture notes.
Game Playing Chapter 5. Game playing §Search applied to a problem against an adversary l some actions are not under the control of the problem-solver.
Lecture 6: Game Playing Heshaam Faili University of Tehran Two-player games Minmax search algorithm Alpha-Beta pruning Games with chance.
Game Playing Chapter 5. Game playing §Search applied to a problem against an adversary l some actions are not under the control of the problem-solver.
Game-playing AIs Part 1 CIS 391 Fall CSE Intro to AI 2 Games: Outline of Unit Part I (this set of slides)  Motivation  Game Trees  Evaluation.
Adversarial Search Chapter 6 Section 1 – 4. Outline Optimal decisions α-β pruning Imperfect, real-time decisions.
Adversarial Search Chapter Games vs. search problems "Unpredictable" opponent  specifying a move for every possible opponent reply Time limits.
Game tree search Chapter 6 (6.1 to 6.3 and 6.6) cover games. 6.6 covers state of the art game players in particular. 6.5 covers games that involve uncertainty.
ARTIFICIAL INTELLIGENCE (CS 461D) Princess Nora University Faculty of Computer & Information Systems.
CMSC 421: Intro to Artificial Intelligence October 6, 2003 Lecture 7: Games Professor: Bonnie J. Dorr TA: Nate Waisbrot.
Adversarial Search 2 (Game Playing)
Explorations in Artificial Intelligence Prof. Carla P. Gomes Module 5 Adversarial Search (Thanks Meinolf Sellman!)
Adversarial Search Chapter 5 Sections 1 – 4. AI & Expert Systems© Dr. Khalid Kaabneh, AAU Outline Optimal decisions α-β pruning Imperfect, real-time decisions.
ADVERSARIAL SEARCH Chapter 6 Section 1 – 4. OUTLINE Optimal decisions α-β pruning Imperfect, real-time decisions.
Adversarial Search CMPT 463. When: Tuesday, April 5 3:30PM Where: RLC 105 Team based: one, two or three people per team Languages: Python, C++ and Java.
Chapter 5 Adversarial Search. 5.1 Games Why Study Game Playing? Games allow us to experiment with easier versions of real-world situations Hostile agents.
Artificial Intelligence AIMA §5: Adversarial Search
Adversarial Search and Game-Playing
EA C461 – Artificial Intelligence Adversarial Search
Last time: search strategies
PENGANTAR INTELIJENSIA BUATAN (64A614)
Adversarial Search Chapter 5.
Games & Adversarial Search
Games & Adversarial Search
Adversarial Search.
Artificial Intelligence
Game playing.
Games & Adversarial Search
Games & Adversarial Search
Artificial Intelligence
Game Playing Fifth Lecture 2019/4/11.
Games & Adversarial Search
Adversarial Search CMPT 420 / CMPG 720.
Games & Adversarial Search
Adversarial Search Chapter 6 Section 1 – 4.
Minimax Trees: Utility Evaluation, Tree Evaluation, Pruning
Presentation transcript:

Artificial Intelligence 1: game playing Lecturer: Tom Lenaerts SWITCH, Vlaams Interuniversitair Instituut voor Biotechnologie

Pag. 2 Outline What are games? Optimal decisions in games –Which strategy leads to success? - pruning Games of imperfect information Games that include an element of chance

Pag. 3 What are and why study games? Games are a form of multi-agent environment –What do other agents do and how do they affect our success –Competitive multi-agent environments give rise to adversarial search a.k.a. games Why study games? –Fun; historically entertaining –Interesting subject of study because they are hard –Easy to represent and agents restricted to small number of actions

Pag. 4 Relation of Games to Search Search – no adversary –Solution is (heuristic) method for finding goal –Heuristics and CSP techniques can find optimal solution –Evaluation function: estimate of cost from start to goal through given node –Examples: path planning, scheduling activities Games – adversary –Solution is strategy (strategy specifies move for every possible opponent reply). –Time limits force an approximate solution –Evaluation function: evaluate goodness of game position –Examples: chess, checkers, Othello, backgammon

Pag. 5 Types of Games

Pag. 6 Game setup Two players: MAX and MIN MAX moves first and they take turns until the game is over. Winner gets award, looser gets penalty. Games as search: –Initial state: e.g. board configuration of chess –Successor function: list of (move,state) pairs specifying legal moves. –Terminal test: Is the game finished? –Utility function: Gives numerical value of terminal states. E.g. win (+1), loose (-1) and draw (0) in tic-tac-toe (next) MAX uses search tree to determine next move.

Pag. 7 Partial Game Tree for Tic-Tac-Toe

Pag. 8 Optimal strategies Find the contingent strategy for MAX assuming an infallible MIN opponent. Assumption: Both players play optimally !! Given a game tree, the optimal strategy can be determined by using the minimax value of each node: MINIMAX-VALUE(n)= UTILITY(n)If n is a terminal max s successors(n) MINIMAX-VALUE(s) If n is a max node min s successors(n) MINIMAX-VALUE(s) If n is a min node

Pag. 9 Two-Ply Game Tree

Pag. 10 Two-Ply Game Tree

Pag. 11 Two-Ply Game Tree

Pag. 12 Two-Ply Game Tree The minimax decision Minimax maximizes the worst-case outcome for max.

Pag. 13 What if MIN does not play optimally? Definition of optimal play for MAX assumes MIN plays optimally: maximizes worst-case outcome for MAX. But if MIN does not play optimally, MAX will do even better. [proven.]

Pag. 14 Minimax Algorithm function MINIMAX-DECISION(state) returns an action inputs: state, current state in game v MAX-VALUE(state) return the action in SUCCESSORS(state) with value v function MIN-VALUE(state) returns a utility value if TERMINAL-TEST(state) then return UTILITY(state) v for a,s in SUCCESSORS(state) do v MIN(v,MAX-VALUE(s)) return v function MAX-VALUE(state) returns a utility value if TERMINAL-TEST(state) then return UTILITY(state) v for a,s in SUCCESSORS(state) do v MAX(v,MIN-VALUE(s)) return v

Pag. 15 Properties of Minimax CriterionMinimax TimeO(b^m) SpaceO(bm)

Pag. 16 Multiplayer games Games allow more than two players Single minimax values become vectors

Pag. 17 Problem of minimax search Number of games states is exponential to the number of moves. –Solution: Do not examine every node –==> Alpha-beta pruning –Remove branches that do not influence final decision Revisit example …

Pag. 18 Alpha-Beta Example [-, +] Range of possible values Do DF-search until first leaf

Pag. 19 Alpha-Beta Example (continued) [-,3] [-,+]

Pag. 20 Alpha-Beta Example (continued) [-,3] [-,+]

Pag. 21 Alpha-Beta Example (continued) [3,+] [3,3]

Pag. 22 Alpha-Beta Example (continued) [-,2] [3,+] [3,3] This node is worse for MAX

Pag. 23 Alpha-Beta Example (continued) [-,2] [3,14] [3,3][-,14],

Pag. 24 Alpha-Beta Example (continued) [,2] [3,5] [3,3][-,5],

Pag. 25 Alpha-Beta Example (continued) [2,2] [,2] [3,3]

Pag. 26 Alpha-Beta Example (continued) [2,2] [-,2] [3,3]

Pag. 27 Alpha-Beta Algorithm function ALPHA-BETA-SEARCH(state) returns an action inputs: state, current state in game v MAX-VALUE(state, -, + ) return the action in SUCCESSORS(state) with value v function MAX-VALUE(state,, ) returns a utility value if TERMINAL-TEST(state) then return UTILITY(state) v - for a,s in SUCCESSORS(state) do v MAX(v,MIN-VALUE(s,, )) if v then return v MAX(,v) return v

Pag. 28 Alpha-Beta Algorithm function MIN-VALUE(state,, ) returns a utility value if TERMINAL-TEST(state) then return UTILITY(state) v + for a,s in SUCCESSORS(state) do v MIN(v,MAX-VALUE(s,, )) if v then return v MIN(,v) return v

Pag. 29 General alpha-beta pruning Consider a node n somewhere in the tree If player has a better choice at –Parent node of n –Or any choice point further up n will never be reached in actual play. Hence when enough is known about n, it can be pruned.

Pag. 30 Final Comments about Alpha-Beta Pruning Pruning does not affect final results Entire subtrees can be pruned. Good move ordering improves effectiveness of pruning With perfect ordering, time complexity is O(b m/2 ) –Branching factor of sqrt(b) !! –Alpha-beta pruning can look twice as far as minimax in the same amount of time Repeated states are again possible. –Store them in memory = transposition table

Pag. 31 Games of imperfect information Minimax and alpha-beta pruning require too much leaf-node evaluations. May be impractical within a reasonable amount of time. SHANNON (1950): –Cut off search earlier (replace TERMINAL-TEST by CUTOFF- TEST) –Apply heuristic evaluation function EVAL (replacing utility function of alpha-beta)

Pag. 32 Cutting off search Change: –if TERMINAL-TEST(state) then return UTILITY(state) into –if CUTOFF-TEST(state,depth) then return EVAL(state) Introduces a fixed-depth limit depth –Is selected so that the amount of time will not exceed what the rules of the game allow. When cuttoff occurs, the evaluation is performed.

Pag. 33 Heuristic EVAL Idea: produce an estimate of the expected utility of the game from a given position. Performance depends on quality of EVAL. Requirements: –EVAL should order terminal-nodes in the same way as UTILITY. –Computation may not take too long. –For non-terminal states the EVAL should be strongly correlated with the actual chance of winning. Only useful for quiescent (no wild swings in value in near future) states

Pag. 34 Heuristic EVAL example Eval(s) = w 1 f 1 (s) + w 2 f 2 (s) + … + w n f n (s)

Pag. 35 Heuristic EVAL example Eval(s) = w 1 f 1 (s) + w 2 f 2 (s) + … + w n f n (s) Addition assumes independence

Pag. 36 Heuristic difficulties Heuristic counts pieces won

Pag. 37 Horizon effect Fixed depth search thinks it can avoid the queening move

Pag. 38 Games that include chance Possible moves (5-10,5-11), (5-11,19- 24),(5-10,10-16) and (5-11,11-16)

Pag. 39 Games that include chance Possible moves (5-10,5-11), (5-11,19-24),(5-10,10- 16) and (5-11,11-16) [1,1], [6,6] chance 1/36, all other chance 1/18 chance nodes

Pag. 40 Games that include chance [1,1], [6,6] chance 1/36, all other chance 1/18 Can not calculate definite minimax value, only expected value

Pag. 41 Expected minimax value EXPECTED-MINIMAX-VALUE(n)= UTILITY(n) If n is a terminal max s successors(n) MINIMAX-VALUE(s) If n is a max node min s successors(n) MINIMAX-VALUE(s) If n is a max node s successors(n) P(s). EXPECTEDMINIMAX(s) If n is a chance node These equations can be backed-up recursively all the way to the root of the game tree.

Pag. 42 Position evaluation with chance nodes Left, A1 wins Right A2 wins Outcome of evaluation function may not change when values are scaled differently. Behavior is preserved only by a positive linear transformation of EVAL.

Pag. 43 Discussion Examine section on state-of-the-art games yourself Minimax assumes right tree is better than left, yet … –Return probability distribution over possible values –Yet expensive calculation

Pag. 44 Discussion Utility of node expansion –Only expand those nodes which lead to significanlty better moves Both suggestions require meta-reasoning

Pag. 45 Summary Games are fun (and dangerous) They illustrate several important points about AI –Perfection is unattainable -> approximation –Good idea what to think about –Uncertainty constrains the assignment of values to states Games are to AI as grand prix racing is to automobile design.