CS 460, Sessions 8-9 1 Last time: search strategies Uninformed: Use only information available in the problem formulation Breadth-first Uniform-cost Depth-first.

Slides:



Advertisements
Similar presentations
Adversarial Search Chapter 6 Sections 1 – 4. Outline Optimal decisions α-β pruning Imperfect, real-time decisions.
Advertisements

Adversarial Search Chapter 6 Section 1 – 4. Types of Games.
Classic AI Search Problems
Games & Adversarial Search Chapter 5. Games vs. search problems "Unpredictable" opponent  specifying a move for every possible opponent’s reply. Time.
For Friday Finish chapter 5 Program 1, Milestone 1 due.
February 7, 2006AI: Chapter 6: Adversarial Search1 Artificial Intelligence Chapter 6: Adversarial Search Michael Scherger Department of Computer Science.
Games & Adversarial Search
Artificial Intelligence Adversarial search Fall 2008 professor: Luigi Ceccaroni.
CMSC 671 Fall 2001 Class #8 – Thursday, September 27.
ICS-271:Notes 6: 1 Notes 6: Game-Playing ICS 271 Fall 2008.
Game Playing (Tic-Tac-Toe), ANDOR graph By Chinmaya, Hanoosh,Rajkumar.
CS 484 – Artificial Intelligence
Adversarial Search Chapter 6 Section 1 – 4.
SE Last time: search strategies Uninformed: Use only information available in the problem formulation Breadth-first Uniform-cost Depth-first Depth-limited.
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.
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.
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
CS 561, Sessions Administrativia Assignment 1 due tuesday 9/24/2002 BEFORE midnight Midterm exam 10/10/2002.
DCP 1172, Homework 2 1 Homework 2 for DCP-1172 ( ) This time, we have 3 different homework assignments.  Homework assignment 2-1 (50%, Ch3 &
1 Game Playing Chapter 6 Additional references for the slides: Luger’s AI book (2005). Robert Wilensky’s CS188 slides:
CS 561, Sessions Last time: search strategies Uninformed: Use only information available in the problem formulation Breadth-first Uniform-cost Depth-first.
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)
1 DCP 1172 Introduction to Artificial Intelligence Lecture notes for Chap. 6 [AIMA] Chang-Sheng Chen.
ICS-271:Notes 6: 1 Notes 6: Game-Playing ICS 271 Fall 2006.
Games & Adversarial Search Chapter 6 Section 1 – 4.
Game Playing: Adversarial Search Chapter 6. Why study games Fun Clear criteria for success Interesting, hard problems which require minimal “initial structure”
Game Playing State-of-the-Art  Checkers: Chinook ended 40-year-reign of human world champion Marion Tinsley in Used an endgame database defining.
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 Trees: MiniMax strategy, Tree Evaluation, Pruning, Utility evaluation Adapted from slides of Yoonsuck Choe.
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. Introduction Why is game playing so interesting from an AI point of view? –Game Playing is harder then common searching The search space.
Game Playing.
October 3, 2012Introduction to Artificial Intelligence Lecture 9: Two-Player Games 1 Iterative Deepening A* Algorithm A* has memory demands that increase.
Adversarial Search. Game playing Perfect play The minimax algorithm alpha-beta pruning Resource limitations Elements of chance Imperfect information.
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.
Games. Adversaries Consider the process of reasoning when an adversary is trying to defeat our efforts In game playing situations one searches down the.
Adversarial Search Chapter Games vs. search problems "Unpredictable" opponent  specifying a move for every possible opponent reply Time limits.
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.
Adversarial Search 2 (Game Playing)
Adversarial Search and Game Playing Russell and Norvig: Chapter 6 Slides adapted from: robotics.stanford.edu/~latombe/cs121/2004/home.htm Prof: Dekang.
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.
Announcements Homework 1 Full assignment posted..
Last time: search strategies
PENGANTAR INTELIJENSIA BUATAN (64A614)
CS 460 Spring 2011 Lecture 4.
Games & Adversarial Search
Games & Adversarial Search
Adversarial Search.
Games & Adversarial Search
Games & Adversarial Search
Game Playing Fifth Lecture 2019/4/11.
Games & Adversarial Search
Adversarial Search Chapter 6 Section 1 – 4.
Presentation transcript:

CS 460, Sessions Last time: search strategies Uninformed: Use only information available in the problem formulation Breadth-first Uniform-cost Depth-first Depth-limited Iterative deepening Informed: Use heuristics to guide the search Best first: Greedy search – queue first nodes that maximize heuristic “desirability” based on estimated path cost from current node to goal; A* search – queue first nodes that maximize sum of path cost so far and estimated path cost to goal. Iterative improvement – keep no memory of path; work on a single current state and iteratively improve its “value.” Hill climbing – select as new current state the successor state which maximizes value. Simulated annealing – refinement on hill climbing by which “bad moves” are permitted, but with decreasing size and frequency. Will find global extremum.

CS 460, Sessions Exercise: Search Algorithms The following figure shows a portion of a partially expanded search tree. Each arc between nodes is labeled with the cost of the corresponding operator, and the leaves are labeled with the value of the heuristic function, h. Which node (use the node’s letter) will be expanded next by each of the following search algorithms? (a) Depth-first search (b) Breadth-first search (c) Uniform-cost search (d) Greedy search (e) A* search 5 D 5 A C h=15 B FGE h=8h=12h=10 h=18 H h=20 h=14

CS 460, Sessions Depth-first search Node queue:initialization #statedepthpath costparent # 1A00--

CS 460, Sessions Depth-first search Node queue:add successors to queue front; empty queue from top #statedepthpath costparent # 2B131 3C1191 4D151 1A00--

CS 460, Sessions Depth-first search Node queue:add successors to queue front; empty queue from top #statedepthpath costparent # 5E272 6F282 7G282 8H292 2B131 3C1191 4D151 1A00--

CS 460, Sessions Depth-first search Node queue:add successors to queue front; empty queue from top #statedepthpath costparent # 5E272 6F282 7G282 8H292 2B131 3C1191 4D151 1A00--

CS 460, Sessions Exercise: Search Algorithms The following figure shows a portion of a partially expanded search tree. Each arc between nodes is labeled with the cost of the corresponding operator, and the leaves are labeled with the value of the heuristic function, h. Which node (use the node’s letter) will be expanded next by each of the following search algorithms? (a) Depth-first search (b) Breadth-first search (c) Uniform-cost search (d) Greedy search (e) A* search 5 D 5 A C h=15 B FGE h=8h=12h=10 h=18 H h=20 h=14

CS 460, Sessions Breadth-first search Node queue:initialization #statedepthpath costparent # 1A00--

CS 460, Sessions Breadth-first search Node queue:add successors to queue end; empty queue from top #statedepthpath costparent # 1A00-- 2B131 3C1191 4D151

CS 460, Sessions Breadth-first search Node queue:add successors to queue end; empty queue from top #statedepthpath costparent # 1A00-- 2B131 3C1191 4D151 5E272 6F282 7G282 8H292

CS 460, Sessions Breadth-first search Node queue:add successors to queue end; empty queue from top #statedepthpath costparent # 1A00-- 2B131 3C1191 4D151 5E272 6F282 7G282 8H292

CS 460, Sessions Exercise: Search Algorithms The following figure shows a portion of a partially expanded search tree. Each arc between nodes is labeled with the cost of the corresponding operator, and the leaves are labeled with the value of the heuristic function, h. Which node (use the node’s letter) will be expanded next by each of the following search algorithms? (a) Depth-first search (b) Breadth-first search (c) Uniform-cost search (d) Greedy search (e) A* search 5 D 5 A C h=15 B FGE h=8h=12h=10 h=18 H h=20 h=14

CS 460, Sessions Uniform-cost search Node queue:initialization #statedepthpath costparent # 1A00--

CS 460, Sessions Uniform-cost search Node queue:add successors to queue so that entire queue is sorted by path cost so far; empty queue from top #statedepthpath costparent # 1A00-- 2B131 3D151 4C1191

CS 460, Sessions Uniform-cost search Node queue:add successors to queue so that entire queue is sorted by path cost so far; empty queue from top #statedepthpath costparent # 1A00-- 2B131 3D151 5E272 6F282 7G282 8H292 4C1191

CS 460, Sessions Uniform-cost search Node queue:add successors to queue so that entire queue is sorted by path cost so far; empty queue from top #statedepthpath costparent # 1A00-- 2B131 3D151 5E272 6F282 7G282 8H292 4C1191

CS 460, Sessions Exercise: Search Algorithms The following figure shows a portion of a partially expanded search tree. Each arc between nodes is labeled with the cost of the corresponding operator, and the leaves are labeled with the value of the heuristic function, h. Which node (use the node’s letter) will be expanded next by each of the following search algorithms? (a) Depth-first search (b) Breadth-first search (c) Uniform-cost search (d) Greedy search (e) A* search 5 D 5 A C h=15 B FGE h=8h=12h=10 h=18 H h=20 h=14

CS 460, Sessions Greedy search Node queue:initialization #statedepthpathcosttotalparent # costto goalcost 1A

CS 460, Sessions Greedy search Node queue:Add successors to queue, sorted by cost to goal. #statedepthpathcosttotalparent # costto goalcost 1A B D C Sort key

CS 460, Sessions Greedy search Node queue:Add successors to queue, sorted by cost to goal. #statedepthpathcosttotalparent # costto goalcost 1A B G E H F D C

CS 460, Sessions Greedy search Node queue:Add successors to queue, sorted by cost to goal. #statedepthpathcosttotalparent # costto goalcost 1A B G E H F D C

CS 460, Sessions Exercise: Search Algorithms The following figure shows a portion of a partially expanded search tree. Each arc between nodes is labeled with the cost of the corresponding operator, and the leaves are labeled with the value of the heuristic function, h. Which node (use the node’s letter) will be expanded next by each of the following search algorithms? (a) Depth-first search (b) Breadth-first search (c) Uniform-cost search (d) Greedy search (e) A* search 5 D 5 A C h=15 B FGE h=8h=12h=10 h=18 H h=20 h=14

CS 460, Sessions A* search Node queue:initialization #statedepthpathcosttotalparent # costto goalcost 1A

CS 460, Sessions A* search Node queue:Add successors to queue, sorted by total cost. #statedepthpathcosttotalparent # costto goalcost 1A B D C Sort key

CS 460, Sessions A* search Node queue:Add successors to queue front, sorted by total cost. #statedepthpathcosttotalparent # costto goalcost 1A B G E H D F C

CS 460, Sessions A* search Node queue:Add successors to queue front, sorted by total cost. #statedepthpathcosttotalparent # costto goalcost 1A B G E H D F C

CS 460, Sessions Exercise: Search Algorithms The following figure shows a portion of a partially expanded search tree. Each arc between nodes is labeled with the cost of the corresponding operator, and the leaves are labeled with the value of the heuristic function, h. Which node (use the node’s letter) will be expanded next by each of the following search algorithms? (a) Depth-first search (b) Breadth-first search (c) Uniform-cost search (d) Greedy search (e) A* search 5 D 5 A C h=15 B FGE h=8h=12h=10 h=18 H h=20 h=14

CS 460, Sessions Last time: Simulated annealing algorithm Idea: Escape local extrema by allowing “bad moves,” but gradually decrease their size and frequency. Note: goal here is to maximize E. -

CS 460, Sessions Last time: Simulated annealing algorithm Idea: Escape local extrema by allowing “bad moves,” but gradually decrease their size and frequency. Algorithm when goal is to minimize E. < - -

CS 460, Sessions This time: Outline Game playing The minimax algorithm Resource limitations alpha-beta pruning Elements of chance

CS 460, Sessions What kind of games? Abstraction: To describe a game we must capture every relevant aspect of the game. Such as: Chess Tic-tac-toe … Accessible environments: Such games are characterized by perfect information Search: game-playing then consists of a search through possible game positions Unpredictable opponent: introduces uncertainty thus game-playing must deal with contingency problems

CS 460, Sessions Searching for the next move Complexity: many games have a huge search space Chess:b = 35, m=100  nodes = if each node takes about 1 ns to explore then each move will take about millennia to calculate. Resource (e.g., time, memory) limit: optimal solution not feasible/possible, thus must approximate 1.Pruning: makes the search more efficient by discarding portions of the search tree that cannot improve quality result. 2.Evaluation functions: heuristics to evaluate utility of a state without exhaustive search.

CS 460, Sessions Two-player games A game formulated as a search problem: Initial state: ? Operators: ? Terminal state: ? Utility function: ?

CS 460, Sessions Two-player games A game formulated as a search problem: Initial state: board position and turn Operators: definition of legal moves Terminal state: conditions for when game is over Utility function: a numeric value that describes the outcome of the game. E.g., -1, 0, 1 for loss, draw, win. (AKA payoff function)

CS 460, Sessions Game vs. search problem

CS 460, Sessions Example: Tic-Tac-Toe

CS 460, Sessions Type of games

CS 460, Sessions Type of games

CS 460, Sessions The minimax algorithm Perfect play for deterministic environments with perfect information Basic idea: choose move with highest minimax value = best achievable payoff against best play Algorithm: 1.Generate game tree completely 2.Determine utility of each terminal state 3.Propagate the utility values upward in the three by applying MIN and MAX operators on the nodes in the current level 4.At the root node use minimax decision to select the move with the max (of the min) utility value Steps 2 and 3 in the algorithm assume that the opponent will play perfectly.

CS 460, Sessions Generate Game Tree

CS 460, Sessions Generate Game Tree x xx x

CS 460, Sessions Generate Game Tree x ox x o x o xo

CS 460, Sessions Generate Game Tree x ox x o x o xo 1 ply 1 move

CS 460, Sessions A subtree win lose draw xx o o o x xx o o o x xx o o o x x xx o o o x x x xx o o o x x xx o o o x x xx o o o x x xx o o o x x xx o o o x x xx o o o x x o o oo o o xx o o o x x oxxx xx o o o x x o xx o o o x x o x xx o o o x xo

CS 460, Sessions What is a good move? win lose draw xx o o o x xx o o o x xx o o o x x xx o o o x x x xx o o o x x xx o o o x x xx o o o x x xx o o o x x xx o o o x x xx o o o x x o o oo o o xx o o o x x oxxx xx o o o x x o xx o o o x x o x xx o o o x xo

CS 460, Sessions Minimax Minimize opponent’s chance Maximize your chance

CS 460, Sessions Minimax MIN Minimize opponent’s chance Maximize your chance

CS 460, Sessions Minimax MAX MIN Minimize opponent’s chance Maximize your chance

CS 460, Sessions Minimax MAX MIN Minimize opponent’s chance Maximize your chance

CS 460, Sessions minimax = maximum of the minimum 1 st ply 2 nd ply

CS 460, Sessions Minimax: Recursive implementation Complete: ? Optimal: ? Time complexity: ? Space complexity: ?

CS 460, Sessions Minimax: Recursive implementation Complete: Yes, for finite state-space Optimal: Yes Time complexity: O(b m ) Space complexity: O(bm) (= DFS Does not keep all nodes in memory.)

CS 460, Sessions Move evaluation without complete search Complete search is too complex and impractical Evaluation function: evaluates value of state using heuristics and cuts off search New MINIMAX: CUTOFF-TEST: cutoff test to replace the termination condition (e.g., deadline, depth-limit, etc.) EVAL: evaluation function to replace utility function (e.g., number of chess pieces taken)

CS 460, Sessions Evaluation functions Weighted linear evaluation function: to combine n heuristics f = w 1 f 1 + w 2 f 2 + … + w n f n E.g, w ’s could be the values of pieces (1 for prawn, 3 for bishop etc.) f ’s could be the number of type of pieces on the board

CS 460, Sessions Note: exact values do not matter

CS 460, Sessions Minimax with cutoff: viable algorithm? Assume we have 100 seconds, evaluate 10 4 nodes/s; can evaluate 10 6 nodes/move

CS 460, Sessions  -  pruning: search cutoff Pruning: eliminating a branch of the search tree from consideration without exhaustive examination of each node  -  pruning: the basic idea is to prune portions of the search tree that cannot improve the utility value of the max or min node, by just considering the values of nodes seen so far. Does it work? Yes, in roughly cuts the branching factor from b to  b resulting in double as far look-ahead than pure minimax

CS 460, Sessions  -  pruning: example  6 6 MAX 6128 MIN

CS 460, Sessions  -  pruning: example  6 6 MAX  2 MIN

CS 460, Sessions  -  pruning: example  6 6 MAX  2 5  5 MIN

CS 460, Sessions  -  pruning: example  6 6 MAX  2 5  5 MIN Selected move

CS 460, Sessions  -  pruning: general principle Player Opponent m n  v If  > v then MAX will chose m so prune tree under n Similar for  for MIN

CS 460, Sessions Properties of  - 

CS 460, Sessions The  -  algorithm:

CS 460, Sessions More on the  -  algorithm Same basic idea as minimax, but prune (cut away) branches of the tree that we know will not contain the solution.

CS 460, Sessions More on the  -  algorithm: start from Minimax

CS 460, Sessions Remember: Minimax: Recursive implementation Complete: Yes, for finite state-space Optimal: Yes Time complexity: O(b m ) Space complexity: O(bm) (= DFS Does not keep all nodes in memory.)

CS 460, Sessions More on the  -  algorithm Same basic idea as minimax, but prune (cut away) branches of the tree that we know will not contain the solution. Because minimax is depth-first, let’s consider nodes along a given path in the tree. Then, as we go along this path, we keep track of:  : Best choice so far for MAX  : Best choice so far for MIN

CS 460, Sessions More on the  -  algorithm: start from Minimax Note: These are both Local variables. At the Start of the algorithm, We initialize them to  = -  and  = + 

CS 460, Sessions More on the  -  algorithm … MAX MIN MAX  = -   = +  Min-Value loops over these In Min-Value:  = -   = 5  = -   = 5  = -   = 5 Max-Value loops over these

CS 460, Sessions More on the  -  algorithm … MAX MIN MAX  = -   = +  In Max-Value:  = -   = 5  = -   = 5  = -   = 5  = 5  = +  Max-Value loops over these

CS 460, Sessions In Min-Value: More on the  -  algorithm … MAX MIN MAX  = -   = +   = -   = 5  = -   = 5  = -   = 5  = 5  = +   = 5  = 2 End loop and return 5 Min-Value loops over these

CS 460, Sessions In Max-Value: More on the  -  algorithm … MAX MIN MAX  = -   = +   = -   = 5  = -   = 5  = -   = 5  = 5  = +   = 5  = 2 End loop and return 5  = 5  = +  Max-Value loops over these

CS 460, Sessions Another way to understand the algorithm From: For a given node N,  is the value of N to MAX  is the value of N to MIN

CS 460, Sessions Example

CS 460, Sessions  -  algorithm:

CS 460, Sessions Solution NODE TYPE ALPHA BETA SCORE A Max -I +I B Min -I +I C Max -I +I D Min -I +I E Max D Min -I 10 F Max D Min -I C Max 10 +I G Min 10 +I H Max G Min C Max 10 +I 10 B Min -I 10 J Max -I 10 K Min -I 10 L Max K Min -I … NODE TYPE ALPHA BETA SCORE … J Max B Min -I A Max 10 +I Q Min 10 +I R Max 10 +I S Min 10 +I T Max S Min R Max 10 +I V Min 10 +I W Max V Min R Max 10 +I 10 Q Min A Max

CS 460, Sessions State-of-the-art for deterministic games

CS 460, Sessions Nondeterministic games

CS 460, Sessions Algorithm for nondeterministic games

CS 460, Sessions Remember: Minimax algorithm

CS 460, Sessions Nondeterministic games: the element of chance 3 ? ? CHANCE ? expectimax and expectimin, expected values over all possible outcomes

CS 460, Sessions Nondeterministic games: the element of chance CHANCE 4 = 0.5* *5 Expectimax Expectimin

CS 460, Sessions Evaluation functions: Exact values DO matter Order-preserving transformation do not necessarily behave the same!

CS 460, Sessions State-of-the-art for nondeterministic games

CS 460, Sessions Summary

CS 460, Sessions Exercise: Game Playing (a) Compute the backed-up values computed by the minimax algorithm. Show your answer by writing values at the appropriate nodes in the above tree. (b) Compute the backed-up values computed by the alpha-beta algorithm. What nodes will not be examined by the alpha-beta pruning algorithm? (c) What move should Max choose once the values have been backed-up all the way? A B C D E FG HIJ K LMNOPQRSTUVWYX Max Min Consider the following game tree in which the evaluation function values are shown below each leaf node. Assume that the root node corresponds to the maximizing player. Assume the search always visits children left-to-right.