• Tidak ada hasil yang ditemukan

Introduction to AI: Assignment 1 EXAMPLE SOLUTIONS Due

N/A
N/A
Protected

Academic year: 2025

Membagikan "Introduction to AI: Assignment 1 EXAMPLE SOLUTIONS Due"

Copied!
3
0
0

Teks penuh

(1)

EECS 492: Introduction to Artificial Intelligence March 7, 2002

Introduction to AI: Assignment 1 EXAMPLE SOLUTIONS Due: 8 March, 12:00 Noon (via hardcopy or email)

In this assignment, you will get experience formalizing a problem in a manner that will allow automated problem-solving.

Here is the problem, known as the Missionaries and Cannibals problem:

At a remote island in the Pacific, a group of people is trying to reach the coast to be rescued. The group consists of 3 missionaries and 3 cannibals.

The group has encountered a problem: their path is blocked by a wide, deep river. Fortunately for them, they have found a boat on their bank of the river, but the boat can only fit at most two people at a time.

The problem is to come up with a sequence of river crossings that get all the people safely to the other side. The boat cannot cross the river without someone in it (to paddle it). For example, if 2 people cross on the boat at the outset, then one of them will have to come back to the original side to bring the boat back to pick up others. Furthermore, the cannibals should never outnumber the missionaries on either side of the river (counting whomever is in the boat when the boat is on that side).

Task 1:

Develop a representation for a state in this problem. Justify your decisions about what should be represented and what should not be.

This problem has 3 missionaries, say M1, M2, and M3. It has 3 cannibals, C1, C2, and C3. It has a boat B. And it has a river. The important thing to represent is the missionaries and cannibals on each side of the river, as well as which side of the river the boat is on. However, the identities of the missionaries and cannibals is unimportant: a state where M1 and C1 have crossed looks the same as the state where M2 and C3 have crossed.

(2)

EECS 492: Introduction to Artificial Intelligence March 7, 2002

Given all of the above, I would choose the following for a representation:

(m, c, b)

where m is the number of missionaries on the initial bank, c is the number of cannibals on the initial bank, and b is the number of boats on the initial bank. Obviously, m and c can each be a number between 0 and 3, and b can either be 0 or 1.

Task 2:

Show the initial state, and also the goal state(s), in your representation.

There is one initial state, of course. In my representation it would be:

(3, 3, 1).

There are two states that would satisfy the goal: (0, 0, 0) and (0, 0, 1). Note that the second of these would not be reachable though.

Task 3:

How many different states could be represented based on your answer to task 1?

Given my answer to task 1: m could have a value between 0 and 3, so 4 possible values. So could c. b can have 2 possible values. So, altogether, I could represent as many as 4 x 4 x 2 = 32 states. Some of these of course will violate constraints, but they could be represented.

Task 4:

Define all the legal operators for this problem based on the above description, indicating which state(s) each applies to and what state(s) arise from each. Try to write each operator so that it applies to more than one specific state (otherwise, you’ll probably have to write quite a few operators!).

There are a total of 10 possible operators. One cannibal can take the boat from the starting bank to the destination bank. Or one missionary can. Or

(3)

EECS 492: Introduction to Artificial Intelligence March 7, 2002

two cannibals can. Or two missionaries can. Or one of each. And then there are the equivalent operators going back the other way.

Defined according to my representation:

(m, c, 1) -> (m, c-1, 0) if c > 0 and (m=0 or m=3).

(m, c, 1) -> (m-1, c, 0) if m = 1 or (m = 3 and c > 1) (m, c, 1) -> (m, c-2, 0) if c > 1 and m ≠ 2.

(m, c, 1) -> (m-2, c, 0) if m > 1 and m + c = 4.

(m, c, 1) -> (m-1, c-1, 0) if m > 0 and m = c.

The inverses are similarly defined, such as:

(m, c, 0) -> (m, c+1, 1) if c < 3 and c ≠ m.

etc.

Task 5:

Given your previous answers and any further analysis that you want to do: if there is a solution to this problem, what would be the

maximum number of operator applications (the maximum path length) that the shortest solution would need in order to get from the initial state to the goal state? Justify your answer. (Note, this should be based only on your analysis of the problem and the state space;

you shouldn’t solve the problem and then use that as an answer!) Well, in the worst case, we’d have to visit all 32 states, or take 31 steps between the initial state and the goal state. But of course, we know that 2 of those states are impossible to reach: (3, 3, 0) and (0, 0, 1). And of the

remaining ones, it is easy to see that 12 are illegal: (1, 2, x), (1, 3, x) (2, 3, x), (1, 0, x), (2, 0, x) and (2, 1, x) (where x can be 0 or 1). Altogether, then, that leaves 32 – 14 = 18 states, so a maximum of 17 steps. So the longest a possible solution would be is 17 steps, based on this analysis.

Referensi

Dokumen terkait