CS400 Assignment 20

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Assignment 2

Due Date 22/ 10/18


Question 1

The “water jug problem” can be stated as follows: you are given two jugs, one that can hold 4 gallons of water
and the other that can hold 3 gallons of water. You also have a pump that can be used to fill either jug with
water, and you can empty the contents of either jug at any time. You goal is to get exactly 2 gallons of water
into the four-gallon jug.

a) State this problem in terms of state-space search. Describe the state, the move-generator, the goal
checker. (You can do this in Lisp if you want, or in some other computer language, or in pseudo-code, or
in English as long as you are precise.) Suggest a heuristic for guiding the search for a solution. [15]
b) Prolog
animal(X) :- bird(X).
animal(X) :- mammal(X).
animal(X) :- snake(X).

bird(X) :- robin(X).
bird(X) :- eagle(X).
mammal(X) :- cat(X).

snake(X) :- wormsnake(X).

fears(X,Y) :- bird(X), snake(Y).


fears(X,Y) :- mammal(X), snake(Y).

eats(X,Y) :- eagle(X), snake(Y).


eats(X,Y) :- eagle(X), robin(Y).
eats(X,Y) :- snake(X), cat(Y).
eats(X,Y) :- snake(X), robin(Y).
eats(X,Y) :- cat(Y), robin(Y).

robin(opus).
eagle(flier).
wormsnake(slyth).
cat(bill).
Deduce the answers to the following queries. Justify.
i. ?- eats(flier, opus)? [2]
ii. ?- fears(bill, X).? [2]
iii. ?- eats(X, Y), snake(X). [3]
iv. ?- bird(Y). [3]
Question 2
a) The Missionaries and Cannibals problem is a classic brainteaser. It is a member of a class of river-crossing
brainteasers that includes Farmer to Market, Jealous Husbands, and others Three missionaries and three
cannibals must cross a river using a boat which can carry at most two people. The constraint is that, for
both river banks, if there are missionaries present on the bank, they cannot be outnumbered by cannibals (if
they were, the cannibals would eat the missionaries). The boat cannot cross the river by itself without
people on board.
b) How can all six people get safely across the river? [6]
c) What is the maximum branching factor counting Both allowed and forbidden states as children
[4]
d) Draw the state space showing ONLY the ALLOWED states. I.e., do NOT show the FORBIDDEN states.
Represent an allowed state as a circle enclosing its state vector (M,C,B). Connect allowed states that are
possible successors of each other. The start and goal states are shown. The first node expansion is done for
you as an example. [6]

Question 3

a) Consider the following Bayesian network, where F = having the flu and C = coughing:

i. Write down the joint probability table specified by the Bayesian network. [10]
ii. Determine the probabilities for the following Bayesian network

so that it species the same joint probabilities as the given one. [5]

You might also like