5.0

5.0 | 3 ratings Rate this file 91 downloads (last 30 days) File Size: 7.08 KB File ID: #13900

N-Puzzle (dynamic size and solver)

by Per-Anders Ekstrom

 

07 Feb 2007 (Updated 27 Jun 2007)

Code covered by BSD License  

Graphical User Interface for playing and solving the N-Puzzle game.

Download Now | Watch this File

File Information
Description

The Game:
The N-puzzle is known in various versions, including the 8 puzzle, the
15 puzzle, and with various names. It is a sliding puzzle that consists of a grid of numbered squares with one square missing, and the labels on the squares jumbled up. If the grid is 3?the puzzle is called the 8-puzzle or 9-puzzle. If the grid is 4?the puzzle is called the 15-puzzle or 16-puzzle. The goal of the puzzle is to un-jumble the squares by only making moves which slide squares into the empty space, in turn revealing another empty space in the position of the moved piece. (From Wikipedia)
 
Game Board:
The N-Puzzle interface lets the user choose between several predefined sizes of boards, and also to choose any custom (valid) size N. A valid
size of N is such that round(sqrt(N+1))^2-1 equals to N.
All generated games are solvable. A game is generated by performing 1000 random moves of the empty space starting from the solution.
User can also import any puzzle into the interface. Puzzle must be defined as an array or as a matrix with numbers spanning from 1 where
the largest number is the empty space.
 
Game Controls:
The N-puzzle game can be played using either mouse or keyboard (or both). Move around marker using arrow keys and make a switch using space. With mouse you move around marker using left-click and make a switch using any other type of click (double-click, right-click, shift-click, etc.)
 
Extra Game Features:
The N-Puzzle game has Undo and Redo functionality that can be reached from the menu or by the shortcuts Ctrl-Z (Undo) and Ctrl-R (Redo).
A simulation of the game so far can also be viewed using the control in the menu.
The game now also has a built-in solver.

MATLAB release MATLAB 7.2 (R2006a)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (3)
07 Feb 2007 John D'Errico

Its the 15 puzzle. Works nicely. Well implemented. Its got help. No problems that I found.

23 Feb 2007 Joe Kirk

This is an excellent contribution! I'd give it 6 stars if I could. It has everything anyone could want in a sliding puzzle...(except maybe a High Scores table) :o)

02 Mar 2007 Joseph Don

Flawless!

Please login to add a comment or rating.
Updates
27 Jun 2007

Generic solver added.

Tag Activity for this File
Tag Applied By Date/Time
games Per-Anders Ekstrom 22 Oct 2008 09:00:02
sliding Per-Anders Ekstrom 22 Oct 2008 09:00:02
game Per-Anders Ekstrom 22 Oct 2008 09:00:02
fifteen Per-Anders Ekstrom 22 Oct 2008 09:00:02
puzzle Per-Anders Ekstrom 22 Oct 2008 09:00:02
solver Per-Anders Ekstrom 22 Oct 2008 09:00:02
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com