File Exchange

## Application of Artificial intelligence (A*) - Puzzle - 8

version 1.0.0.0 (3.34 KB) by
Implementation of A* algorithm to solve the Puzzle-8.

Updated 21 Aug 2008

This Programme is to apply A* algorithm to the puzzle-8.

Puzzle-8:
This is a simple sliding game which children use to solve. The same sliding game becomes a great challange to solve by using computer. The traditional meathod of solving by using various combination is very long process. AI's algorithm A* (A-Star) allow us to slove the same with less iterations.

How to open:
1. Extract files from "8puzzle.zip" and save all files in one folder.
2. Run the file "gskmadem8puzzle.m" from MATLAB.
3. Change the MATLAB location to the present folder location.
4. Give input of 3 X 3 matrix (use 0 instead of space)
5. Wait for few minutes. The solution will be displayed as the algorithm reaches its goal.(Waiting time depends on computer speed also on the input convergence). Approximate time needed is 30 seconds to 10 minutes.

Supporting files:
1. gskcostastar.m
3. gskpzget.m
4. gskpzjoin.m
5. gsksearch.m

Sample Input and Output:
Upon executing "gskmadem8puzzle.m", Following screen is expected (input considered is "[4 5 6; 1 7 0; 8 3 2]")

enter a puzzle in 3 x 3 form (use 0 for space) ..........: [4 5 6; 1 7 0; 8 3 2]

intv000 =

1

pzout =

4 5 6
1 7 0
8 3 2

intv000 =

2

pzout =

4 5 0
1 7 6
8 3 2

intv000 =

3

pzout =

4 0 5
1 7 6
8 3 2

intv000 =

4

pzout =

0 4 5
1 7 6
8 3 2

intv000 =

5

pzout =

1 4 5
0 7 6
8 3 2

intv000 =

6

pzout =

1 4 5
7 0 6
8 3 2

intv000 =

7

pzout =

1 4 5
7 6 0
8 3 2

intv000 =

8

pzout =

1 4 5
7 6 2
8 3 0

intv000 =

9

pzout =

1 4 5
7 6 2
8 0 3

intv000 =

10

pzout =

1 4 5
7 0 2
8 6 3

intv000 =

11

pzout =

1 0 5
7 4 2
8 6 3

intv000 =

12

pzout =

1 5 0
7 4 2
8 6 3

intv000 =

13

pzout =

1 5 2
7 4 0
8 6 3

intv000 =

14

pzout =

1 5 2
7 4 3
8 6 0

intv000 =

15

pzout =

1 5 2
7 4 3
8 0 6

intv000 =

16

pzout =

1 5 2
7 4 3
0 8 6

intv000 =

17

pzout =

1 5 2
0 4 3
7 8 6

intv000 =

18

pzout =

1 5 2
4 0 3
7 8 6

intv000 =

19

pzout =

1 0 2
4 5 3
7 8 6

intv000 =

20

pzout =

1 2 0
4 5 3
7 8 6

intv000 =

21

pzout =

1 2 3
4 5 0
7 8 6

intv000 =

22

pzout =

1 2 3
4 5 6
7 8 0

******************************

Feel free to inform about corrections and suggestions.

### Cite As

Suresh Kumar Gadi (2021). Application of Artificial intelligence (A*) - Puzzle - 8 (https://www.mathworks.com/matlabcentral/fileexchange/21154-application-of-artificial-intelligence-a-puzzle-8), MATLAB Central File Exchange. Retrieved .

snehal jaipurkar

I m new user of matlab. I have so many doubts in matlab. Will I get all the necessary help here????

Muhammed

Fabiano

Hi, I've used your code as example to make an IDA* solver to 8 puzzle. Half combinations in 8 puzzle that your code can't solve. I've changed the code to solve any combination and the heuristics too. Check out my code in http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid:254006
Thanks!

Sam

Nice work!!! thanks... :)

PacketSpike

[4 5 6; 1 7 8; 0 3 2] 1 sec
[4 5 6; 1 7 0; 8 3 2]15 sec
[4 5 1; 6 7 0; 8 3 2] Still going! 1 Day so far!!

Miguel

Hi,
I am a graduate student and I am interested in understanding your code. Is it possible to have some comments on the variables, functions and commands?
Thanks

yalda hosseini

very good
i am beginner at AI, would you please help me how to convert it to 15 puzzle?
thanks

Jess Zhou

Solves good.

##### MATLAB Release Compatibility
Created with R14SP3
Compatible with any release
##### Platform Compatibility
Windows macOS Linux