University of Amsterdam Search, Navigate, and Actuate – Search through Game Trees Arnoud Visser 1 Game Playing Search the action space of 2 players Russell.

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.
Adversarial Search Chapter 6 Section 1 – 4. Types of Games.
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.
Games & Adversarial Search
Adversarial Search Chapter 6 Section 1 – 4. Warm Up Let’s play some games!
ICS-271:Notes 6: 1 Notes 6: Game-Playing ICS 271 Fall 2008.
Game Playing (Tic-Tac-Toe), ANDOR graph By Chinmaya, Hanoosh,Rajkumar.
Adversarial Search Chapter 6 Section 1 – 4.
Adversarial Search Chapter 5.
COMP-4640: Intelligent & Interactive Systems Game Playing A game can be formally defined as a search problem with: -An initial state -a set of operators.
1 Game Playing. 2 Outline Perfect Play Resource Limits Alpha-Beta pruning Games of Chance.
Lecture 12 Last time: CSPs, backtracking, forward checking Today: Game Playing.
Adversarial Search Game Playing Chapter 6. Outline Games Perfect Play –Minimax decisions –α-β pruning Resource Limits and Approximate Evaluation Games.
Adversarial Search CSE 473 University of Washington.
Adversarial Search Chapter 6.
Artificial Intelligence for Games Game playing Patrick Olivier
Adversarial Search 對抗搜尋. Outline  Optimal decisions  α-β pruning  Imperfect, real-time decisions.
An Introduction to Artificial Intelligence Lecture VI: Adversarial Search (Games) Ramin Halavati In which we examine problems.
1 Adversarial Search Chapter 6 Section 1 – 4 The Master vs Machine: A Video.
10/19/2004TCSS435A Isabelle Bichindaritz1 Game and Tree Searching.
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
1 Game Playing Chapter 6 Additional references for the slides: Luger’s AI book (2005). Robert Wilensky’s CS188 slides:
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)
ICS-271:Notes 6: 1 Notes 6: Game-Playing ICS 271 Fall 2006.
Game Tree Search based on Russ Greiner and Jean-Claude Latombe’s notes.
Adversarial Search: Game Playing Reading: Chess paper.
Games & Adversarial Search Chapter 6 Section 1 – 4.
1 Adversary Search Ref: Chapter 5. 2 Games & A.I. Easy to measure success Easy to represent states Small number of operators Comparison against humans.
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.
1 Game Playing Why do AI researchers study game playing? 1.It’s a good reasoning problem, formal and nontrivial. 2.Direct comparison with humans and other.
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.
Adversarial Search Chapter 6 Section 1 – 4. Outline Optimal decisions α-β pruning Imperfect, real-time decisions.
Introduction to Artificial Intelligence CS 438 Spring 2008 Today –AIMA, Ch. 6 –Adversarial Search Thursday –AIMA, Ch. 6 –More Adversarial Search The “Luke.
Adversarial Search Chapter 6 Section 1 – 4. Search in an Adversarial Environment Iterative deepening and A* useful for single-agent search problems What.
Kansas State University Department of Computing and Information Sciences CIS 730: Introduction to Artificial Intelligence Lecture 9 of 42 Wednesday, 14.
Adversarial Search Chapter Games vs. search problems "Unpredictable" opponent  specifying a move for every possible opponent reply Time limits.
Paula Matuszek, CSC 8520, Fall Based in part on aima.eecs.berkeley.edu/slides-ppt 1 CS 8520: Artificial Intelligence Adversarial Search Paula Matuszek.
ARTIFICIAL INTELLIGENCE (CS 461D) Princess Nora University Faculty of Computer & Information Systems.
Adversarial Search Chapter 6 Section 1 – 4. Games vs. search problems "Unpredictable" opponent  specifying a move for every possible opponent reply Time.
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.
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.
5/4/2005EE562 EE562 ARTIFICIAL INTELLIGENCE FOR ENGINEERS Lecture 9, 5/4/2005 University of Washington, Department of Electrical Engineering Spring 2005.
Artificial Intelligence AIMA §5: Adversarial Search
Game Playing Why do AI researchers study game playing?
EA C461 – Artificial Intelligence Adversarial Search
PENGANTAR INTELIJENSIA BUATAN (64A614)
CS 460 Spring 2011 Lecture 4.
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
Minimax strategies, alpha beta pruning
Games & Adversarial Search
Adversarial Search Chapter 6 Section 1 – 4.
Presentation transcript:

University of Amsterdam Search, Navigate, and Actuate – Search through Game Trees Arnoud Visser 1 Game Playing Search the action space of 2 players Russell & Norvig Chapter 6 Bratko Chapter 22

University of Amsterdam Search, Navigate, and Actuate – Search through Game Trees Arnoud Visser 2 Game Playing ‘Games contribute to AI like Formula 1 racing contributes to automobile design.’ ‘Games, like the real world, require the ability to make some decision, even when the optimal decision is infeasible.’ ‘Games penalize inefficiency severely’.

University of Amsterdam Search, Navigate, and Actuate – Search through Game Trees Arnoud Visser 3 Games vs. search problems "Unpredictable" opponent  specifying a move for every possible opponent reply Time limits  unlikely to find the solution, must approximate a solution

University of Amsterdam Search, Navigate, and Actuate – Search through Game Trees Arnoud Visser 4 Game tree of tic-tac-toe (2-player, deterministic, turn-taking, zero sum) University of Amsterdam

Search, Navigate, and Actuate – Search through Game Trees Arnoud Visser 5 Minimax Perfect play for deterministic games Idea: choose move to position with highest minimax value = best achievable payoff against perfect playing opponent E.g., 2-ply game:

University of Amsterdam Search, Navigate, and Actuate – Search through Game Trees Arnoud Visser 6 Minimax algorithm

University of Amsterdam Search, Navigate, and Actuate – Search through Game Trees Arnoud Visser 7 Minimax prolog implementation minimax( Pos, BestSucc, Val) :- moves( Pos, PosList), !, % Legal moves in Pos best( PosList, BestSucc, Val) ; staticval( Pos, Val). % Terminal Pos has no successors best( [ Pos], Pos, Val) :- minimax( Pos, _, Val), !. best( [Pos1 | PosList], BestPos, BestVal) :- minimax( Pos1, _, Val1), best( PosList, Pos2, Val2), betterof( Pos1, Val1, Pos2, Val2, BestPos, BestVal). betterof( Pos0, Val0, Pos1, Val1, Pos0, Val0) :- min_to_move( Pos0), Val0 > Val1, ! % MAX prefers the greater value ; max_to_move( Pos0), Val0 < Val1, !. % MIN prefers the lesser value betterof( Pos0, Val0, Pos1, Val1, Pos1, Val1). % Otherwise Pos1 better than Pos0

University of Amsterdam Search, Navigate, and Actuate – Search through Game Trees Arnoud Visser 8 Game interface moves( Pos, PosList) % Legal moves in Pos, fails when Pos is terminal staticval( Pos, Val). % value of a Terminal node (utility function) min_to_move( Pos ) % the opponents turn max_to_move( Pos ) % our turn Maarten van Soomeren’s implementation is based on Bratko’s implementation: fig22_3.txt fig22_3.txt The tic-tac-toe game interface is based on 4 relations: Bratko’s terminal position are win (+1) or loose (-1),

University of Amsterdam Search, Navigate, and Actuate – Search through Game Trees Arnoud Visser 9 Properties of minimax Complete? Yes (if tree is finite) Optimal? Yes (against an optimal opponent) 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

University of Amsterdam Search, Navigate, and Actuate – Search through Game Trees Arnoud Visser 10 α-β pruning Efficient minimaxing Idea: once a move is clearly inferior to a previous move, it is not necessary to know exactly how much inferior. Introduce two bounds: Alpha = minimal value the MAX is guaranteed to achieve Beta = maximal value the MAX can hope to achieve Example:

University of Amsterdam Search, Navigate, and Actuate – Search through Game Trees Arnoud Visser 11 α-β pruning Example: Alpha = 3 Val Alpha ! Newbound(β)

University of Amsterdam Search, Navigate, and Actuate – Search through Game Trees Arnoud Visser 12 α-β pruning Example: Val > α Val < α Newbound(β) !

University of Amsterdam Search, Navigate, and Actuate – Search through Game Trees Arnoud Visser 13 Properties of α-β Pruning does not affect final result Good move ordering improves effectiveness of pruning With "perfect ordering," time complexity = O(b m/2 )  doubles depth of search A simple example of the value of reasoning about which computations are relevant (a form of metareasoning)

University of Amsterdam Search, Navigate, and Actuate – Search through Game Trees Arnoud Visser 14 AlphaBeta prolog implementation alphabeta( Pos, Alpha, Beta, GoodPos, Val) :- moves( Pos, PosList), !, % Legal moves in Pos boundedbest( PosList, Alpha, Beta, GoodPos, Val) ; staticval( Pos, Val). % Terminal Pos has no successors boundedbest( [Pos | PosList], Alpha, Beta, GoodPos, GoodVal) :- alphabeta( Pos, Alpha, Beta, _, Val), goodenough( PosList, Alpha, Beta, Pos, Val, GoodPos, GoodVal). … goodenough( _, Alpha, Beta, Pos, Val, Pos, Val) :- min_to_move( Pos), Val > Beta, ! % MAX prefers the greater value ; max_to_move( Pos), Val < Alpha, !. % MIN prefers the lesser value goodenough( PosList, Alpha, Beta, Pos, Val, GoodPos, GoodVal) :- newbounds( Alpha, Beta, Pos, Val, NewAlpha, NewBeta), % Refine bounds boundedbest( PosList, NewAlpha, NewBeta, Pos1, Val1), betterof( Pos, Val, Pos1, Val1, GoodPos, GoodVal).

University of Amsterdam Search, Navigate, and Actuate – Search through Game Trees Arnoud Visser 15 Properties of α-β implementation +straightforward implementation -It doesn’t answer the solution tree -With the depth-first strategy, it is difficult to control

University of Amsterdam Search, Navigate, and Actuate – Search through Game Trees Arnoud Visser 16 Prolog assignment alphabeta( Pos, Alpha, Beta, GoodPos, Val, MaxDepth) Download AlphaBeta implementation from Bratko: fig22_5.txt fig22_5.txt Replace in your solution minimax for AlphaBeta. Create test-routines to inspect the performance difference

University of Amsterdam Search, Navigate, and Actuate – Search through Game Trees Arnoud Visser 17 Resource usages in chess Suppose we have 100 secs, explore 10 4 nodes/sec  10 6 nodes per move ≈ 35 8/2  α-β reaches depth 8  human chess player Needed additional modifications: cutoff test: e.g., depth limit (perhaps add quiescence search) evaluation function = estimated desirability of position

University of Amsterdam Search, Navigate, and Actuate – Search through Game Trees Arnoud Visser 18 Evaluation-functions are quite static We need domain knowledge (heuristics) At many equivalent quiescence positions, we need long term plans, and we have to stick to them An expert system is needed with long term plans –This heuristic values are values proposed by Maarten van Someren

University of Amsterdam Search, Navigate, and Actuate – Search through Game Trees Arnoud Visser 19 Advantages of separating production rules from inference engine +Modularity: each rule an concise piece of knowledge +Incrementability: new rules can be added independently of other rules +Modifiability: old rules can be changed +Transparent

University of Amsterdam Search, Navigate, and Actuate – Search through Game Trees Arnoud Visser 20 Production rules If precondition P then Conclusion C If situation S then action A If conditions C1 and C2 hold then Condition C does not hold

University of Amsterdam Search, Navigate, and Actuate – Search through Game Trees Arnoud Visser 21 Advice Language Central in Advice Language is an advice table. Each table is ordered collection of production rules. When the precondition is forfilled, a list of advices can be tried, in the order specified. A ‘piece-of-advice’ is the central building block in AL0.

University of Amsterdam Search, Navigate, and Actuate – Search through Game Trees Arnoud Visser 22 Piece-of-Advice Extending Situation Calculus: Us-move-constraints: selects a subset of all legal us-moves Them-move-constraints: selects a subset of all legal them-moves Combination of precondition and actions.

University of Amsterdam Search, Navigate, and Actuate – Search through Game Trees Arnoud Visser 23 Advice Language Stop criteria: Better-goal: a goal to be achieved Holding-goal: a goal to be maintained while playing toward the better-goal

University of Amsterdam Search, Navigate, and Actuate – Search through Game Trees Arnoud Visser 24 The result Solution trees are implemented with forcing trees: AND/OR trees where AND-nodes have only one arc (selected us-move). P Q1Q1 R1R1 Q2Q2 R2R2 Q3Q3 R3R3

University of Amsterdam Search, Navigate, and Actuate – Search through Game Trees Arnoud Visser 25 Prolog assignment Select subset of legal moves with Advice Language: Download: Test:

University of Amsterdam Search, Navigate, and Actuate – Search through Game Trees Arnoud Visser 26 Advice Language applied to chess Bratko gives a solution for the King and Rook vs King problem Advice table consist of two rules: –edge_rule (trying mate_in_2) –else_rule Both rules the following advices in this order: –squeeze, approach, keeproom, divide_in_2, divide_in_3

University of Amsterdam Search, Navigate, and Actuate – Search through Game Trees Arnoud Visser 27 Illustration of game-play

University of Amsterdam Search, Navigate, and Actuate – Search through Game Trees Arnoud Visser 28 Assignment of this week Generate an expert system for the chess problem King and Queen versus King