Professional Documents
Culture Documents
NAME: RUTHIKA.J
REG NO: 21MIS0359
COURSE NAME: ARTIFICIAL INTELLIGENCE
SLOT:C1+TC1
COURSE CODE: SWE4010
DA - 2 QUESTION
H
C
G
A
D
B
F
E
Solution:
Local Function:
Add one point for every block that is resting on the thing it is supposed to be
resting on. Subtract one point for every block that is sitting on the wrong thing.
Step 0:
H -1 H +1
C -1 G +1
G -1 F +1
A -1 E +1
D -1 D +1
B -1 C +1
F +1 B +1
E -1
A +1
E -1 H
Score: -6
Justification: In step-1, the score has not been improved from step-0, hence the
hill-climbing algorithm comes to halt. We need to redefine heuristic function.
Global Function:
For each block that has the correct support structure (i.e., the complete structure
underneath it is exactly as it should be), add one point for every block in the
support structure. For each block that has an incorrect support structure subtract
one point for every block in the existing supporting structure.
Step 0:
-7 H +7
H
C -6 G +6
G -5 F +5
A -4 E +4
D -3 D +3
B -2 C +2
F -1 B +1
E 0 A 0
E 0 H
Score: -21
Step 2:
Case(a)
G
-5
A -4
D -3
B -2
F -1 0 0
E 0 H C
Score: -15
Case(b)
G -5
A -4
D -3
B -2
F -1 C -1
E 0
H 0
Score: -16
Case(c)
H -7
C -6
G -5
A -4
D -3
B -2
F -1
E
0
(Dead End)
Score: -28
Justification : Score of case (a) is highest. Hence we can proceed with case (a).
Step 3:
A
-4
D
-3
B -2
F -1 0 0 0
E 0 H C G
Score: -10
Step 4:
D
-3
B -2
0
F -1 0 0 0
E 0 H C G A
Score: -6
Step 5:
B -2 0
0
F -1 0 0 0
H C G A D
E 0
Score: -3
Step 6:
F -1 0 0 0 0 0 000
0
E 0 H C G A D B
Score: -1
Step 7:
0 0 0 0 00 00 0
0
E H C G A D B F
Score: 0
Step 8:
0
0 0 B +1 0
0 0 0
E 00000 H C G A 0 D F
E
Score: +1
Step 9
C
+2
0
0 0 0 B 0 +1 0
E H G A 0 D F
Score: +3
Step 10:
D
+3
C
+2
B
0 0 0 +1 0
E H G A 0 F
Score: +6
Step 11:
E
+4
D
+3
C
+2
0 0 B +1 0
H G A 0 F
Score: +10
Step 12:
F +5
E +4
D
+3
C
+2
0 0 B +1
H G A 0
E
Score: +15
Step 13:
G
+6
F +5
E +4
D
+3
C
+2
0 B +1
H A 0
E
Score : +21
Step 14:
H +7
G +6
F +5
E +4
D +3
C +2
B +1
A 0
Score: +28
Therefore, Goal state is reached.