Searching for Solutions Artificial Intelligence CSPP 56553 January 14, 2004.

Slides:



Advertisements
Similar presentations
Review: Search problem formulation
Advertisements

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.
Games & Adversarial 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.
CSC 423 ARTIFICIAL INTELLIGENCE
Search in AI.
Lecture 12 Last time: CSPs, backtracking, forward checking Today: Game Playing.
MINIMAX SEARCH AND ALPHA- BETA PRUNING: PLAYER 1 VS. PLAYER 2.
Games CPSC 386 Artificial Intelligence Ellen Walker Hiram College.
Minimax and Alpha-Beta Reduction Borrows from Spring 2006 CS 440 Lecture Slides.
Lecture 13 Last time: Games, minimax, alpha-beta Today: Finish off games, summary.
Artificial Intelligence in Game Design
Mahgul Gulzai Moomal Umer Rabail Hafeez
CPSC 322 Introduction to Artificial Intelligence October 27, 2004.
CPSC 322 Introduction to Artificial Intelligence October 25, 2004.
This time: Outline Game playing The minimax algorithm
Review: Search problem formulation
1 Using Search in Problem Solving Part II. 2 Basic Concepts Basic concepts: Initial state Goal/Target state Intermediate states Path from the initial.
Games with Chance Other Search Algorithms CPSC 315 – Programming Studio Spring 2008 Project 2, Lecture 3 Adapted from slides of Yoonsuck Choe.
Game Playing CSC361 AI CSC361: Game Playing.
MAE 552 – Heuristic Optimization Lecture 27 April 3, 2002
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)
Find a Path s A D B E C F G Heuristically Informed Methods  Which node do I expand next?  What information can I use to guide this.
Uninformed Search Reading: Chapter 3 by today, Chapter by Wednesday, 9/12 Homework #2 will be given out on Wednesday DID YOU TURN IN YOUR SURVEY?
ICS-271:Notes 6: 1 Notes 6: Game-Playing ICS 271 Fall 2006.
Games & Adversarial Search Chapter 6 Section 1 – 4.
Solving problems by searching
Game Playing: Adversarial Search Chapter 6. Why study games Fun Clear criteria for success Interesting, hard problems which require minimal “initial structure”
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.
Review: Search problem formulation Initial state Actions Transition model Goal state (or goal test) Path cost What is the optimal solution? What is the.
Search: Heuristic &Optimal Artificial Intelligence CMSC January 16, 2003.
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.
Heuristic Search In addition to depth-first search, breadth-first search, bound depth-first search, and iterative deepening, we can also use informed or.
Minimax with Alpha Beta Pruning The minimax algorithm is a way of finding an optimal move in a two player game. Alpha-beta pruning is a way of finding.
Games. Adversaries Consider the process of reasoning when an adversary is trying to defeat our efforts In game playing situations one searches down the.
For Monday Read chapter 4, section 1 No homework..
Review: Tree search Initialize the frontier using the starting state While the frontier is not empty – Choose a frontier node to expand according to search.
Lecture 3: Uninformed Search
Searching for Solutions Artificial Intelligence CMSC January 15, 2008.
GAME PLAYING 1. There were two reasons that games appeared to be a good domain in which to explore machine intelligence: 1.They provide a structured task.
Search CPSC 386 Artificial Intelligence Ellen Walker Hiram College.
Advanced Artificial Intelligence Lecture 2: Search.
Game Playing Revision Mini-Max search Alpha-Beta pruning General concerns on games.
Search (continued) CPSC 386 Artificial Intelligence Ellen Walker Hiram College.
Informed Search Reading: Chapter 4.5 HW #1 out today, due Sept 26th.
Searching for Solutions
ARTIFICIAL INTELLIGENCE (CS 461D) Princess Nora University Faculty of Computer & Information Systems.
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.
Adversarial Search 2 (Game Playing)
CS-424 Gregory Dudek Lecture 10 Annealing (final comments) Adversary Search Genetic Algorithms (genetic search)
Artificial Intelligence in Game Design Board Games and the MinMax Algorithm.
Search CSC 358/ Outline Homework #6 Game search States and operators Issues Search techniques DFS, BFS Beam search A* search Alpha-beta.
Brian Williams, Fall 041 Analysis of Uninformed Search Methods Brian C. Williams Sep 21 st, 2004 Slides adapted from: Tomas Lozano Perez,
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.
CMPT 463. What will be covered A* search Local search Game tree Constraint satisfaction problems (CSP)
Game Search & Constrained Search CMSC Artificial Intelligence January 18, 2005.
Search: Games & Adversarial Search Artificial Intelligence CMSC January 28, 2003.
Chapter 3 Solving problems by searching. Search We will consider the problem of designing goal-based agents in observable, deterministic, discrete, known.
Adversarial Search and Game-Playing
Announcements Homework 1 Full assignment posted..
Last time: search strategies
Artificial Intelligence Problem solving by searching CSC 361
Announcements Homework 3 due today (grace period through Friday)
Artificial Intelligence
Search.
Search.
Games & Adversarial Search
Minimax strategies, alpha beta pruning
Presentation transcript:

Searching for Solutions Artificial Intelligence CSPP January 14, 2004

Agenda Search – Motivation –Problem-solving agents –Rigorous problem definitions Exhaustive search: –Breadth-first, Depth-first, Iterative Deepening –Search analysis:Computational cost, limitations Efficient, Optimal Search –Hill-climbing, A* Game play: Search for the best move –Minimax, Alpha-Beta, Expectiminimax

Problem-Solving Agents Goal-based agents –Identify goal, sequence of actions that satisfy Goal: set of satisfying world states –Precise specification of what to achieve Problem formulation: –Identify states and actions to consider in achieving goal –Given a set of actions, consider sequence of actions leading to a state with some value Search: Process of looking for sequence –Problem -> action sequence solution

Agent Environment Specification ● Dimensions – Fully observable vs partially observable: – Fully – Deterministic vs stochastic: – Deterministic – Static vs dynamic: – Static – Discrete vs continuous: – Discrete ● Issues?

Closer to Reality Sensorless agents (conformant problems) –Replace state with “belief state” Multiple physical states, successors:sets of successors Partial observability (contigency problems) –Solution is tree, branch chosen based on percepts

Formal Problem Definitions Key components: –Initial state: E.g. First location –Available actions: Successor function: reachable states –Goal test: Conditions for goal satisfaction –Path cost: Cost of sequence from initial state to reachable state Solution: Path from initial state to goal –Optimal if lowest cost

Why Search? Not just city route search –Many AI problems can be posed as search What are some examples? How can we formulate the problem?

Basic Search Algorithm Form a 1-element queue of 0 cost=root node Until first path in queue ends at goal or no paths –Remove 1st path from queue; extend path one step –Reject all paths with loops –Add new paths to queue If goal found=>success; else, failure Paths to extend Order of paths added Position new paths added

Basic Search Problem Vertices: Cities; Edges: Steps to next, distance Find route from S(tart) to G(oal) SDAEBCFG

Formal Statement Initial State: in(S) Successor function: –Go to all neighboring nodes Goal state: in(G) Path cost: –Sum of edge costs

Blind Search Need SOME route from S to G –Assume no information known –Depth-first, breadth-first,iterative deepening Convert search problem to search tree –Root=Zero length path at Start –Node=Path: label by terminal node Child one-step extension of parent path

Search Tree SADBDCEDFGEFBGCEABDEFGBFACG

Breadth-first Search Explore all paths to a given depth SADBDAECEEBBFDFBFDEACG

Breadth-first Search Algorithm Form a 1-element queue of 0 cost=root node Until first path in queue ends at goal or no paths –Remove 1st path from queue; extend path one step –Reject all paths with loops –Add new paths to BACK of queue If goal found=>success; else, failure

Analyzing Search Algorithms Criteria: –Completeness: Finds a solution if one exists –Optimal: Find the best (least cost) solution –Time complexity: Order of growth of running time –Space complexity: Order of growth of space needs BFS: –Complete: yes; Optimal: only if # steps= cost –Time complexity: O(b^d+1); Space: O(b^d+1)

Uniform-cost Search BFS: –Extends path with fewest steps UCS: –Extends path with least cost Analysis: –Complete?: Yes; Optimal?: Yes –Time: O(b^(C*/e)); Space: O(b^(C*/e))

Uniform-cost Search Algorithm Form a 1-element queue of 0 cost=root node Until first path in queue ends at goal or no paths –Remove 1st path from queue; extend path one step –Reject all paths with loops –Add new paths to queue –Sort paths in order of increasing length If goal found=>success; else, failure

Depth-first Search Pick a child of each node visited, go forward –Ignore alternatives until exhaust path w/o goal SABCEDFG

Depth-first Search Algorithm Form a 1-element queue of 0 cost=root node Until first path in queue ends at goal or no paths –Remove 1st path from queue; extend path one step –Reject all paths with loops –Add new paths to FRONT of queue If goal found=>success; else, failure

Question Why might you choose DFS vs BFS? –Vice versa?

Search Issues Breadth-first search: –Good if many (effectively) infinite paths, b<< –Bad if many end at same short depth, b>> Depth-first search: –Good if: most partial=>complete, not too long –Bad if many (effectively) infinite paths

Iterative Deepening Problem: –DFS good space behavior Could go down blind path, or sub-optimal Solution: –Search at progressively greater depths: 1,2,3,4,5…..

Question Is this wasting a lot of work?

Progressive Deepening Answer: (surprisingly) No! –Assume cost of actions at leaves dominates –Last ply (depth d): Cost = b^d –Preceding plies: b^0 + b^1+…b^(d-1) (b^d - 1)/(b -1) –Ratio of last ply cost/all preceding ~ b - 1 –For large branching factors, prior work small relative to final ply

Informed and Optimal Search Roadmap –Heuristics: Admissible, Consistent –Hill-Climbing –A* –Analysis

Heuristic Search A little knowledge is a powerful thing –Order choices to explore better options first –More knowledge => less search –Better search alg?? Better search space Measure of remaining cost to goal-heuristic –E.g. actual distance => straight-line distance S D A E BC F G

Hill-climbing Search Select child to expand that is closest to goal S A 10.4 D 8.9 A 10.4 E 6.9 B 6.7 F 3.0 G

Hill-climbing Search Algorithm Form a 1-element queue of 0 cost=root node Until first path in queue ends at goal or no paths –Remove 1st path from queue; extend path one step –Reject all paths with loops –Sort new paths by estimated distance to goal –Add new paths to FRONT of queue If goal found=>success; else, failure

Beam Search Breadth-first search of fixed width - top w –Guarantees limited branching factor, E.g. w=2 S A D BD AE CE BF ACG

Beam Search Algorithm –Form a 1-element queue of 0 cost=root node –Until first path in queue ends at goal or no paths Extend all paths one step Reject all paths with loops Sort all paths in queue by estimated distance to goal –Put top w in queue –If goal found=>success; else, failure

Best-first Search Expand best open node ANYWHERE in tree –Form a 1-element queue of 0 cost=root node –Until first path in queue ends at goal or no paths Remove 1st path from queue; extend path one step Reject all paths with loops Put in queue Sort all paths by estimated distance to goal –If goal found=>success; else, failure

Heuristic Search Issues Parameter-oriented hill climbing –Make one step adjustments to all parameters E.g. tuning brightness, contrast, r, g, b on TV –Test effect on performance measure Problems: –Foothill problem: aka local maximum All one-step changes - worse!, but not global max –Plateau problem: one-step changes, no FOM + –Ridge problem: all one-steps down, but not even local max Solution (local max): Randomize!!

Search Costs

Optimal Search Find BEST path to goal –Find best path EFFICIENTLY Exhaustive search: –Try all paths: return best Optimal paths with less work: –Expand shortest paths –Expand shortest expected paths –Eliminate repeated work - dynamic programming

Efficient Optimal Search Find best path without exploring all paths –Use knowledge about path lengths Maintain path & path length –Expand shortest paths first –Halt if partial path length > complete path length

Underestimates Improve estimate of complete path length –Add (under)estimate of remaining distance –u(total path dist) = d(partial path)+u(remaining) –Underestimates must ultimately yield shortest –Stop if all u(total path dist) > d(complete path) Straight-line distance => underestimate Better estimate => Better search No missteps

Search with Dynamic Programming Avoid duplicating work –Dynamic Programming principle: Shortest path from S to G through I is shortest path from S to I plus shortest path from I to G No need to consider other routes to or from I

A* Search Algorithm Combines good optimal search ideas –Dynamic programming and underestimates Form a 1-element queue of 0 cost=root node Until first path in queue ends at goal or no paths –Remove 1st path from queue; extend path one step –Reject all paths with loops For all paths with same terminal node, keep only shortest –Add new paths to queue –Sort all paths by total length underestimate, shortest first (d(partial path) + u(remaining)) If goal found=>success; else, failure

A* Search Example SAD AE BF G

Heuristics A* search: only as good as the heuristic Heuristic requirements: –Admissible: UNDERESTIMATE true remaining cost to goal –Consistent: h(n) <= c(n,a,n') + h(n')

Constructing Heuristics Relaxation: –State problem –Remove one or more constraints What is the cost then? Example: –8-square: Move A to B if 1) A &B horizontally or vertically adjacent, and 2) B is empty –Ignore 1) -> Manhattan distance –Ignore 1) & 2): # of misplaced squares

Game Play: Search for the Best Move

Agenda Game search characteristics Minimax procedure –Adversarial Search Alpha-beta pruning: –“If it’s bad, we don’t need to know HOW awful!” Game search specialties –Progressive deepening –Singular extensions

Games as Search Nodes = Board Positions Each ply (depth + 1) = Move Special feature: –Two players, adversial Static evaluation function –Instantaneous assessment of board configuration –NOT perfect (maybe not even very good)

Minimax Lookahead Modeling adversarial players: –Maximizer = positive values –Minimizer = negative values Decisions depend on choices of other player Look forward to some limit –Static evaluate at limit –Propagate up via minimax

Minimax Procedure If at limit of search, compute static value Relative to player If minimizing level, do minimax –Report minimum If maximizing level, do minimax –Report maximum

Minimax Search

Minimax Analysis Complete: –Yes, if finite tree Optimal: –Yes, if optimal opponent Time: –b^m Space: –bm (progressive deepening DFS) Practically: Chess: b~35, m~100 –Complete solution is impossible

Minimax Example MAX MIN

Alpha-Beta Pruning Alpha-beta principle: If you know it’s bad, don’t waste time finding out HOW bad May eliminate some static evaluations May eliminate some node expansions

Simple Alpha-Beta Example MAX MIN 27 2 >=2 1 <=1 2

Alpha-Beta Pruning

Alpha-Beta Procedure If level=TOP_LEVEL, alpha = NEGMAX; beta= POSMAX If (reached Search-limit), compute & return static value of current If level is minimizing level, While more children to explore AND alpha < beta ab = alpha-beta(child) if (ab < beta), then beta = ab Report beta If level is maximizing level, While more children to explore AND alpha < beta ab = alpha-beta(child) if (ab > alpha), then alpha = ab Report alpha

Alpha-Beta Pruning Analysis Worst case: –Bad ordering: Alpha-beta prunes NO nodes Best case: –Assume cooperative oracle orders nodes Best value on left “If an opponent has some response that makes move bad no matter what the moving player does, then the move is bad.” Implies: check move where opposing player has choice, check all own moves

Optimal Alpha-Beta Ordering

Optimal Ordering Alpha-Beta Significant reduction of work: –11 of 27 static evaluations Lower bound on # of static evaluations: –if d is even, s = 2*b^d/2-1 –if d is odd, s = b^(d+1)/2+b^(d-1)/2-1 Upper bound on # of static evaluations: –b^d Reality: somewhere between the two –Typically closer to best than worst

Heuristic Game Search Handling time pressure –Focus search –Be reasonably sure “best” option found is likely to be a good option. Progressive deepening –Always having a good move ready Singular extensions –Follow out stand-out moves

Progressive Deepening Problem: Timed turns –Limited depth If too conservative, too shallow If too generous, won’t finish Solution: –Always have a (reasonably good) move ready –Search at progressively greater depths: 1,2,3,4,5…..

Progressive Deepening Question: Aren’t we wasting a lot of work? –E.g. cost of intermediate depths Answer: (surprisingly) No! –Assume cost of static evaluations dominates –Last ply (depth d): Cost = b^d –Preceding plies: b^0 + b^1+…b^(d-1) (b^d - 1)/(b -1) –Ratio of last ply cost/all preceding ~ b - 1 –For large branching factors, prior work small relative to final ply

Singular Extensions Problem: Explore to some depth, but things change a lot in next ply –False sense of security –aka “horizon effect” Solution: “Singular extensions” –If static value stands out, follow it out –Typically, “forced” moves: E.g. follow out captures

Additional Pruning Heuristics Tapered search: –Keep more branches for higher ranked children Rank nodes cheaply Rule out moves that look bad Problem: –Heuristic: May be misleading Could miss good moves

Deterministic Games

Games with Chance Many games mix chance and strategy –E.g. Backgammon –Combine dice rolls + opponent moves Modeling chance in game tree –For each ply, add another ply of “chance nodes” –Represent alternative rolls of dice One branch per roll Associate probability of roll with branch

Expectiminimax:Minimax+Chance Adding chance to minimax –For each roll, compute max/min as before Computing values at chance nodes –Calculate EXPECTED value –Sum of branches Weight by probability of branch

Expecti… Tree

Summary Game search: –Key features: Alternating, adversarial moves Minimax search: Models adversarial game Alpha-beta pruning: –If a branch is bad, don’t need to see how bad! –Exclude branch once know can’t change value –Can significantly reduce number of evaluations Heuristics: Search under pressure –Progressive deepening; Singular extensions