Preeti Soni Lecturer (C S E) Rsrrcet Bhilai, C.G
Preeti Soni Lecturer (C S E) Rsrrcet Bhilai, C.G
LECTURER(C S E)
RSRRCET
Bhilai, C.G.
Uninformed
search
methods
lack
problem-specific
Srivastava
cases. Puja
Using
problem-specific knowledge can
Asst. Prof.(C S E)
dramatically improve
the search speed. In this Unit-II we will
RSRRCET
Bhilai, C.G.search algorithms that use problem
study some informed
specific heuristics. At the heart of such algorithms there is
the concept of a heuristic function.
f2
1
8
5
2
4
7
=4
f3(T) = the sum of ( the horizontal + vertical distance that each tile is
away from its final destination):
gives a better estimate of distance from the goal node
f3
1
8
3
5
6
2
4
7
= 1 + 4 + 2 + 3 = 10
= v( ) + v( )
+ v( ) + v( )
- v( ) - v( )
generate all successor states and evaluate each with our heuristic
function
A*
AO*
Beem Search
Greedy Search
In simple hill climbing method, the first state is better than the
current state is selected.
There is a trade off between the time required to slect a move and
number of moves required to get a solution that must be
considered wwhile deciding which method will work better for a
particular problem.
Root
8
B
A
2.7
C
2.9
2
D
Goal Node
1.
2.
3.
4.
5.
START.
6.
Goto step 2.
Both the simple hill climbing and gradient search may fail to find
a solution, either the algorithm may terminate not by finding the
goal state but getting to state from which any better state cant be
generated.
2. Plateau
3. Ridge
1. LOCAL MAXIMUM
A local maximum is a state i.e. better than all its neighbor but not better
than some other state further away
2. PLATEAU
A flat area of the search space in which all neighbouring states have the
same value.
Remedy
Make a big jump in some direction and try to get a new section of search
space.
3.RIDGE
Remedy
Apply two or more rules before doing the test.
Adventages Of DFS:
Adventages Of BFS:
In Best First Search one move is selected but the other nodes are kept
in consideration so that they can be examined or expanded later on if
g(n)
node
h(n)
node
1.
2.
3.
4.
5.
6.
7.
8.
Goto step 2.
9
3
E
12
6
Start Node
1 K
0 L
14
2
C
M
6
Goal Node
S.No.
Node
being
expanded
Children
Available Nodes
Node Choosen
1.
(A:3)
2.
(D:9), (E:8)
(C:5)
3.
(H:7)
4.
(F:12), (G:14)
(H:7)
5.
(I:5), (J:6)
(I:5)
6.
(B:6)
Search stops as
goal is reached
14
FitnessValue
6
A
8
3
3
12
1 K
14
G
0 L
2
M
6
1.
2.
3.
4.
5.
6.
7.
8.
Goto step 2.
An arc (
The complex problem and the sub problem , there exist two kinds of
relationships.
AND relationship
OR relationship.
In AND relationship, the solution for the problem is obtained by solving all the
sub problems.
9
7
A
4
B
6
D
Step 2.1 Select a node NODE1 from NODE. Keep track of the path.
Step2.2 Expand NODE1 by generating its childern. For childern which
are not the ancessors of NODE1, evaluate the evaluation Function
value. If the child node is terminal node label it END_NODE.
Step2.3. Generate a set of nodes DIFF_NODES having only NODE1.
Step 2.4 Repeat until DIFF_NODES is empty.
A
5
A 6
9
B
3
A 9
B
3
C
4
C
4
D
5
A 11
D 10
E
4
F
4
B 6
G
5
12
H
7
C
4
D 10
E
4
F
4
Two-step process:
1. Constraints are discovered and propagated as far as possible.
2. If there is still not a solution, then search begins, adding new
constraints.
Two kinds of rules:
1. Rules that define valid constraint propagation.
Cryptarithmetic puzzle:
SEND
MORE
MONEY
M = 1, since two single-digit numbers plus a carry can not total more
than 19.
N = 3 since N = E + 1.
Start
Initial state:
No two letters have
the same value.
The sum of the digits
must be as shown.
M=1
R=9
S=8
E=2
N=3
O=0
D=4
Y =6
M=1
S = 8 or 9
O=0
N=E+1
C2 = 1
N+R>8
E9
SEND
MORE
MONEY
E=2
N=3
R = 8 or 9
2 + D = Y or 2 + D = 10 + Y
C1 = 0
2+D=Y
N + R = 10 + E
R=9
S =8
M=1
R=9
S=8
E=2
N=3
O=0
D=8
Y=0
M=1
R=9
S=8
E=2
N=3
O=0
D=9
Y=1
C1 = 1
2 + D = 10 + Y
D=8+Y
D = 8 or 9
D=8
Y=0
Conflict
D=9
Y=1
Conflict
For the human expert, it is easy to explain the rationale for a move
unlike other domains.
Usual conditions:
Zero-sum game: any gain for one player is a loss for the other
Components of game:
initial state
game
utility function:
computes a single numeric value for a terminal state
The plausible move generator three childern for that move and the
static evaluation function generator assigns the values given along
with each of the states.
C
-6
D
7
minimaxValue(n) =
utility(n)
if n is a terminal state
max minimaxValue(s) of all successors, s
if n is a MAX node
min minimaxValue(s) of all successors, s
if n is a MIN node
going one level deeper may have revealed a trapa sudden negative
turn of events!
Alpha:
minimal score that player MAX is guaranteed to attain
(best known so far, but possibility of improvement.
Minimum attainable)
Beta:
best score that player MIN can attain so far (lowest
score known so far, lower score may yet be found.
Maximum attainable)
Max
Min
Max
Min
Beta = 6
Max
Min
Max
Min
Alpha = 6
from bd to bd/2
pruning from 35 to 6!
tic-tac-toe
connect four
checkers
chess
amazon
nim
othello
go
hex
backgammon (dice)
scrabble
bridge
poker
battleship
kriegspiel
Secondary Search
Alternatives to Minmax