State Space Search and Planning General Game PlayingLecture 4 Michael Genesereth Spring 2005.

Slides:



Advertisements
Similar presentations
Review: Search problem formulation
Advertisements

Uninformed search strategies
Solving Problem by Searching
Lecture 3: Uninformed Search
ICS-271:Notes 6: 1 Notes 6: Game-Playing ICS 271 Fall 2008.
Problem Solving Agents A problem solving agent is one which decides what actions and states to consider in completing a goal Examples: Finding the shortest.
1 Lecture 3 Uninformed Search. 2 Uninformed search strategies Uninformed: While searching you have no clue whether one non-goal state is better than any.
Solving Problems by Searching Currently at Chapter 3 in the book Will finish today/Monday, Chapter 4 next.
CS 480 Lec 3 Sept 11, 09 Goals: Chapter 3 (uninformed search) project # 1 and # 2 Chapter 4 (heuristic search)
Search Strategies Reading: Russell’s Chapter 3 1.
1 Blind (Uninformed) Search (Where we systematically explore alternatives) R&N: Chap. 3, Sect. 3.3–5.
Lets remember about Goal formulation, Problem formulation and Types of Problem. OBJECTIVE OF TODAY’S LECTURE Today we will discus how to find a solution.
Implementation and Evaluation of Search Methods. Use a stack data structure. 1. Push root node of tree on the stack. 2. Pop the top node off the stack.
Touring problems Start from Arad, visit each city at least once. What is the state-space formulation? Start from Arad, visit each city exactly once. What.
UNINFORMED SEARCH Problem - solving agents Example : Romania  On holiday in Romania ; currently in Arad.  Flight leaves tomorrow from Bucharest.
Search Strategies.  Tries – for word searchers, spell checking, spelling corrections  Digital Search Trees – for searching for frequent keys (in text,
CPSC 322, Lecture 9Slide 1 Search: Advanced Topics Computer Science cpsc322, Lecture 9 (Textbook Chpt 3.6) January, 23, 2009.
SE Last time: Problem-Solving Problem solving: Goal formulation Problem formulation (states, operators) Search for solution Problem formulation:
UnInformed Search What to do when you don’t know anything.
Introduction to Artificial Intelligence Blind Search Ruth Bergman Fall 2004.
1 Lecture 3 Uninformed Search. 2 Complexity Recap (app.A) We often want to characterize algorithms independent of their implementation. “This algorithm.
Incomplete Information General Game PlayingLecture 5 Michael Genesereth Spring 2005.
ICS-271:Notes 6: 1 Notes 6: Game-Playing ICS 271 Fall 2006.
Using Search in Problem Solving
CIS 310: Visual Programming, Spring 2006 Western State College 310: Visual Programming Othello.
Introduction to Artificial Intelligence Blind Search Ruth Bergman Fall 2002.
CS 561, Session 6 1 Last time: Problem-Solving Problem solving: Goal formulation Problem formulation (states, operators) Search for solution Problem formulation:
1 Lecture 3 Uninformed Search
Managing Search General Game PlayingLecture 5 Michael Genesereth / Nat Love Spring 2006.
1 Midterm Review cmsc421 Fall Outline Review the material covered by the midterm Questions?
Lecture 3 Uninformed Search.
1 Problem Solving and Searching CS 171/271 (Chapter 3) Some text and images in these slides were drawn from Russel & Norvig’s published material.
KU NLP Heuristic Search Heuristic Search and Expert Systems (1) q An interesting approach to implementing heuristics is the use of confidence.
Lecture 2-2CS250: Intro to AI/Lisp Implementing Search Lecture 2-2 January 14 th /19 th, 1999 CS250.
Introduction to search Chapter 3. Why study search? §Search is a basis for all AI l search proposed as the basis of intelligence l inference l all learning.
Introduction to search Chapter 3. Why study search? §Search is a basis for all AI l search proposed as the basis of intelligence l all learning algorithms,
Informed search algorithms Chapter 4. Outline Best-first search Greedy best-first search A * search Heuristics.
For Monday Read chapter 4, section 1 No homework..
Lecture 3: Uninformed Search
Search CPSC 386 Artificial Intelligence Ellen Walker Hiram College.
Uninformed Search ECE457 Applied Artificial Intelligence Spring 2007 Lecture #2.
Basic Problem Solving Search strategy  Problem can be solved by searching for a solution. An attempt is to transform initial state of a problem into some.
Uninformed search strategies A search strategy is defined by picking the order of node expansion Uninformed search strategies use only the information.
Search as a problem solving technique. Consider an AI program that is capable of formulating a desired goal based on the analysis of the current world.
Implementation: General Tree Search
Graph Search II GAM 376 Robin Burke. Outline Homework #3 Graph search review DFS, BFS A* search Iterative beam search IA* search Search in turn-based.
Solving problems by searching A I C h a p t e r 3.
CPSC 322, Lecture 5Slide 1 Uninformed Search Computer Science cpsc322, Lecture 5 (Textbook Chpt 3.5) Sept, 13, 2013.
Blind Search Russell and Norvig: Chapter 3, Sections 3.4 – 3.6 CS121 – Winter 2003.
Search Part I Introduction Solutions and Performance Uninformed Search Strategies Avoiding Repeated States Partial Information Summary.
Romania. Romania Problem Initial state: Arad Goal state: Bucharest Operators: From any node, you can visit any connected node. Operator cost, the.
Automated Reasoning General Game PlayingLecture 3 Michael Genesereth Spring 2005.
Chapter 3 Solving problems by searching. Search We will consider the problem of designing goal-based agents in observable, deterministic, discrete, known.
Artificial Intelligence Solving problems by searching.
Chapter 3.5 Heuristic Search. Learning Objectives Heuristic search strategies –Best-first search –A* algorithm Heuristic functions.
Lecture 3: Uninformed Search
Last time: Problem-Solving
Uninformed Search Chapter 3.4.
Uninformed Search Strategies
Russell and Norvig: Chapter 3, Sections 3.4 – 3.6
What to do when you don’t know anything know nothing
EA C461 – Artificial Intelligence
Searching for Solutions
Problem Spaces & Search
Problem Spaces & Search
UNINFORMED SEARCH -BFS -DFS -DFIS - Bidirectional
Search.
Search.
CMSC 471 Fall 2011 Class #4 Tue 9/13/11 Uninformed Search
Basic Search Methods How to solve the control problem in production-rule systems? Basic techniques to find paths through state- nets. For the moment: -
Presentation transcript:

State Space Search and Planning General Game PlayingLecture 4 Michael Genesereth Spring 2005

2 Outline Cases: Single Player, Complete Information (today) Multiple Players, Partial Information (next time) Search Direction:Search Strategy: Forward Search Depth First Backward Search Breadth First Bidirectional Search Iterative Deepening Issues: State Collapse (Graph Search) Evaluation Functions

3 State Machine Model c be f h i dgj a k

4 Game Trees a c hg d ji b fe

5 Search Direction

6 Forward Search Even without variables, the number of models to be checked can be exceedingly large. There are, in general, infinitely many models to check. As it turns out, Relational Logic has two nice properties that help to deal with this problem. (1)Whenever a set of premises logically entails a conclusions, there is a finite proof of the conclusion from the premises. (2)It is possible to enumerate all proofs in a systematic way.

7 Backward Search Even without variables, the number of models to be checked can be exceedingly large. There are, in general, infinitely many models to check. As it turns out, Relational Logic has two nice properties that help to deal with this problem. (1)Whenever a set of premises logically entails a conclusions, there is a finite proof of the conclusion from the premises. (2)It is possible to enumerate all proofs in a systematic way.

8 Bidirectional Search Even without variables, the number of models to be checked can be exceedingly large. There are, in general, infinitely many models to check. As it turns out, Relational Logic has two nice properties that help to deal with this problem. (1)Whenever a set of premises logically entails a conclusions, there is a finite proof of the conclusion from the premises. (2)It is possible to enumerate all proofs in a systematic way.

9 Nodes function mguchkp (p,q,al) {cond(p=q, al; varp(p), mguchkp(p,cdr(assoc(q,al)),al); atom(q), nil; t, some(lambda(x).mguchkp(p,x,al),q))}

10 Node Expansion function expand (node) (let (data al nl) {var player = player(node); var role = role(player) for action in legals(role,node) do old = data(node); data(node) == consaction(role,action,old); data = sort(simulate(node),#'minlessp); data(node) = old; if new = gethash(data,hasher(player)) then new else {new = makenode(player,data,theory, node); gethash(data,hasher(player)) = new; if termp(new) then score(new)= reward(role,new); (setf (score new) (reward (role player) new))) (setq nl (cons new nl)))) (setq al (acons (car l) new al)))))

11 Tree Expansion (defun expandnodes (player nodes) (do ((i 1) (node)) ((or (> i nodes) (null (fringe player))) 'done) (setq node (car (fringe player))) (setf (fringe player) (cdr (fringe player))) (unless (score node) (setq i (1+ i)) (setf (fringe player) (nconc (fringe player) (expandnode node))))))

12 Search Strategy

13 Game Trees a c hg d ji b fe

14 Breadth First Search a b c d e f g h i j a c hg d ji b fe Advantage: Finds shortest path Disadvantage: Consumes large amount of space

15 Depth First Search a c hg d ji b fe a b e f c g h d i j Advantage: Small intermediate storage Disadvantage: Susceptible to garden paths Disadvantage: Susceptible to infinite loops

16 Time Comparison Analysis for branching 2 and depth d and solution at depth k

17 Time Comparison Analysis for branching b and depth d and solution at depth k.

18 Space Comparison Worst Case Space Analysis for search depth d and depth k.

19 Iterative Deepening Run depth-limited search repeatedly, starting with a small initial depth, incrementing on each iteration, until success or run out of alternatives.

20 Example a c hg d ji b fe a a b c d a b e f c g h d i j Advantage: Small intermediate storage Advantage: Finds shortest path Advantage: Not susceptible to garden paths Advantage: Not susceptible to infinite loops

21 Time Comparison

22 General Results Theorem [Korf]: The cost of iterative deepening search is b/(b-1) times the cost of depth-first search (where b is the branching factor). Theorem: The space cost of iterative deepening is no greater than the space cost for depth-first search.

23 Implementation function expand (node) (let (player role data al nl) var player=player(node); var role=role(player) for action in legals(role,node) do old = data(node); data(node) = consaction(role,action,old); data = sort(simulate(node),#'minlessp); data(node) = old; if new = gethash(data,hasher(player)) then new else {new = makenode(player,data,theory, node); gethash(data,hasher(player)) = new; if termp(new) then score(new)= reward(role,new); (setf (score new) (reward (role player) new))) (setq nl (cons new nl)))) (setq al (acons (car l) new al)))))

24 Graphs versus Trees

25 State Collapse The game tree for Tic-Tac-Toe has approximately 900,000 nodes. There are approximately 5,000 distinct states. Searching the tree requires 180 times more work than searching the graph. One small hitch: The graph is implicit in the state description and must be built in advance or incrementally. Recognizing a repeated state takes time that varies with the size of the graph thus far seen. Solution: Hashing.

26 Hashing function mguchkp (p,q,al) {cond(p=q, al; varp(p), mguchkp(p,cdr(assoc(q,al)),al); atom(q), nil; t, some(lambda(x).mguchkp(p,x,al),q))}

27 Sorting The game tree for Tic-Tac-Toe has approximately 900,000 nodes. There are approximately 5,000 distinct states. Searching the tree requires 180 times more work than searching the graph. One small hitch: The graph is implicit in the state description and must be built in advance or incrementally. Recognizing a repeated state takes time that varies with the size of the graph thus far seen. Solution: Hashing.

28 Ordering Code (defun minlessp (x y) (cond ((numberp x) (not (and (numberp y) (< y x)))) ((symbolp x) (cond ((numberp y) nil) ((symbolp y) (string< (symbol-name x) (symbol-name y)))) ((numberp y) nil) ((symbolp y) nil) (t (do ((l x (cdr l)) (m y (cdr m))) (nil) (cond ((null l) (return (not (null m)))) ((null m) (return nil)) ((minlessp (car l) (car m)) (return t)) ((equal (car l) (car m))) (t (return nil)))))))))

29 Node Expansion With State Collapse function expand (node) (let (player role data al nl) var player=player(node); var role=role(player) for action in legals(role,node) do old = data(node); data(node) = consaction(role,action,old); data = sort(simulate(node),#'minlessp); data(node) = old; if new = gethash(data,hasher(player)) then new else {new = makenode(player,data,theory, node); gethash(data,hasher(player)) = new; if termp(new) then score(new)= reward(role,new); (setf (score new) (reward (role player) new))) (setq nl (cons new nl)))) (setq al (acons (car l) new al)))))

30 Early Termination

31 Heuristic Search These are all techniques for blind search. In traditional approaches to game-playing, it is common to use evaluation functions to assess the quality of game state and, presumably, the likelihood of achieving the goal. Example: piece count in chess. In general game playing, the rules are not known in advance, and it is not possible to devise an evaluation function without such rules. We will discuss techniques for inventing evaluation functions in a later session.

32 Evaluation Functions Even without variables, the number of models to be checked can be exceedingly large. There are, in general, infinitely many models to check. As it turns out, Relational Logic has two nice properties that help to deal with this problem. (1)Whenever a set of premises logically entails a conclusions, there is a finite proof of the conclusion from the premises. (2)It is possible to enumerate all proofs in a systematic way.

33 Scores function maxscore (node) {cond(score(node); null(alist(node),nil; t, for l = alist(node) with score = nil with max = 0 when null(l) return(max) do score <- maxscore(cdar(l)); cond(score = 100,return(100); ~numberp(score), max <- nil; ~max; score > max, max <- score))}

34 Best Move function bestmove (node) {var best = nil; var score = nil; for pair in alist(node) do score = maxscore(cdr(pair)) cond(score = 100, return(car pair); score = 0, nil; null(best), best <- car(pair)) best or car(alist(node))}