0
54kviews
Explain Water Jug problem with State Space Search method.
1 Answer
2
7.9kviews
written 6.3 years ago by |
The operators to be used to solve the problem can be describes as shown below. They are represented as rules whose left side are matched against the currnent state and whose right side describes the new state that results from applying the rules.
We have two jugs a 4 gallon and a 3 gallon.
Consider the following Rule set:
- (x,y)->(4,y) fill the 4 gallon jug
If x<4.
- (x,y)->(x,3) fill the 3 gallon jug
If x<3
- (x,y)->(x-d,y) pour some water out of the 4-gallon jug.
If x>0
- (x,y)->(x-d,y) pour some water out of the 3-gallon jug.
If y>0
- (x,y)->(0,y) empty the 4-gallon jug on the ground
If x>0
- (x,y)->(x,0) empty the 3-gallon jug on the ground
If y>0
- (x,y)->(4,y-(4-x)) pour water from the 3-gallon jug into the 4-gallon
If x+y>=4 and y>0 jug until the 4-gallon jug is full
- (x,y)->(x-(3-y),3)) pour water from the 4-gallon jug into the 3-gallon
If x+y>=3 and x>0 jug until the 3-gallon jug is full.
- (x,y)->(x+y,0) pour all the water from the 3-gallon jug into
If x+y<=4 and y>0 the 3-gallon jug.
- (x,y)->(0,x+y) pour all the water from the 4-gallon jug into
If x+y<=3 and x>0 the 3-gallon jug.
(0,2)->(2,0) pour the 2-gallon from the 3-gallon jug into the 4-gallon jug.
(2,y)->(0,x) empty the 2 gallon in the 4 gallon on the ground.
Production of the water jug problem:
ADD COMMENT
EDIT
Please log in to add an answer.