Write the Python code to solve the water jug problem. Change from an initial state of 4 gallons in a 5-gallon jug and 2 gallons in a 3-gallon jug to a final state of 1 gallon in a 5-gallon jug and none in a 3-gallon jug. You can use the following operators: empty_big, empty_small, big_is_empty, and small_is_empty as shown in the attached image. Also, use a tree model to find the solution path as shown in the figure. Write the solution path as shown in the figure.
Water Jug Problem (Cont.)
Operators:
Pre-cond Post-cond b > 0 (0, s) s > 0 (b, 0)
Init: 5, 2 goal: 1, 0
1. empty big 2. empty small 3. big is empty 4. small is empty
52
b = 0, s > 0 s = 0 b > 0, s = 0 (b - 2, 2 if b > 2 0, b) b < 2
(0, 2)
5, 0
(2, 0)
Solution path: 2.4.2, 4, 2
1, 0