5.0

5.0 | 2 ratings Rate this file 36 Downloads (last 30 days) File Size: 3.34 KB File ID: #21154

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

by Suresh Kumar Gadi

 

20 Aug 2008 (Updated 21 Aug 2008)

Implementation of A* algorithm to solve the Puzzle-8.

| Watch this File

File Information
Description

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
2. gskmadem8puzzle.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.

MATLAB release MATLAB 7.1.0 (R14SP3)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (3)
21 Aug 2008 Jess Zhou

Solves good.

I want to share this link to you for generating random puzzles.

http://www.permadi.com/java/puzzle8/

11 Sep 2010 yalda hosseini

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

07 Jan 2012 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

Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
neural and fuzzy systems Suresh Kumar Gadi 22 Oct 2008 10:15:24
artificial intelligence Suresh Kumar Gadi 22 Oct 2008 10:15:24
a Suresh Kumar Gadi 22 Oct 2008 10:15:24
puzzle 8 Suresh Kumar Gadi 22 Oct 2008 10:15:24
companion software Suresh Kumar Gadi 22 Oct 2008 10:15:24

Contact us at files@mathworks.com