0% found this document useful (0 votes)
24 views23 pages

Lecture 7

Uploaded by

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

Lecture 7

Uploaded by

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

Classic AI Problems:

Vacuum cleaner problem


Water Jug problem
The Farmer ,Wolf ,Goat,and Cabbage Problem
8 puzzle problem
A travelling salesman problem
Tower of Hanoi
Monkeys and bananas
Chess etc
Problem Statement:
This particular world has just two locations:
 Squares A
 Square B.
The vacuum agent perceives which square it is in and
whether there is dirt in the square.
 It can choose to
 move left,
 move right,
 suck up the dirt,
 Do nothing.
Possible Actions:
One very simple agent function is the
following:
if the current square is dirty, then suck,
otherwise move to the other square.
Problem Formulation:
 States:
 The agent is in one of two locations, each of which might or
might not contain dirt.
 Thus there are 2 x 22 = 8 possible world states.

 Initial state:
 Any state can be designated as the initial state.

 Successor function:
 This generates the legal states that result from trying the
three actions (Left, Right, and Suck).
Problem Formulation:
 Goal test:
This checks whether all the squares are clean.

Path cost:
Each step costs 1, so the path cost is the
number of steps in the path.
Vacuum Agent Function
Vacuum World State Space Graph:
Problem Statement:
We are given 2 jugs, a 4 liter one and a 3-
liter one. Neither has any measuring markers
on it.
 There is a pump that can be used to fill the
jugs with water.
How can we get exactly 2 liters of water in to
the 4-liter jugs?
Problem Formulation:
The state space for this problem can be defined as

{ ( i ,j ) i = 0,1,2,3,4 j = 0,1,2,3}

‘i’ = the number of liters of water in the 4-liter jug


‘j’ = the number of liters of water in the 3-liter jug.
The initial state is ( 0,0) that is no water on each
jug.
The goal state is to get ( 2,n) for any value of ‘n’.
Assumptions:
 To solve this we have to make some assumptions not
mentioned in the problem. They are:

1. We can fill a jug from the pump.

2. we can pour water out of a jug to the ground.

3. We can pour water from one jug to another.

4. There is no measuring device available.


The Water Jug Problem
 The water jug problem is another famous AI problem where you are given two jugs
with fixed capacities and an unlimited water supply. The goal is to measure out a
specific amount of water using these two jugs.
 Problem Setup
 Jug 1 Capacity: 4 liters.
 Jug 2 Capacity: 3 liters.
 Goal: Measure out exactly 2 liters of water.
Operations (Actions):
 You can perform the following operations:

 Fill a jug: Fill one of the jugs completely from the water supply.

 Empty a jug: Pour all the water out of a jug.

 Pour water from one jug to another: Transfer water from one jug to another,
either until the first jug is empty or the second jug is full.
Search Techniques:
 This can be formulated as a search problem where:
 State: The amount of water in Jug 1 and Jug 2 (represented as a pair, e.g., (3, 0)
means Jug 1 has 3 liters and Jug 2 has 0 liters).
 Initial State: (0, 0), both jugs are empty.
 Goal State: (2, x), where Jug 1 has 2 liters (x can be any amount in Jug 2).
 You can use Breadth-First Search (BFS) or Depth-First Search (DFS) to explore all
possible states. Alternatively, A* with a heuristic that estimates how close you are
to the 2 liters in Jug 1 can also be applied.
Solution Example:
1. Fill Jug 2: (0, 3)

2. Pour Jug 2 into Jug 1: (3, 0)

3. Fill Jug 2 again: (3, 3)

4. Pour Jug 2 into Jug 1 until Jug 1 is full: (4, 2)

5. Empty Jug 1: (0, 2)

 Now Jug 1 has exactly 2 liters, and you have reached the goal.
Production Rules:
Sr. Current State Next State Descriptions
1 (x,y) if x < 4 (4,y) Fill the 4 gallon jug
2 (x,y) if x < 3 (x,3) Fill the 3 gallon jug
3 (x,y) if x > 0 (x – d, y) Pour some water out of the 4 gallon jug
4 (x,y) if y > 0 (x, y – d) Pour some water out of the 3 gallon jug
5 (x,y) if y > 0 (0, y) Empty the 4 gallon jug
6 (x,y) if y > 0 (x 0) Empty the 3 gallon jug on the ground
7 (x,y) if x + y > = 4 (4, y – (4 – x)) Pour water from the 3 gallon jug into the
and y > 0 4 gallon jug until the 4 gallon jug is full
8 (x,y) if x + y > = 3 (x – (3 – x), 3) Pour water from the 4 gallon jug into the
and x > 0 3 gallon jug until the 3 gallon jug is full
9 (x,y) if x + y < = 4 (x + y, 0) Pour all the water from the 3 gallon jug
and y > 0 into the 4 gallon jug
10 (x,y) if x + y < = 3 (0, x + y) Pour all the water from the 4 gallon jug
and x > 0 into the 3 gallon jug
11 (0, 2) (2, 0) Pour the 2 gallons from 3 gallon jug into
the 4 gallon jug
12 (2, y) (0, y) Empty the 2 gallons in the 4 gallon jug
on the ground
Possible Solutions:

Solution 1
Solution 2
Solution 3
Analysis of Solution:
We see that, when there is no limit for water
prevails then solution is the most efficient.
When water is limited then Solution 2 is the
best suited.
In no way solution 3 is good, Because it
requires 8 steps for solution and wastes 5
liters of water.

You might also like