0% found this document useful (0 votes)
32 views5 pages

State Space Representation Example

The problem involves transporting 3 missionaries and 3 cannibals across a river using a boat that holds 2 people. The initial state has all people on the left bank and the goal is to get them all to the right bank safely. States are represented as lists showing who is on each bank and whether the boat is there. Operators move 1 or 2 people or a missionary and cannibal together between banks if it keeps cannibals from outnumbering missionaries at any location. A solution sequence of operators is provided.

Uploaded by

patelhemv1143
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views5 pages

State Space Representation Example

The problem involves transporting 3 missionaries and 3 cannibals across a river using a boat that holds 2 people. The initial state has all people on the left bank and the goal is to get them all to the right bank safely. States are represented as lists showing who is on each bank and whether the boat is there. Operators move 1 or 2 people or a missionary and cannibal together between banks if it keeps cannibals from outnumbering missionaries at any location. A solution sequence of operators is provided.

Uploaded by

patelhemv1143
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Water Jug Problem in Artificial Intelligence – State Space Search

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.

Production rules for solving the water jug problem

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.

Objects of the State World:


MMMCCCB
3 missionaries, 3 cannibals, 1 boat, a left river bank, and a right river bank.
C represents a cannibal, M represents a missionary, and B represents the location
of the boat.

Representation of a State of the World:


L<M C B> R<M C B>
A state of the world is represented as 2 lists :
L is the left bank.
R is the right bank.
C represents the location’s amount of cannibals.
M represents the location's amount of missionaries.
B is 1 when the boat is on the shore and 0 when it is on the opposite shore.
The State Space Description:
Initial State: Goal State:
L<3 3 1> R<0 0 0> L<0 0 0> R<3 3 1>

State Space Operands:


1 Cannibal goes left:
L1C L< M C B > R< M C B > => L< M (C-1) (B-1) > R< M (C+1) (B+1) >

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) >

1 Missionary goes left:


L1M L< M C B > R< M C B > => L< (M-1) C (B-1) > R< (M+1) C (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) >

1 Cannibal goes right:


R1C L< M C B > R< M C B > => L< M (C+1) (B+1) > R< M (C-1) (B-1) >

2 Cannibals goes right:


R2C L< M C B > R< M C B > => L< M (C+2) (B+1) > R< M (C-2) (B-1) >

1 Missionary goes right:


R1M L< M C B > R< M C B > => L< (M+1) C (B+1) > R< (M-1) 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) >

1 Cannibal and 1 Missionary go left:


LMC L< M C B > R< M C B > => L< (M-1) (C-1) (B-1) > R< (M+1) (C+1) (B+1) >

1 Cannibal and 1 Missionary go right:


RMC L< M C B > R< M C B > => L< (M+1) (C+1) (B+1) > R< (M+1) (C+1) (B+1) >
State Space Graph (Including At Least One Solution):

<R2C L1C R2C L1C R2M LMC R2M L1C R2C L1C R2C>

You might also like