File Exchange

image thumbnail

Application of Artificial Intelligence (ID A*) - 8-Puzzle

version (3.67 KB) by Fabiano
8-Puzzle solver using AI techniques - iterative deepening ID A*


Updated 19 Feb 2013

View Version History

View License

The 8-puzzle is an old game largely used to test new heuristic AI techniques.

The software solves any 8-puzzle combination (even and odd) using "board counting".
An even combination will find the following objective:

An odd combination will find the following objective:

How to run the program:

1. Extract files from "" in FOLDER.
2. Change MATLAB location to FOLDER.
3. Run the file "StartGame.m" from MATLAB.
4. Enter a 3 X 3 matrix. ex. [3 2 1, 4 5 6 , 0 8 7]
5. Wait for the solution.

Cite As

Fabiano (2021). Application of Artificial Intelligence (ID A*) - 8-Puzzle (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (5)

Farooq Rasheed

no one can understand whats going on in your output and what does this mean ?
Output should be [1 2 3; 4 5 6; 7 8 0]
but your output is strange

Suraj Rao Bandela

ruba mfarij

can you please help me implementing BFS for this game?
The "one-row sliding-tile puzzle" consists of three black tiles, three white tiles, and an empty space in the middle as shown below.

initial state : B B B 0 W W W
goal state : W W W B B B 0

The puzzle has two kinds of legal moves with associated costs: A tile may move into an adjacent location. This has a cost of 1. A tile can hop over one or two other tiles into the empty position. This has a cost equal to the number of tiles jumped over.

ruba mfarij

thank you

frdous hashem


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

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!