Search in AI.

Slides:



Advertisements
Similar presentations
Review: Search problem formulation
Advertisements

An Introduction to Artificial Intelligence
Greedy best-first search Use the heuristic function to rank the nodes Search strategy –Expand node with lowest h-value Greedily trying to find the least-cost.
Traveling Salesperson 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.
Informed Search Methods How can we improve searching strategy by using intelligence? Map example: Heuristic: Expand those nodes closest in “as the crow.
Artificial Intelligence Adversarial search Fall 2008 professor: Luigi Ceccaroni.
ICS-271:Notes 6: 1 Notes 6: Game-Playing ICS 271 Fall 2008.
Artificial Intelligence
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.
Solving Problems by Searching Currently at Chapter 3 in the book Will finish today/Monday, Chapter 4 next.
Branch & Bound Algorithms
CS 484 – Artificial Intelligence1 Announcements Department Picnic: today, after class Lab 0 due today Homework 2 due Tuesday, 9/18 Lab 1 due Thursday,
Chapter 4 Search Methodologies.
Lecture 12 Last time: CSPs, backtracking, forward checking Today: Game Playing.
Search Strategies.  Tries – for word searchers, spell checking, spelling corrections  Digital Search Trees – for searching for frequent keys (in text,
Games CPSC 386 Artificial Intelligence Ellen Walker Hiram College.
Mahgul Gulzai Moomal Umer Rabail Hafeez
CPSC 322 Introduction to Artificial Intelligence October 27, 2004.
CPSC 322 Introduction to Artificial Intelligence October 25, 2004.
All rights reservedL. Manevitz Lecture 31 Artificial Intelligence A/O* and Minimax L. Manevitz.
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.
Using Search in Problem Solving
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.
Using Search in Problem Solving
Problem Solving and Search in AI Heuristic Search
ICS-271:Notes 6: 1 Notes 6: Game-Playing ICS 271 Fall 2006.
Using Search in Problem Solving
1 Tree Searching Strategies. 2 The procedure of solving many problems may be represented by trees. Therefore the solving of these problems becomes a tree.
HEURISTIC SEARCH. Luger: Artificial Intelligence, 5 th edition. © Pearson Education Limited, 2005 Portion of the state space for tic-tac-toe.
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,
Heuristic Search Heuristic - a “rule of thumb” used to help guide search often, something learned experientially and recalled when needed Heuristic Function.
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.
Vilalta&Eick: Informed Search Informed Search and Exploration Search Strategies Heuristic Functions Local Search Algorithms Vilalta&Eick: Informed Search.
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 Chapter 5. Game playing §Search applied to a problem against an adversary l some actions are not under the control of the problem-solver.
October 3, 2012Introduction to Artificial Intelligence Lecture 9: Two-Player Games 1 Iterative Deepening A* Algorithm A* has memory demands that increase.
Heuristic Search In addition to depth-first search, breadth-first search, bound depth-first search, and iterative deepening, we can also use informed or.
State-Space Searches. 2 State spaces A state space consists of A (possibly infinite) set of states The start state represents the initial problem Each.
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..
Lecture 3: Uninformed Search
For Friday Finish chapter 6 Program 1, Milestone 1 due.
State space representations and search strategies - 2 Spring 2007, Juris Vīksna.
Heuristic Search Foundations of Artificial Intelligence.
Knowledge Search CPTR 314.
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)
Artificial Intelligence in Game Design Board Games and the MinMax Algorithm.
CMPT 463. What will be covered A* search Local search Game tree Constraint satisfaction problems (CSP)
Chapter 3 Solving problems by searching. Search We will consider the problem of designing goal-based agents in observable, deterministic, discrete, known.
Lecture 3: Uninformed Search
Adversarial Search and Game-Playing
Announcements Homework 1 Full assignment posted..
Artificial Intelligence Problem solving by searching CSC 361
Alpha-Beta Search.
Alpha-Beta Search.
Introduction to Artificial Intelligence Lecture 9: Two-Player Games I
Alpha-Beta Search.
Alpha-Beta Search.
CS 416 Artificial Intelligence
CMSC 471 Fall 2011 Class #4 Tue 9/13/11 Uninformed Search
Alpha-Beta Search.
Lecture 4: Tree Search Strategies
Presentation transcript:

Search in AI

Towers of Hanoi Solve the problem by finding the appropriate state transitions from a start state to a goal state. A state is a configuration of discs A transition takes us from one state to another via a legal move

Towers of Hanoi Observations Moving the smallest disc The smallest disc can always be moved to two other poles If the smallest disc was moved on the previous move, it does not make sense to move it again because One choice is to move back to where it just was. The other choice was available on the previous move Conclusion: There is never a reason to move the smallest disc twice in a row.

Towers of Hanoi Observations (continued) Moving a disc other than the smallest The disc holding the smallest disc is not a legal destination for a larger disc The largest top-level disc can not be moved, as both possible destinations contain smaller discs Conclusion: If we aren’t moving the smallest disc, there is only one move choice.

Towers of Hanoi Optimization We will always have a choice of two destinations for the smallest disc, followed by a “forced” move of the smaller of the two other top-level discs. We can therefore reduce the possible transitions at any point to two.

The Eight Puzzle Eight puzzle - one start state and one solution state.

Eight puzzle can also have state optimizations Change the goal-state: From to this: To this: 1 2 3 4 5 6 7 8 1 2 3 4 5 7 8 6

From each state there are 8 possible “corner twists.” Rotate clockwise Top-left quadrant Top-right quadrant Bottom-left quadrant Bottom-right quadrant Rotate counter-clockwise

Using state-transition graphs, many of these types of problems become be solved using graph search algorithms. You probably already know some graph-search algorithms Breadth-first search Look at all the possible solutions one move deep, before looking at any possible solutions two moves deep and so on. Depth-first search Try a first move, then another move from that state. When you run out of moves, backtrack to the next available move.

Breadth-first Search Place the root node in a queue While a solution has not been found Remove a state from the queue If that state is not a solution Place all possible transitions from that state into the queue. Positive qualities: With enough resources, the algorithm will find a solution. Negative qualities: Memory requirements and processing times grow exponentially for every move depth where the branching factor is greater than 1.

Depth-first Search Depth-first-search(root) For every transition from the root If the state is not a solution Depth-first-search(transition state) Positive qualities: Memory requirements do not grow exponentially Negative qualities: There is no guarantee that depth-first will find an answer, even if one exists.

Depth-First Search with Iterative Deepening Set the depth limit to 0 While a solution is not found Perform Depth-First Search to the depth limit Increase the depth limit by 1 This algorithm has positive qualities of breadth-first, without the exponential memory costs.

Heuristics-based Search Use a set of rules to evaluate the “quality” of a state. The quality of a state is usually an estimate of how close the state is to the solution.

Sample Heuristics For the 8-puzzle Compute the sum of the minimum number of moves needed to move each tile from its current position its destination

Manhattan Distance – sum of the minimum number of moves each tile must make to get to its destination position 4 must move a minimum of 1 space 1 must move a minimum of 1 space 2 must move a minimum of 1 space 8 must move a minimum of 1 space 7 must move a minimum of 3 spaces 6 must move a minimum of 3 spaces 3 must move a minimum of 3 spaces 5 must move a minimum of 2 spaces Manhattan distance = 1 + 1 + 1 +1 + 3 + 3 + 3 + 2 = 15

Possible (naïve) Heuristic for Towers of Hanoi Number of discs in final position (i.e., on the third pole on top of disc that it is on top of in the solution) – the minimum number of moves to reach a complete solution.

Hill Climbing Make any transition that gets you from your current state to a better state. Do not store any state other than your current state. The value of the state is typically created by a heuristic Examples: 8-Puzzle Make any move that transitions to a state with a lower Manhattan distance. Lost in Hoan Kiem District: Turn onto a different street if it is larger than the street that you are on until you find something that you recognize.

Steepest Ascent Hill Climbing Look at all possible state transitions before selecting the one with the highest value.

Problems with Hill-climbing The heuristic may not be a good measure, or may not work in this instance It is easy to get to a “local maximum” You may not be climbing the highest hill in the search space There is no mechanism for backtracking If you make a wrong turn you may not be able to recover There is no mechanism for detecting cycles

Problems with Hill Climbing (continued) Plateau Problem All transition states might have the same value as the current state.

Best-first Search Maintain a list of nodes (the open list) that we can return to if we take a wrong path Maintain a list of nodes that we no longer need to consider (the closed list) Best-first search While a solution has not been found Remove the node with the best heuristic value from the open list and place it on the closed list For each child of that node, if the node is not already on the closed list, place it on the open list.

Beam-Search Expand the best k nodes on the open list Similar to breadth-first, but each level only has k nodes explored.

Completeness A search algorithm is said to be complete if it is guaranteed to find a solution if a solution exists.

Optimal A search algorithm is said to be optimal if it is guaranteed to find the lowest-cost (best) solution.

Admissible Heuristic An admissible heuristic is one that provides an estimate that is always less than or equal to the actual cost. Admissible heuristics allow us to know that we have found the best answer when the heuristic estimates from all nodes on the open list exceed the value of the current node.

Monotonicity A search algorithm is said to be monotonic if it is guaranteed to produce an optimal path to every intermediate node it generates.

Branch and Bound Create a priority queue sorted on lowest cost Insert root node into priority queue While a solution is not found or the queue contains nodes with a cost less then the solution found Remove a node from the priority queue If it is the best solution found so far, record it Add all the children to the priority queue Return the solution

Principal of Optimality Optimal paths are constructed from optimal subpaths If we find a shorter alternate path to a node we can discard the longer path

Estimating the cost to a goal Let g(x) be the cost from the start state to node x Let h(x) be the cost from x to the goal state The total cost from start to finish, through node x is: f(x) = g(x) + h(x) We do not know h(x). So we create an estimate that we call h*(x) f*(x) = g*(x) + h*(x) is our estimate of f(x)

A* Algorithm Create a priority queue sorted on f*(x) Add the start node to the queue While a solution has not been found Remove a node from the queue Compute f*(x) for all the nodes children (that have not already been encountered) Insert the node’s children into the queue

Assignment Use the C++ code posted on the website to solve the 8-puzzle

Two-Player Games Different search techniques are required to find solutions to two-player, move-based games.

Minimax Trees Alternate between choosing the maximum and minimum values of the child nodes. The “Value of the Game” can be computed using a bottom-up computation of the value of each parent node

Depth of Game-Trees Ideally, all the way to the bottom We can “solve” such games Use some fixed depth and then apply a “static evaluation function” that estimates the value of the game at that node. Use heuristics to determine a depth that is not necessarily uniform e.g., search to a quiescent state

Minimax with alpha-beta pruning If terminal node, return the value of the terminal node If non-terminal For each child Score = alpha-beta(child) If (Score > alpha) alpha

Two types of pruning Alpha cut-off Beta cut-off Happens during min-level analysis The max player will not allow this to happen, so there is no point looking any further Beta cut-off Happens during max-level analysis The min player will not allow this to happen, so there is no point looking any further

Homework Assignment Use the letters in your full name to assign values for the 16 terminal nodes in a binary game tree (lower-case only). If you don’t have 16 letters in your name, just repeat your name j o h n q u e s m i t h j o h n The first player wants to maximize the alphabetic value of the selected letter The second player wants to minimize the alphabetic value of the selected letter Draw the minimax tree and annotate each node with the value of the subtree Show which branches of the tree would be pruned through alpha-beta search Specify whether alpha or beta cutoff was used for each pruning