Introduction to AI: Midterm Grading Policy and Sample Solution

Introduction to AI: Midterm
Grading Policy and Sample Solution
1. (20 Points)
General AI and Agents (Grader: Yen-Ling Kuo)
For each of the following statements, please briefly argue for or against it.
(a) (4 Points) A computer program can be built to automatically translate from Swahili to Chinese even if none of the programmers speak Swahili.
Grading policy:
• (1 point) Argue FOR it.
• (3 points) Justification.
You should provide at least one idea about how the program works.
Sample solution: For.
The computer program can use statistical method or dictionary to translate from Swahili to
Chinese.
(b) (4 Points) Jack, a program playing Contract Bridge, a card game played by four players in
two competing partnerships with the standard deck of 52 cards, can consistently defeat the
world champion human players.
Grading policy:
• (1 point) Argue AGAINST it.
• (3 points) Justification.
You should provide at least one reason of why Jack will lose.
Sample solution: Against.
Contract Bridge is an stochastic game. Jack can lose if it has bad luck.
(c) (4 Points) There exist task environments in which no pure reflex agent can behave rationally.
Grading policy:
• (1 point) Argue AGAINST it.
• (3 points) Justification.
Sample solution: Against.
By definition (p.37 in AIMA), an agent is rational as long as it selects an action that is
expected to maximize its performance measure for each state. Therefore, an agent can
behave rationally based on its sensory information and belief.
(d) (4 Points) A perfectly rational poker-playing agent never loses.
Grading policy:
• (1 point) Argue AGAINST it.
• (3 points) Justification.
Sample solution: Against.
A rational agent will take actions that maximize its performance measure. However, it still
may lose if its best choice is worse than its opponement’s choice.
(e) (4 Points) A simple thermostat, which turns on the air conditioner when the room temperature is at least 3◦ C above the setting and turns off the AC when the temperature is at least
3◦ C below the setting, is an instance of a simple reflex agent.
Grading policy:
• (1 point) Argue FOR it.
• (3 points) Justification.
You should state the requirements of simple reflex agents this thermostat matches.
Sample solution: For.
Thermostat, the simple reflex agent, behaves according to the rules that matches its sensory
information and state.
1
2. (20 Points)
Search (Grader: Yen-Ling Kuo)
You are given 12 coins, one of which is a counterfeit known to be either heavier or lighter than
the rest. Suppose that you have a two-pan scale, where each pan may hold an arbitrary number
of coins. Your goal is to find the counterfeit coin and determine whether it is light or heavy.
(a) (6 Points) Formulate the problem as a general search problem in terms of its problem states
and operators.
Grading policy:
• (3 points) Define state, including initial and goal state.
• (3 points) Define operators. You need to specify the transition between states.
Sample solution:
•
•
•
•
States: Each coin is marked as light(L), heavy(H), equal(E), or unknown(U).
Initial state: All coins are marked as unknown.
Goal state: One coin is marked as heavy or light. The other coins are marked as equal.
Operators: Choose 2k coins where k is an arbitrary constant. Put k coins in one pan
and the others in another pan. The state transition is to mark the coins according to
the weighting result.
– If their wieght is the same, mark all of them as equal and keep the marks of coins.
– Otherwise, mark coins of heavy side as heavy and the other side as light. If a coin
is marked oppositely in previous state, mark it equal instead.
(b) (4 Points) Please estimate the size of the search space.
Grading policy:
• (2 points) Estimation of size. You can only show the upper bound.
• (2 points) Justification.
Sample solution:
The state size is the number of possible marks of coins: |S| = (# possible marks)(# coins) .
For each state, we can choose to weight the coins on left/right pan or not to weight. Each
coin will be heavy/light, equal, or not changed after weighing. Therefore, the branching
factor b = 3 × 3(# coins) . The search space is at most b|S| , if we do not enter the same state
twice.
(c) (6 Points) Find the shortest solution for identifying the counterfeit.
Grading policy:
• (6 point) Show the solution. You may get partial credits if it is not shortest.
You have to use your formulation to describe the solution.
Sample solution:
If we identify each coin by numbers 1, 2, ..., 12, we can use 3U, 3H, 3L, 3E to denote coin 3
as unknown, heavy, light, equal, respectively. The shortest solution is shown as follows.
First, weigh coins 1U, 2U, 3U, 4U against coins 5U, 6U, 7U, 8U.
(1) If they are equal, weigh coins 9U, 10U against coins 11U and 8E.
i. If they are also equal, weigh coin 12 with any coin to mark it as heavy or light.
ii. If coins 11 and 8 are heavier, mark 11H, 9L, 10L, and 12E. Then, weigh 9 against
10. If they are equal, 11 is heavy; otherwise, mark the heavier coin as equal and the
other one as light.
iii. If coins 11 and 8 are lighter, mark 11L, 9H, 10H, and 12E. Then, weigh 9 against
10. If they are equal, 11 is light; otherwise, mark the heavier coin as heavy and the
other one as equal.
(2) If coins 5, 6, 7, 8 are heavier than coins 1, 2, 3, 4, mark 1L, 2L, 3L, 4L, 5H, 6H, 7H, 8H,
9E, 10E, 11E, and 12E. Then, weigh 1L, 2L, and 5H against 3L, 6H, and 9E.
i. If they are equal, weigh coin 7 and 8 to get the answer.
ii. If the coins 1L, 2L, and 5H are heavier, weigh coin 3 and any coin marked to get
obtain the answer.
iii. If the coins 3L, 6H, and 9E are heavier, weigh coin 1, 2 to obtain the answer.
2
(3) If coins 1, 2, 3, 4 are heavier than coins 5, 6, 7, 8, search can be done similarly as previous
case.
(d) (4 Points) Which search strategy works best for finding the solution in (c)? Why?
Grading policy:
• (2 points) Choose a feasible algorithm.
• (2 points) Justification.
Sample solution: IDS works best in this problem.
Since the shortest solution is at depth 3, BFS and IDS are good choices. However, the large
branching factor may lead to memory problem for BFS. IDS is better in this problem.
3. (20 Points)
Constraint Satisfaction (Grader: Tao-Hsuan Chang)
The objective of the Sudoku puzzle is to fill in the 9 × 9 grid so that every row, every column,
and every 3 × 3 sub-grids contains the digits 1 through 9. Figure 1 shows a sample game and the
corresponding solution.
Figure 1: A sample game of Sudoku and its solution.
(a) (6 Points) Please formulate the game of Sudoku as a constraint satisfaction problem.
Grading policy:
• (2 points) Variables.
• (1 points) Domains.
• (3 points) Constraints.
Sample solution:
• Variables: {Xi,j |i, j ∈ N, 1 ≤ i, j ≤ 9 and (i, j) is empty at start}
• Domains: Xi,j ∈ {1, 2, 3, 4, 5, 6, 7, 8, 9}
• Constraints: For all integers i, j, k, l ∈ [1, 9],
– If i 6= k, then Xi,j 6= Xk,j
– If j 6= k, then Xi,j 6= Xi,k
j−1
k−1
l−1
– If i 6= k or j 6= l, and ⌊ i−1
3 ⌋ = ⌊ 3 ⌋ and ⌊ 3 ⌋ = ⌊ 3 ⌋, then Xi,j 6= Xk,l
(b) (4 Points) Please estimate the size of the search space.
Grading policy:
• (2 points) Estimation of size.
• (2 points) Justification.
Sample solution:
If there is no constraint and duplication checking, the size of the search tree is the number
of possible filling of grids: 99×9 .
(c) (5 Points) Describe an approach to improving the basic backtracking search. (Hint: You may
explain with examples.)
Grading policy:
• (2 points) Describe the approach.
3
• (3 points) Explain how it improves the basic backtracking search.
Sample solution:
Fill in the most constrained variable first, because it can avoid some conflicts to happen. For
example, (7,4) should be chosen before (7,5). Since cell (7,4) is the most constrained variable
(7 is the only valid assignment), we can prune the branch that assign 7 to cell (7,5) earlier
using this approach.
(d) (5 Points) Describe how to solve the problem using hill-climbing, and explain briefly why it
is a good idea or not.
Grading policy:
• (2 points) Describe how to solve Sudoku using hill-climbing.
• (3 points) Explain why it is good or not.
Sample solution:
Fill in all the cells at once and check how many conflicts exist. Then, swap cells that can
eliminate some conflicts.
Since regular Sudoku may have only few solutions, it is not a good idea to solve regular
Sudoku. Also, there may be no single swap that can eliminate the conflicts.
4. (20 Points)
Game Search (Grader: Tao-Hsuan Chang)
Consider the multi-player Pacman game in the maze world with one or more ghosts.
Figure 2: The Multi-agent Pacman Game.
(a) (6 Points) Please describe how the search tree differs from the typical MINMAX game tree;
and how you should modify the MINMAX search to play against three ghosts.
Grading policy:
• (3 points) Description of the search tree.
• (3 points) Modification of MINMAX search.
Sample solution:
There are n MIN layers in each turn of Pacman, where n is the number of ghosts. It is
different from a typical MINMAX game tree which has only 1 MIN layer in each turn.
We should modify the MINMAX search to calculate the results of n MIN layers (the ghost
layer) so that the Pacman can select MAX among the min values.
(b) (4 Points) Please estimate the size of the search space for the multi-player game.
Grading policy:
• (2 points) Estimation of size.
• (2 points) Justification.
Sample solution:
There are L layers in each turn, where L is the number of agents in the game. Assume that
the game will end in T turns and each player can choose UP, DOWN, LEFT, RIGHT, STOP.
Therefore, the search space is 5L×T .
(c) (5 Points) Please define your evaluationFunction of the states. Justify briefly.
Grading policy:
• (2 points) Definition of evaluationFuction.
• (2 points) Justification.
4
Sample solution:
P
manhattan distance(pacman,dot)
One possible evaluationFunction is P manhattan distance(pacman,ghost)
The score of this evaluationFunction is high when the Pacman is close to more dots and
less ghosts. Therefore, using this evaluationFunction, the Pacman will be tend to take
actions that move towards dots and avoid ghosts.
(d) (5 Points) How should you modify the search if your Pacman agent is playing against random
ghosts who choose among legal actions randomly?
Grading policy:
• (2 points) Describe how to modify.
• (3 points) Justification.
Sample solution:
Since the random ghost moves based on some probability distributions, we can calculate the
expectation value of each move and use it as new evaluation score of search algorithm. Using
this expectation value, the Pacman with MINMAX search will take rational actions that
maximize the expected outcome. Therefore, it will perform better than the one using the
original evaluation function.
5. (20 Points)
Short-Answer Questions
(a) (5 Points) Consider the sensorless version of the erratic vacuum world. Draw the belief states
reachable from the initial belief state {1, 3, 5, 7} in one move.
Grading policy: (Grader: Tao-Hsuan Chang)
• (2 points) Belief state.
• (3 points) Transition.
Sample solution:
The sensorless version of the erratic vacuum world:
• When suck applied to a dirty square the action cleans the square and sometimes cleans
up dirt in an adjacent square, too.
• When suck applied to a clean square the action sometimes deposit dirt on the carpet.
Therefore, the initial state and one-move transition can be shown in the following figure.
(b) (5 Points) Describe how the A∗ search and Dijkstra’s shortest path algorithm are similar/different.
Grading policy: (Grader: Tao-Hsuan Chang)
• (2 points) Similarities.
• (3 points) Differences.
Sample solution: Your comparison between the two algorithms may include, but not
restrict to, the node expanding order, the handling of repeated nodes, and the termination
condition.
5
• The similar parts:
– Optimality: Both algorithm find the optimal solution (shortest path) for graphs with
non-negative weights.
• The differences:
– Node expanding order: A∗ uses heuristic function and path cost to calculate fvalue, which can prune more nodes. Dijkstra only uses cost to determine the node
expanding order.
– Handling of repeated nodes (tree search v.s. graph search): The fringe in A∗ search
may contain repeated nodes (which is visited in previous iteration), but Dijkstra’s
algorithm does not visit the same nodes twice.
– Termination condition: A∗ search terminates once it visits the goal state. However,
In Dijkstra’s algorithm, there is no goal state and it continues to traverse until
shortest paths to all nodes are determined.
(c) (5 Points) Describe how ONLINE-DFS-AGENT and LRTA∗ -AGENT are similar/different.
Grading policy: (Grader: Yen-Ling Kuo)
• (2 point) Similarities.
• (3 points) Differences.
Sample solution:
• The similar parts:
– Both algorithms build a map of environment in their result tables.
• The differences:
– ONLINE-DFS-AGENT records the unexplored and back-tracking information, while
LRTA∗ -AGENT records the experience of all state (h(s)).
– ONLINE-DFS-AGENT works only in reversible state space, while LRTA∗ -AGENT
works in all finite, safely explorable environment.
– ONLINE-DFS-AGENT will visit each node twice in worst case, while LRTA∗ -AGENT
has an upperbound O(n2 ), where n is the number of states of the environment.
(d) (5 Points) Name the algorithm that results from each of the following special cases:
•
•
•
•
•
Local beam search with k = 1.
Local beam search with one initial state and no limit on the number of states retained.
Simulated annealing with T=0 at all times (and omitting the termination test).
Simulated annealing with T = ∞ at all times.
Genetic algorithm with population size N = 1.
Grading policy: (Grader: Yen-Ling Kuo)
• (5 points) 1 point per correct answer.
Sample solution:
•
•
•
•
•
Hill climbing.
A∗ .
Hill climbing.
Best-first search.
Stochastic hill climbing.
(e) (Bonus 3 Points) Please give three suggestions for improving the course.
Grading policy:
• (3 points) 1 point per suggestion.
6