0% found this document useful (0 votes)
12 views24 pages

Ai Expbm 3

PPT ON AI

Uploaded by

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

Ai Expbm 3

PPT ON AI

Uploaded by

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

MODULE - I

EXAMPLE AI-PROBLEMS

20MCA188 ARTIFICIAL
INTELLIGENCE (Elective-2) Selma Joseph A.
EXAMPLE PROBLEMS
The vacuum cleaner world
Description
This world has just two locations: squares A and 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, or do nothing. One very simple
agent function is the following: if the Standard formulation
• otherwise,
current square is dirty, then suck; States : The
movestate is determined
to the by
other square.
both the agent location and the dirt
locations. 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
• Actions : In this simple environment, eachasstate
the initial state.
has just three
actions: Left, Right,
and Suck.
• Transition model : The actions have their expected effects, except
that moving Left
in the leftmost square, moving Right in the rightmost square, and
Sucking in a clean
The state space for the vacuum world. Links denote actions:
L = Left, R =Right, S = Suck.
8-PUZZLE PROBLEM
Description
The 8-puzzle consists of a 3 x 3 board with eight numbered tiles and a
blank space. A tile
adjacent to the blank space can slide into the space. The
Standard objective is to
formulation
reach a specified
goal state. States: A state description
specifies the location of each of
the eight tiles and the blank in
one of the nine squares. (The total
number of states is 9! = 362880.
Initial state: Any state can be
designated as the initial state.
8-puzzle Actions: Actions may be defined
as movements of the blank space
Left, Right, Up, or Down. Different
subsets of these are possible
8 Puzzle Problem….

Transition model: Given a state and action, this returns the


resulting state; for example, if we apply Left to the start state in
Figure, the resulting state has the 5
and the blank cell switched.
Goal test: This checks whether the state matches the goal
configuration .
Path cost: Each step costs 1, so the path cost is the number of
steps in the path.
EXERCISE Initial state =S1
Possible actions={Left,
1 2 3 Right, Up, Down}
1 2 3
Actions(S1)={ Left,
4 8 4 5 6 Up,Down}
Transition state
7 6 5 Result(S1,Down)=S2
7 8
Goal test
Path cost=5
Initial Goal
{(1,2,3),(4,8,0),
State dow State Left Up
(7,6,5)}
1 2 3 1 n2 3 1 2 3 1 2 3
4 8 4 8 5 4 8 5 4 5

7 6 5 7 6 7 6 7 8 6

S S2 S3 S4
1 1 2 3 1 2 3

S5
4 5
S6
4 5 6
GOAL !
Down
Righ 7 8 6 7 8 !
t
MISSIONARIES AND CANNIBALS
PROBLEM
It is an AI famous problem formulation from an analytical viewpoint.

Description
Three missionaries and three cannibals * are on one side of a river, along
with a boat that can hold one or two people. Find a way to get everyone to
the other side without ever leaving a group of missionaries in one
place outnumbered by the cannibals in that place(Figure 1).
* cannibal is a person
who eats the flesh of
other humans.

Figure 1: The missionaries and cannibals problem


MISSIONARIES AND CANNIBALS PROBLEM…
Standard formulation
Ignore all irrelevant parts of the problem (e.g., weather conditions,
possible presence of crocodiles in the river, etc.).

• States:
Each state is represented by an ordered sequence of 3 numbers (x; y;
z) where
x : number of missionaries on initial river bank
y : number of cannibals on initial river bank Figure 2

z : number of boats on initial river bank

For example, if triangles represent missionaries, circles represent


cannibals and the left bank is the initial bank then the state shown in
Figure 2 is specified by the ordered triple (3, 3; 1). Note that the fact
that the boat is at the destination bank is indicated by z = 0. Also it
may be noted that not all such ordered triples represent legal states.
MISSIONARIES AND CANNIBALS PROBLEM…
Initial state: The ordered sequence = (3; 3; 1) (see Figure 1).
Actions: Take two missionaries, two cannibals, or one of each
across in the boat. We have to take care to avoid illegal states.
Transition model: Given a state and action, this returns the
resulting state; for example, if we apply the action ”Take 1
cannibal” to the state (0; 2; 0) the resulting state is (0; 3; 1).
Goal test: We have reached state (0; 0; 0).
Path cost: Number of crossings.
Solution
Figure 3 shows the possible legal states reachable from the initial state
applying only
legal actions. In the figure, the notation indicates the operation of
taking 2 cannibals from the bank where the boat is currently located to the
other bank and the notation indicates taking two missionaries.
MISSIONARIES AND CANNIBALS PROBLEM…
CRYPTARITHMETIC PROBLEM

This is an example for a special type of problem known as “constraint


satisfaction problem”. Constraints
• No two letters have same value
• Sum of digits should be as in problem
• Only one carry forward
• Digits can be 0 to 9
• Left most position should not be 0
Description
A cryptarithmetic puzzle is a mathematical exercise where the digits of
some numbers are
represented by letters. Each letter represents a unique digit. It will be
assumed that the
2 1
Letter - Digit
leading digits of numbers are not zero. The problem is to find the digits
T 2
such that a given 8 1 O 1
G 8
mathematical equation is satisfied.
U 0
TO 1 0 2

+GO
CRYPTARITHMETIC PROBLEM…
Problem formulation
Using the idea of states the problem can be formulated as follows:
States: Let there be n different letters where n≤10. A problem state
is an ordered n-tuple of digits (d1, d2, …… ,dn) representing the
digits to be assigned to the integers.
Initial state: The initial state can be considered as the ordered n-
tuple all of whose elements are 0’s.
Actions: Increase the value assigned to a letter by 1.
Transition model: Given a state and action, this returns the
resulting state.
Goal test: We have reached state (d1, d2, ….., dn) which satisfies
the constraints of the problem.
CRYPTARITHMETIC PROBLEM…
Solution
There are algorithms for solving the cryptarithmetic puzzle.
Implementations of these algorithms by hand computations is
difficult. The method of trial and error keeping in mind
Example problem 1
TO Solution by hand computation
+GO Since leading digits are not 0, we have T ≠ 0, G
------- ≠ 0, O ≠ 0.
OUT Since O is a non-zero carry digit when the two
digits T an G are added, we must have O = 1.
---------
Since O = 1 and O + O = T, we must have T =
2.
Since T = 2 and T + G ≥ 10, T + G must be
either 10 or 11.
If T + G = 10, then G = 8 and U = 0.
T = 2, O = 1, G = 8, U = 0.
This gives a solution to the problem, namely,
21 If T + G = 11, then U = 1 and in that case U =
+81 O = 1 which is not acceptable.
--------- Thus the problem has a unique solution as
102 given above
---------
CRYPTARITHMETIC PROBLEM 2…
Solve the following cryptarithmetic
puzzle:
N=E+1 Charact Code
SEND
N + R = 10 + E er
+MORE
------------------- S 9
MONEY E+1+R +1=10+E
----------------- 1 1 E 5
D+E =Y
9 5 6 7 N 6
2,3,4,5,6,7
D 7

1 0 8 5 M 1
+
O 0

R 8
1 0 6 5 2
Y 2
CRYPTARITHMETIC PROBLEM 2…
Solution
1. We number the columns as
follows: 2. From column 5, we must have
Col : 5 4 3 2 1 M = 1 since it is the only carry
----------------------- possible from the sum of two
SEND single digit numbers.
+ MORE Col:5 4 3 2 1
---------------------- -----------------
MONEY SEND
------------------------ +1ORE
---------------
1ONEY
-----------------

3. To produce a carry from column 4 to column 5, S + 1 Col: 54321


must be at least 9. We have S + 1 = 9 (if there is a
carry over from column 3) or 10 (if there is no carry ---------------
from column 3). So, we must have S = 8 or 9. Then O SEND
= 0 or 1. But we have already seen that M = 1. The +10RE
same value cannot be assigned to O. Therefore we
must have O = 0. ----------------
CRYPTARITHMETIC PROBLEM 2…
8. If E were 6 and D + E at least 12 then D would be 7, but N = E + 1 and
N would
also be 7 which is impossible. Therefore E = 5 and N = 6.
Col:5 4 3 2 1
----------------
956D
+1085
---------------
1065Y
---------------
9. D + E is at least 12 for that we must have D = 7 and Y = 2.
Col:5 4 3 2 1
-----------------------
9567
+1085
----------------
10652
-----------------
10. The problem has unique solution, namely,
D = 7, E = 5, M = 1, N = 6, O = 0, R = 8, S = 9, Y = 2.
BLOCKS WORLD PROBLEM

Blocks world (or, the world of blocks) is a model domain used in artificial
intelligence to
explore different approaches to automated reasoning. This model is used to
illustrate that
a given algorithm can perform planning, or that it is efficient in terms of the
number of
calculations required to find a solution or in terms of the length of that
solution.

Description
There is a table on which some uniform blocks (cubes) are placed. Some
blocks may or
BLOCKS WORLD PROBLEM…
States: Configurations of the
blocks satisfying the
conditions. The configurations
can be specified using the
following predicates where X
and Y denote arbitrary blocks:

ON(X,Y) : block X is on block Y.


ON(X, Table) : block X is on the
table.
CLEAR(X) : block X has
nothing on it.
HOLDING(X) : the arm holds
Initial state: The initial configuration of blocks.
block X.
Actions: ARM(Empty) : the arm holds
UNSTACK(X,Y) : pick up clear block X from block nothing.
Y and hold it in the arm
STACK(X,Y) : place block X held in the arm onto clear block Y
PICKUP(X) : lift clear block X with the empty arm
PUTDOWN(X) : place block X held in the arm onto a free space on the table.
BLOCKS WORLD PROBLEM…
Solution
The blocks world problem has always a trivial solution: All blocks not already
correctly
positioned for the goal state be set off onto the table (one at a time with the
mechanical arm), and then reassembled in the proper order on top of any
blocks already correctly positioned.

1. UNSTACK(2, 3)
7. PICKUP(2)
2. PUTDOWN(2) 8. STACK(2, 5)
3. UNSTACK(4, 5)
9. PICKUP(3)
4. PUTDOWN(4) 10. STACK(3, 1)
5. UNSTACK(5, 6)
11. PICKUP(6)
6. STACK(5, 4) 12. STACK(6, 3)
BLOCKS WORLD PROBLEM…

HOMEWORK !!
WATER JUG PROBLEM
Problem statement
We have two jugs of capacity 4 liters and 3 liters, and a
tap with an endless supply of water. The objective is to
obtain 2 liters of water exactly in the 4-liter jug with the
minimum steps possible.

Problem formulation
States: Let x denote the number of liters of water in
the 4-liter jug and y the number of liters of water in the
3-liter jug. Now x = 0, 1, 2, 3, or 4 and y = 0, 1, 2, or 3.
The ordered pair ( x, y ) represents a state.
Initial state: The ordered pair (0 , 0).
Actions: Each action is represented in the form “(x , y)
-> (u , v)” where (x , y) represents the state before the
application of the action and (u , v) represents the state
Transition model: The production system given in
Table also
specifies the transition model.
Goal test: The state (2 , n) where n is some integer.
Path cost: Number of operations performed.
ossible actions and the conditions under which the various actions given in the ta

Solution
One solution
to the water
jug problem
is given

You might also like