Example: Water Jug
Given a 5-gallon jug and a 2-gallon jug, with the 5-gallon jug initially
full of water and the 2-gallon jug empty, the goal is to fill the
2-gallon jug with exactly one gallon of water.
- State = (x,y), where x =
number of gallons of water in the 5-gallon jug and y is gallons in the
2-gallon jug
- Initial State = (5,0)
- Goal State = (*,1), where * means any amount
- Operators
- (x,y) -> (0,y) ; empty 5-gal jug
- (x,y) -> (x,0) ; empty 2-gal jug
- (x,2) and x<=3 -> (x+2,0) ; pour 2-gal into 5-gal
- (x,0) and x>=2 -> (x-2,2) ; pour 5-gal into 2-gal
- (1,0) -> (0,1) ; empty 5-gal into 2-gal
- State Space (also called the Problem Space)
(5,0) = Start
/ \
(3,2) (0,0)
/ \
(3,0) (0,2)
/
(1,2)
/
(1,0)
/
(0,1) = Goal
There are few states, and almost no choice of actions, so the problem is
very easy to search.