Professional Documents
Culture Documents
Ai - Da 1
Ai - Da 1
Question:
Develop all production for the following water jug problem:
You are given two jugs, 6-gallon one and a 5-gallon one. Neither has any measuring marks
on it. There is a pump that can be used to fill the jugs with water. How can you get exactly 2
gallons of water into a 6-gallon jug?
Answer:
The state space for this problem can be described as the set of ordered pairs of integers (x , y ),
such that x=0,1,2,3,4,5∨6 and y=1,2,3,4∨5 .
x represents the number of gallons of water in the 6-gallon jug.
y represents the number of gallons of water in the 5-gallon jug.
Production rules:
Current state
Rule No. New state Description
with condition
(x , y )
Pour all the water from the 5-gallon
9. if x + y ≤ 6 (x + y , 0)
jug into the 6-gallon jug.
and y >0
(x , y )
Pour all the water from the 6-gallon
10. if x + y ≤ 5 (0 , x+ y)
jug into the 5-gallon jug.
and x >0