CS188: Section Handout 1, Uninformed Search SOLUTIONS

Similar documents
Search then involves moving from state-to-state in the problem space to find a goal (or to terminate without finding a goal).

CSE 573 Problem Set 1. Answers on 10/17/08

Foundations of AI. 3. Solving Problems by Searching. Problem-Solving Agents, Formulating Problems, Search Strategies

Outline for today s lecture Informed Search Optimal informed search: A* (AIMA 3.5.2) Creating good heuristic functions Hill Climbing

Solving Problems by Searching

Foundations of AI. 3. Solving Problems by Searching. Problem-Solving Agents, Formulating Problems, Search Strategies

Problem 1. (15 points) Consider the so-called Cryptarithmetic problem shown below.

Heuristics, and what to do if you don t know what to do. Carl Hultquist

Adversary Search. Ref: Chapter 5

CS 188 Fall Introduction to Artificial Intelligence Midterm 1

Spring 06 Assignment 2: Constraint Satisfaction Problems

mywbut.com Two agent games : alpha beta pruning

Adversarial Search 1

Informed search algorithms. Chapter 3 (Based on Slides by Stuart Russell, Richard Korf, Subbarao Kambhampati, and UW-AI faculty)

COMP9414: Artificial Intelligence Problem Solving and Search

Lecture 2: Problem Formulation

Problem. Operator or successor function - for any state x returns s(x), the set of states reachable from x with one action

Informatics 2D: Tutorial 1 (Solutions)

CS188 Spring 2010 Section 3: Game Trees

UNIVERSITY of PENNSYLVANIA CIS 391/521: Fundamentals of AI Midterm 1, Spring 2010

Spring 06 Assignment 2: Constraint Satisfaction Problems

Problem Solving and Search

Chess Puzzle Mate in N-Moves Solver with Branch and Bound Algorithm

Craiova. Dobreta. Eforie. 99 Fagaras. Giurgiu. Hirsova. Iasi. Lugoj. Mehadia. Neamt. Oradea. 97 Pitesti. Sibiu. Urziceni Vaslui.

Section Marks Agents / 8. Search / 10. Games / 13. Logic / 15. Total / 46

CS61B Lecture #22. Today: Backtracking searches, game trees (DSIJ, Section 6.5) Last modified: Mon Oct 17 20:55: CS61B: Lecture #22 1

UMBC CMSC 671 Midterm Exam 22 October 2012

CMPUT 396 Tic-Tac-Toe Game


Simple Search Algorithms

CSE 40171: Artificial Intelligence. Adversarial Search: Game Trees, Alpha-Beta Pruning; Imperfect Decisions

Heuristics & Pattern Databases for Search Dan Weld

UMBC 671 Midterm Exam 19 October 2009

Homework Assignment #1

Adversarial Search and Game Playing. Russell and Norvig: Chapter 5

Programming Project 1: Pacman (Due )

Adversarial Search. Human-aware Robotics. 2018/01/25 Chapter 5 in R&N 3rd Ø Announcement: Slides for this lecture are here:

ISudoku. Jonathon Makepeace Matthew Harris Jamie Sparrow Julian Hillebrand

COMP219: COMP219: Artificial Intelligence Artificial Intelligence Dr. Annabel Latham Lecture 12: Game Playing Overview Games and Search

General Game Playing (GGP) Winter term 2013/ Summary

: Principles of Automated Reasoning and Decision Making Midterm

More on games (Ch )

Overview PROBLEM SOLVING AGENTS. Problem Solving Agents

CS 171, Intro to A.I. Midterm Exam Fall Quarter, 2016

Games and Adversarial Search II

CS188 Spring 2010 Section 3: Game Trees

Game Tree Search. CSC384: Introduction to Artificial Intelligence. Generalizing Search Problem. General Games. What makes something a game?

Today. Types of Game. Games and Search 1/18/2010. COMP210: Artificial Intelligence. Lecture 10. Game playing

CS510 \ Lecture Ariel Stolerman

Introduction to Algorithms / Algorithms I Lecturer: Michael Dinitz Topic: Algorithms and Game Theory Date: 12/4/14

Informed Search. Read AIMA Some materials will not be covered in lecture, but will be on the midterm.

Introduction Solvability Rules Computer Solution Implementation. Connect Four. March 9, Connect Four 1

ENGR170 Assignment Problem Solving with Recursion Dr Michael M. Marefat

Experimental Comparison of Uninformed and Heuristic AI Algorithms for N Puzzle Solution

Module 3. Problem Solving using Search- (Two agent) Version 2 CSE IIT, Kharagpur

Games (adversarial search problems)

Name: Your EdX Login: SID: Name of person to left: Exam Room: Name of person to right: Primary TA:

CMPT 310 Assignment 1

Searching for Solu4ons. Searching for Solu4ons. Example: Traveling Romania. Example: Vacuum World 9/8/09

In the game of Chess a queen can move any number of spaces in any linear direction: horizontally, vertically, or along a diagonal.

More on games (Ch )

COMP5211 Lecture 3: Agents that Search

Introduction to AI Techniques

Eight Queens Puzzle Solution Using MATLAB EE2013 Project

22c:145 Artificial Intelligence

CS61B Lecture #33. Today: Backtracking searches, game trees (DSIJ, Section 6.5)

Artificial Intelligence Search III

Artificial Intelligence

Game Playing State of the Art

Game-playing: DeepBlue and AlphaGo

Topic 10 Recursive Backtracking

CPS 570: Artificial Intelligence Two-player, zero-sum, perfect-information Games

CS 188: Artificial Intelligence Spring 2007

More Adversarial Search

Artificial Intelligence Uninformed search

Algorithms for Data Structures: Search for Games. Phillip Smith 27/11/13

Game Playing. Why do AI researchers study game playing? 1. It s a good reasoning problem, formal and nontrivial.

Chapter 4 Heuristics & Local Search

CSE373: Data Structure & Algorithms Lecture 23: More Sorting and Other Classes of Algorithms. Nicki Dell Spring 2014

Written examination TIN175/DIT411, Introduction to Artificial Intelligence

Unless stated otherwise, explain your logic and write out complete sentences. No notes, books, calculators, or other electronic devices are permitted.

(Provisional) Lecture 31: Games, Round 2

Informed search algorithms

Monte Carlo Tree Search and AlphaGo. Suraj Nair, Peter Kundzicz, Kevin An, Vansh Kumar

Foundations of Artificial Intelligence

1. Simultaneous games All players move at same time. Represent with a game table. We ll stick to 2 players, generally A and B or Row and Col.

Lecture Notes 3: Paging, K-Server and Metric Spaces

2 person perfect information

CSE 473 Midterm Exam Feb 8, 2018

The 8-queens problem

Solving Problems by Searching

CS 188: Artificial Intelligence. Overview

Local search algorithms

AIMA 3.5. Smarter Search. David Cline

MITOCW R22. Dynamic Programming: Dance Dance Revolution

Conversion Masters in IT (MIT) AI as Representation and Search. (Representation and Search Strategies) Lecture 002. Sandro Spina

Announcements. CS 188: Artificial Intelligence Fall Today. Tree-Structured CSPs. Nearly Tree-Structured CSPs. Tree Decompositions*

8. You Won t Want To Play Sudoku Again

Introduction to Genetic Algorithms

Zoom in on some parts of a fractal and you ll see a miniature version of the whole thing.

Transcription:

Note that for many problems, multiple answers may be correct. Solutions are provided to give examples of correct solutions, not to indicate that all or possible solutions are wrong. Work on following problems in groups of three. Make sure everyone in your group understands problem before moving on to next; you re not necessarily expected to finish all problems. I. Search Space Formulation The n queens problem is a popular problem originally proposed by a chess player in 1848. It requires putting n queens on an n x n chess board such that none of queens is attacking any of or queens. In case you re unfamiliar with chess, a queen can move in any direction for any number of squares: Concretely, picture on right, above, shows a solution to 4 queens problem. Finding a solution to n queens problem can be thought of as a search problem. 1) Formulate n queens as a search problem. This means you should specify: a. Start state: empty board b. Successor function: add a queen to an empty square if doing so results in n or fewer queens c. Search space (what does a valid state in search tree look like): chess board with n or fewer queens, each on a different square d. Goal test: a state is goal if it has exactly n queens and no queen is attacking any or queen (obviously, this can be stated more formally) 2) Like many search problems, n queens problem can be parameterized in a number of different ways to create a valid search problem. Come up with a different way of formulating it as a search problem, specifying same four items as in (1).

Your new formulation shouldn t just change way you encode problem but should also change successor function. Many solutions possible: could make successor function add queens more selectively, creating a more expensive successor function but with fewer valid states 4) Does eir of your search formulations have any advantages over or? Think about this in terms of memory and time requirements, and number of nodes you d expect to expand before finding a solution. Answers will vary different ways of formulating search will result in different branching factors; large branching factors are problematic for search time, especially for BFS 5) N queens can also be solved using recursion. For a little Python practice, write a recursive program to solve n queens. (** Come back to this one after you ve done rest of worksheet or solve it on your own after class.) We assume that we have a function isvalid checks if we can add a queen at (row, col) given a list of current placements of queens (abstracting away chess rule specific part of problem). We n return a list of solutions, where a solution is a list of length n, where ith item in list is column number of queen in row i. def nqueens(n, boardwidth): if n=0: # we re done else: return [[]] return addqueen(n 1, boardwidth, nqueens(n 1, boardwidth) def addqueen(row, boardwidth, solutions): newsolutions = [] for cursol in solutions: for col in range(boardwidth): if isvalid(row, col, cursol): # safe to add a queen at this place in board newsolutions.append(cursol + [col]) return newsolutions

II. Search techniques 2 2 1 4 6 5 Bear's Lair Maia just moved to a new apartment, and has to figure out shortest paths to various places from her new place. 1.) Draw first two levels of search tree for creating a route from to. Assume for all parts of this problem that when we expand a node, successors are ordered alphabetically from left to right. 2.) What happens if we naively try to do depth first tree search for this problem? Infinitely go back and forth between states (search tree has infinite depth)

.) How can we get around problem in (2)? Use graph search; keep a list of nodes we ve already expanded and don t expand m again 4.) Draw search tree for following approaches for finding a route from to, assuming a graph search algorithm, and show only nodes expanded by each search. How many nodes are expanded in each search? What is cost of route found by each search? a. Breadth first search Nodes expanded: 6 Route cost: 8 Bear's Lair b. Depth first search Nodes expanded: 4 Route cost: 12

Bear's Lair c. Greedy search This problem was a bit ill defined it should have had a heuristic given but we hadn t really learned heuristics. The solution below shows expanding node that is closest to an already expanded node this isn t strictly a real heuristic since heuristics must reference goal. The takeaway point for this is that following shortest next path can lead you in to bad spaces in search space and doesn t guarantee that you ll find an optimal path. Nodes expanded: 4 Route cost: 12

d. Uniform cost search Nodes expanded: 6 Route cost: 8 (in this case, UCS is same as BFS this isn t guaranteed!) 5.) Which of above methods techniques found shortest route? Did any find shortest possible route? Are any of m guaranteed to find shortest possible route? Uniform cost search and breadth first search; yes, this is shortest route; UCS is if all costs are > ε 6.) For each search technique, give one pro and one con of using technique. Hint: think about things like optimality, time and space complexity, wher technique is guaranteed to terminate, etc. a. Breadth first search Pro: complete if amount of branching is finite Con: exponential in time and space b. Depth first search Pro: linear space complexity Con: not complete c. Uniform cost search Pro: optimal for costs greater than epsilon Con: like BFS, exponential in time and space III. Formulating problems as search Think of a problem that doesn t involve route planning but that can be formulated as search; for example, can your favorite game be thought of as a search problem? How abut planning your schedule? With your group, pick a problem that seems interesting and come up with: a. The start state b. Successor function c. State space d. How to determine if you re in goal state