In: Computer Science
If you have 4-liter bottle beer A, and 6 another liter of bottle beer B, and you need to measure exactly 2 liters of beer. The only actions you can do is to empty the bottle on the floor and to empty one bottle into the other.
What are the initial state, state space, actions, goal test, path cost and the transition model (not to draw!!!)? The answer should be explained as a text only, without any drawing.
You have 4-liter bottle beer A, and 6 another liter of bottle beer B, and you need to measure exactly 2 liters of beer.
Then what we can do is just through the 4 liter beer from bottle A on the floor and then from bottle B tansfer the beer into bottle A uptill it is filled, the remaining beer left in bottle B is exactly 2 litres of beer.
State Representation and Initial State –
we will represent a state of the problem as a tuple (x, y) where x
represents the 4 litre of beer in bottle A and y represents the 6
litre of beer in bottle B.
Note 0 ≤ x ≤ 4, and 0 ≤ y ≤ 6.
Our initial state: (0,0)
Goal Predicate – state = (x,2) where 0 ≤ x ≤ 4.
Operators – we must define a set of operators that will take us
from one state to another:
1. Empty both the bottles (x,y) -> (0,0)
2. Fill bottle B with 6 litres of beer (x,y) -> (x,6)
3. Fill bottle A with 4 litres of beer from bottle B (x,y) ->
(4,2)
4. New state is (x,y) -> (4,2)
5. Empty 4 litre of beer on ground (x,y) -> (0,2)
6. beer left in bottle B is 2 litres ->ans
Gals in 4-gal jug Gals in 6-gal jug Rule Applied
0 0
1. Fill
6
0 6
2. Pour 6
into 4 to fill
4 2
3.
Remaining amount left in bottle A is 4 litre