State Space Representation Example
State Space Representation Example
We are given two jugs, a 4-gallon one and 3-gallon one. Neither has any measuring
marked on it. There is a pump, which can be used to fill the jugs with water. How can we
get exactly 2 gallons of water into 4-gallon jug?
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 or 4 and Y = 0, 1, 2 or 3; X is the number of gallons of
water in the 4-gallon jug and Y the quantity of water in the 3-gallon jug.
The start state is (0, 0) and the goal state is (2, n) for any value of n, as the problem
does not specify how many gallons need to be filled in the 3-gallon jug (0, 1, 2, 3). So
the problem has one initial state and many goal states. Some problems may have many
initial states and one or many goal states.
In order to describe the operators completely here are some assumptions, not
mentioned, in the problem state.
1. We can fill a jug from the pump.
2. We can pour water out a jug, onto the ground.
3. We can pour water out of one jug into the other.
4. No other measuring devices are available.
All such additional assumptions need to be given when converting a problem statement
in English to a formal representation of the problem, suitable for use by a program.
Here, let x denote the 4-gallon jug and y denote the 3-gallon jug.
The listed production rules contain all the actions that could be performed by the
agent in transferring the contents of jugs.
There are several sequences of operators which will solve the problem, two such
sequences are shown in below table,
Modeling Challenge : Missionaries and
Cannibals State Space Problem Solver
Problem:
Three missionaries and three cannibals, along with one boat that fits at most two
people ( and requires at least one for operation), are on the left bank of a river. The
most salient thing about missionaries and cannibals in “cohabitation” is that if ever
the cannibals in any one spot (left bank, right bank, on the boat outnumber the
missionaries, the outnumbered missionaries will be consumed – eaten! The goal of
this problem is to get all six individuals safely across the river from the left bank to
the right bank.
2 Cannibals go left:
L2C L< M C B > R< M C B > => L< M (C-2) (B-1) > R< M (C+2) (B+1) >
2 Missionaries go left:
L2M L< M C B > R< M C B > => L< (M-2) C (B-1) > R< (M+2) C (B+1) >
2 Missionaries go right:
R2M L< M C B > R< M C B > => L< (M+2) C (B+1) > R< (M-2) C (B+1) >
<R2C L1C R2C L1C R2M LMC R2M L1C R2C L1C R2C>