Unformatted text preview: CS188: Artiﬁcial Intelligence, Fall 2008
Written Assignment 1
CS188 Fall 2010Due: September 11th at the beginning of lecture
Section 1: Search
11 Search Search Strategies
Graph algorithms in action
A
h=2 Goal 2 2
4 Start C
h=2 5 5 1 3
B
h=5 D
h=1 4 Our intrepid hero, Search Agent, is late for her artiﬁcial intelligence class and states get there fast! The
For each of the following graph search strategies, work out the order in whichneeds toare expanded, as well
graph above represents graph search. In all cases, assume ties resolve diﬀerent parts of campus. For earlier
as the path returned by how long it takes Search Agent to walk betweenin such a way that states with each
of the following graph search strategies, work out the order in which states are expanded, well as the path
alphabetical order are expanded ﬁrst. The start and goal state are S and G, respectively.asRemember that in
returned by a state is expanded only assume ties resolve in such a way that states with earlier alphabetical
graph search, graph search. In all cases,once.
order are expanded ﬁrst. The start and goal state are S and G, respectively. Remember that in graph search,
a state is expanded only once.
(a) Depthﬁrst search.
a) Expanded: Search
StatesDepthFirst Start, A, C, D, B, Goal
Path Returned: StartACDGoal
b) Breadth First Search
(b) Breadthﬁrst search.
States Expanded: Start, A, B, D, C, Goal
Path Returned: StartDGoal
c) UniformCost Search
(c) Uniform cost search.
States Greedy search with the heuristic values listed at each state.
d) Expanded: Start, A, B, D, C, Goal
Path Returned: StartACGoal
e) A∗ search with the the heuristic h listed on the state.
(d) Greedy search with heuristic values shown at each graph.
States Expanded: Start, D, Goal
Path Returned: StartDGoal (e) A search with the same heuristic.
States Expanded: Start, A, D, B, C, Goal
Path Returned: StartACGoal 1 2 nQueens Max Friedrich William Bezzel invented the eight queens puzzle in 1848: place 8 queens on a chess board such
that none of them can capture any other. The problem, and the generalized version with n queens, has been
studied extensively (a Google Scholar search turns up over 3500 papers on the subject). Queens can move any number of squares along rows, columns, and diagonals (left); An example
solution to the 4queens problem (right). a) Formulate nqueens as a search problem, using the following statespace representation of: a set of boards,
in which each space on the board may or may not contain a queen.
Start State: An empty board
Successor Function: Return all boards with one more queen placed anywhere
Goal Test: Returns True iﬀ n queens are on the board such that no two can attack each other b) 2 How large is the state space in your formulation? 2n , or 18, 446, 744, 073, 709, 551, 616 for 8queens. c) One way to limit the size of your state space is to limit what your successor function returns. Reformulate
your successor function to reduce the eﬀective statespace size. The successor function is limited to return legal
boards. Then, the goal test need only check if the board has n queens. d) How large is the state space in your formulation with an eﬃcient successor function? There are n2 choices
for the ﬁrst queen, n2 − 1 choices for the second queen, and so on. But, order doesnt matter. So we have
n2 !
(n2 −n)!n! . Thats 4,426,165,368 possible boards for the 8queens problem. e) Give a more eﬃcient state space representation. How large is the state space, with and without an eﬃcient
successor function? A more eﬀective representation is to have a ﬁxed ordering of queens, such that the queen
in the ﬁrst column is placed ﬁrst, the queen in the second column is placed second, etc. The representation could
be a nlength vector, in each each entry takes a value 1n, or “null”. Without an eﬃcient successor function,
we have n choices for each queen, so the total state space is nn (16, 777, 216 with 8queens). Using an eﬃcient
successor function, for the ﬁrst queen, we have n choices, for the second we have n − 1, etc, so the total state
space is n! (40, 320 for 8queens). 2 3 15puzzle The puzzle involves sliding tiles until they are ordered correctly. To solve these puzzles eﬃciently with A*
search, good heuristics are important. (1) Create a heuristic for the 15puzzle based on the number of misplaced tiles.
Count the number of tiles out of place, not including the blank tile. (2) Create a heuristic using Manhattan distance.
Sum the Manhattan (city block) distances between each tile’s current position and its intended position. (3) Explain why your heuristics are admissible.
These heuristics are both relaxations of the original rpoblem so the heuristic estimate is always less than or
equal to the actual cost of reaching the goal. Note that if you include the blank tile in the estimate, this heuristic
is no longer admissible (think about the case where only 1 tile is out of place). 3 ...
View
Full Document
 Spring '08
 Staff
 Artificial Intelligence, Algorithms, The Queen, Eight queens puzzle, successor function

Click to edit the document details