You are on page 1of 3

9/26/2017 Artificial Intelligence(AI): Water-Jug Problem

More Next Blog abhisheklahoti97@gmail.com Dashboard Sign Out

Artificial Intelligence(AI)
CS6659 - AI Notes

Syllabus Unit -I Unit -II Unit-III Unit - IV Unit - V Lecture Videos - Collection 1

Lecture Videos - Collection 2 Lecture Videos - Collection 3

Pages

Water-Jug Problem Assignment & CaseStudy


Check Yourself - questions(UNIT-I)
Water Jug Problem:
check yourself-III with answers
Check yourself -II
Problem: You are given two jugs, a 4-gallon one and a 3-gallon one.Neither has
Check urself-IV
any measuring mark 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 the 4-gallon jug. Check urself - V
Algorithms
Solution: Lecture Videos - Collection 1
The state space for this problem can be described as the set of ordered pairs of Lecture Videos - Collection 2
integers (x,y) Lecture Videos - Collection 3
Where,
X represents the quantity of water in the 4-gallon jug X= 0,1,2,3,4
Y represents the quantity of water in 3-gallon jug Y=0,1,2,3
Start State: (0,0)
Goal State: (2,0)
Generate production rules for the water jug problem
Production Rules:
Rule State Process
1 (X,Y | X<4) (4,Y)
{Fill 4-gallon jug}
2 (X,Y |Y<3) (X,3)
{Fill 3-gallon jug}
3 (X,Y |X>0) (0,Y)
{Empty 4-gallon jug}
4 (X,Y | Y>0) (X,0)
{Empty 3-gallon jug}
5 (X,Y | X+Y>=4 ^ (4,Y-(4-X))
Y>0) {Pour water from 3-gallon jug into 4-gallon
jug until 4-gallon jug is full}
6 (X,Y | X+Y>=3 (X-(3-Y),3)
^X>0) {Pour water from 4-gallon jug into 3-gallon
jug until 3-gallon jug is full}
7 (X,Y | X+Y<=4 (X+Y,0)
^Y>0) {Pour all water from 3-gallon jug into 4-
gallon jug}
8 (X,Y | X+Y <=3^ (0,X+Y)
X>0) {Pour all water from 4-gallon jug into 3-
gallon jug}
9 (0,2) (2,0)
{Pour 2 gallon water from 3 gallon jug into 4
gallon jug}

Initialization:
Start State: (0,0)
Apply Rule 2:
(X,Y | Y<3) -> (X,3)
{Fill 3-gallon jug}
Now the state is (X,3)

Iteration 1:
Current State: (X,3)
Apply Rule 7:
(X,Y | X+Y<=4 ^Y>0) (X+Y,0)
{Pour all water from 3-gallon jug into 4-gallon jug}
Now the state is (3,0)

Iteration 2:
Current State : (3,0)
Apply Rule 2:
(X,Y | Y<3) -> (3,3)
{Fill 3-gallon jug}

http://aimaterials.blogspot.in/p/blog-page_18.html 1/3
9/26/2017 Artificial Intelligence(AI): Water-Jug Problem
Now the state is (3,3)

Iteration 3:
Current State:(3,3)
Apply Rule 5:
(X,Y | X+Y>=4 ^ (4,Y-(4-X))
Y>0) {Pour water from 3-gallon jug into 4-gallon jug until 4-
gallon jug is full}
Now the state is (4,2)

Iteration 4:
Current State : (4,2)
Apply Rule 3:
(X,Y | X>0) (0,Y)
{Empty 4-gallon jug}
Now state is (0,2)

Iteration 5:
Current State : (0,2)
Apply Rule 9:
(0,2) (2,0)
{Pour 2 gallon water from 3 gallon jug into 4 gallon
jug}
Now the state is (2,0)

Goal Achieved.

State Space Tree:

4 comments:

Hitesh Verma 26 September 2016 at 10:23


nice
Reply

http://aimaterials.blogspot.in/p/blog-page_18.html 2/3
9/26/2017 Artificial Intelligence(AI): Water-Jug Problem

dineshtak 8 April 2017 at 10:24


nice sir
thanx
Reply

SimpleMaryam 28 June 2017 at 01:09


Tank you
Reply

SimpleMaryam 28 June 2017 at 01:12


Tank you
Reply

Enter your comment...

Comment as: Abhishek Lahoti (Google) Sign out

Publish Preview Notify me

Home

Subscribe to: Posts (Atom)

Simple theme. Theme images by luoman. Powered by Blogger.

http://aimaterials.blogspot.in/p/blog-page_18.html 3/3

You might also like