0% found this document useful (0 votes)
39 views

Artificial Intelligence & Machine Learning

This document discusses state-space representation for solving artificial intelligence problems. It provides examples of using state-space representation for the 8-puzzle problem and chess. For the 8-puzzle problem, it describes how to represent board states as matrices and formulate rules for moving tiles. For chess, it outlines representing the board as a list, defining rules for legal moves, checking rule applicability, specifying winning conditions, and selecting search strategies. The document also discusses issues in state-space searches like avoiding loops, finding optimal vs any solutions, decomposing problems, and using forward vs backward reasoning.
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views

Artificial Intelligence & Machine Learning

This document discusses state-space representation for solving artificial intelligence problems. It provides examples of using state-space representation for the 8-puzzle problem and chess. For the 8-puzzle problem, it describes how to represent board states as matrices and formulate rules for moving tiles. For chess, it outlines representing the board as a list, defining rules for legal moves, checking rule applicability, specifying winning conditions, and selecting search strategies. The document also discusses issues in state-space searches like avoiding loops, finding optimal vs any solutions, decomposing problems, and using forward vs backward reasoning.
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 21

Artificial Intelligence &

Machine Learning

Class No-3:
State-space
representation (Contd.)
By:
Dr. Niranjan Panigrahi
CSE, PMEC, Berhampur,Odisha
Recap…
Identification & Definition of AI
problem
Typical NP-complete/NP-hard
problems
State-space representation
Examples of Classical AI problems
State-space representation method
Water-jug problem

2
State Vs Node
 State represents  Node represents a
physical suitable data
configuration of a structure to
given problem represent the state
of a given problem

3
Example-2 : 8-puzzle problem
 Given: a board situation for the 8-puzzle:

1 3 8
2 7
5 4 6
 Problem: find a sequence of moves (allowed under
the rules of the 8-puzzle game) that transform this
board situation in a desired goal situation:
1 2 3
8 4
7 6 5
4
Initial issues to solve:
 How to represent states?
 Ex.: 1 3 8 using a 3 X 3 matrix
2 7
5 4 6
 How to formulate production rules?
 Ex.:
 express how/when squares may be moved?
 Or: express how/when the blank space is moved?
 When is a rule applicable to a state? (matching)
 How to formulate when the goal criterion is satified and
how to verify that it is?
 How/which rules to activate? (control)
5
The (implicit) search tree
 Each state-space representation defines a search
tree:
1 3 8
2 7
5 4 6

1 3 8 1 8 1 3 8 1 3 8
2 7 2 3 7 2 7 2 4 7
5 4 6 5 4 6 5 4 6 5 6

goal

 But this tree is only IMPLICITLY available !! 6


Example-3: Chess playing
 Problem: develop a program that plays chess (well).

1. A way to represent board situations in an


unambiguous way:
 Ex.:

8 List:
7 (( king_black, 8, C),
6 ( knight_black, 7, B),
5 ( pawn_black, 7, G),
4 ( pawn_black, 5, F),
3 ( pawn_white, 2, H),
2 ( king_white, 1, E))
1
A B C D E F G H 7
Chess (2):
 2. Describe the rules that represent allowed
moves:
 Ex.:
4
3
2
1
A B C D E F G H

( (pawn_white,2,x) , (blank, 3, x), (blank, 4, x) )

add( ( pawn_white, 4, x) ),
remove( (pawn_white, 2, x) )
8
Chess (3):
 3. Provide a way to check whether a rule is
applicable to some state:
 Ex.:
List:
8
7 (( king_black, 8, C),
6 ( knight_black, 7, B),
5 ( pawn_black, 7, G),
4 ( pawn_black, 5, F),
3 ( pawn_white, 2, H),
2 ( king_white, 1, E))
1
A B C D E F G H
( (pawn_white,2,x) , (blank, 3, x), (blank, 4, x) )
add( ( pawn_white, 4, x) ),
remove( (pawn_white, 2, x) )

Matching mechanism !! 9
Chess (4):
 4. How to specify a state in which the goal is
reached (= a winning state):
 Ex.:

win( black )  attacked( king_white ) and

no_legal_move( king_white )

+ similar definitions for:

attacked( Piece )  …
no_legal_move( Piece )  ...

10
Chess (5):
 5. A way to verify whether a winning state is
reached.
 Ex.:

?- win( black ).
win( black )  attacked( king_white ) and

no_legal_move( king_white )


Need a theorem prover ( e.g. Prolog) to verify
that the state is a winning one.
11
Chess (6).
 6. The initial state.

A program that is ABLE to play chess.

7. A mechanism that selects in each state an


appropriate rule to apply.

The control problem !

Main focus of searching


strategies!!

12
Chess (7).
Implicit search tree
~15
Move 1

Move 2
~ (15)2

~ (15)3 Move 3

Need very efficient search techniques to find good


paths in such combinatorial trees. 13
Issues and trade-offs:

1. Should we search through the implicit tree or


through an implicit graph?
2. Do we need an optimal solution, or just any solution?
‘optimal path problems’
3. Can we decompose states into components on which
simple rules can in an independent way?
Problem reduction or decomposability
4. Should we search forwards from the initial state,
or backwards from a goal state?

14
1. Avoiding loops:
search in trees or graphs ?
[ 0, 0 ]

[ 4, 0 ] [ 0, 3 ]

[ 1, 3 ] [ 4, 3 ] [ 3, 0 ]

[ 1, 0 ] [ 3, 3 ]
...
Avoids generating loops: but needs to keep
track of ALL the nodes. 15
2. Any path, versus shortest
path, versus best path:
Ex.: 8-puzzle: any or shortest path problem.
Ex.: Traveling salesperson problem:

3000
Boston SanFrancisco
250 1700 2900
3300
1450 NewYork
1200 1700
1500
Miami 1600
Dallas

 Find a sequence of cities ABCDEA such that the


total distance is MINIMAL.
Best path problem
16
3. Problem reduction or
problem decomposition:
Ex.: Computing symbolic integrals:
 State: the integral to compute
 Rules: integration reduction rules
 Goal: all integrals have been eliminated
 x2 + 3x + sin2x . cos2x dx
AND
x2 dx 3xdx sin2x . cos2x dx

x3/3 3 xdx
((sin2x)/2)2dx (1 - cos2x).cos2x dx
... ... ... ...
AND-OR-tree search 17
Necessary for decomposition:
independence of states:
Ex.: Blocks world problem.
 Initially: C is on A and B is on the table.
 Rules: to move any free block to another or to the table
 Goal: A is on B and B is on C.

AND-OR-tree?
C
A B
Goal: A on B and B on C

AND

C C
A B A B
Goal: A on B Goal: B on C
18
AND

C C
A B A B
Goal: A on B Goal: B on C

C A B B
Goal: A on B C
A

A But: branches cannot be


C B combined

19
4. Forward versus backward
reasoning:
Initial states

Goal states

 Forward reasoning (or forward chaining): from


initial states to goal states.
20
5. Forward versus backward
reasoning:
Initial states

Goal states

 Backward reasoning (or backward chaining): from


goal states to initial states.
21

You might also like