Skip to content

VIRUS-ATTACK/SOLVING-15-slide-puzzle-using-A-star-algorithm-based-on-total-no-of-misplaced-tiles

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 

Repository files navigation

SOLVING-15-slide-puzzle-using-A-star-algorithm-based-on-total-no-of-misplaced-tiles

heuristic H(n) = Total no of misplaced tiles

In this project I had implemented a 'c' code to solve 15 slide puzzle using A* algorithm.
Here the heuristic H(n)=Total no of misplaced tiles.Compile and run the 'AI_optimalH2.c' file and give the 4x4 input matrix and the output will be:
1)matrix is solvable matrix or not.
2)all the matrices in the path of reaching the goal matrix
3)number of nodes generated(time)
4)number of nodes present in the memory(space)

Here are some of the test cases
TESTCASE-1
1 2 4 7
5 6 3 0
9 10 11 8
13 14 15 12

TESTCASE-2
2 4 3 7
1 6 10 8
5 9 0 11
13 14 15 12

TESTCASE-3
3 7 0 4
2 1 8 11
5 6 10 15
9 13 14 12

TESTCASE-4
2 6 3 4
1 10 7 8
5 11 0 12
9 13 14 15

TESTCASE-5
2 3 8 4
1 5 14 12
11 6 7 15
9 13 10 0

TESTCASE-6
1 2 4 8
7 3 11 10
0 9 14 12
5 6 13 15

Note:This code only works for solvable 4x4 matrices and for some solvable matrices it may take too much time.