Loyd's 15-Game

MGT Computer Solutions >> Services >> Custom Programming >> JavaScript >> Loyd's 15-Game
Loyd's 15-Game v.3.0
This puzzle demonstrates a tiny part of the power of JavaScript.

A study in JavaScript

JavaScript is the premier programming language for dynamic Web and mobile content. The little game to the right is a whimsical example of the power of this ubiquitous language.

Using JavaScript, we can make your web pages present much more than numbered buttons that move when clicked. Images .. icons .. the limit is not in the technology; the limit is in the imagination.

Let us help you make your web site more dynamic!


How to play

Click "Shuffle", then solve the puzzle by moving the tiles until the board is back in order.  To move a tile, click on it.  Only tiles adjacent to the blank space can be moved.

Try to solve the puzzle in fewer than the number of slides. By how much can you decrease the number of slides before the game becomes trivial? is there a number of slides beyond which the game's difficulty doesn't increase?

For additional difficulty, adjust the size of the board. You can play on boards up to 10x10. The bigger boards with lots of slides are extremely difficult. But smaller isn't very easy either!

Solving the puzzle

You control the puzzle's difficulty by the number of individual movements, or "slides", to apply to the tiles at the start of the game. The default number of slides is 22. That does not sound like many, but you may find most puzzles produced by 22 slides to be difficult enough.

You can change the number in the "Slides" box until you click the "Shuffle" button; after that the number is locked until the puzzle is solved again.  You can set the number of slides to any positive whole number.   Depending on your computer's speed and the browser you are using, your system can become unresponsive if you ask for a large enough shuffle.

You can also use the puzzle manually.  Move the tiles to your own starting position, and then solve the puzzle.  If you do it this way, you'll have to count your slides and moves yourself. 

You can affect the shuffle somewhat by manually moving the tiles to a position of your choosing before clicking the "Shuffle" button.  But the shuffle is still pseudorandom, so the starting position doesn't actually have much influence. If you do it this way, the manual moves that you made are not reflected in the shuffle count.  And unless you click "Shuffle", you won't get a congratulatory message when you solve the puzzle.


More about the puzzle

Beginning around 1880, American gamesmaker, chessmaster and "practical mathematician" Sam Loyd sold thousands of these now-famous sliding-tile puzzles. Selling the games with all the tiles in numerical order except the last two, wily Sam promised a prize of $1000 to anyone who could restore all 15 tiles to a simple ascending sequence, left to right, top to bottom.

Many claimed to have solved the puzzle, but Sam's company always refused to pay, stating - correctly - that someone had tampered with the paydirt puzzle. Sam knew that there are two "families" of tile arrangements, and there is no way to change "families" merely by sliding tiles .. the tiles have to be removed from their frames to perform the necessary rearrangement.

By reversing tiles 14 and 15, Sam ensured that those puzzles had no solution to the problem as stated .. and the prize money he offered remained secure.

Sam didn't invent the puzzle; he was, after all, a practical mathematician. 

Try it yourself

Our implementation of the well-known puzzle always presents a solvable arrangement.  Full instructions are in the 'How to Play' section of this page.

More about the software

MGT Computer Solutions developed this JavaScript implementation of the Loyd-15 Puzzle to demonstrate the power of JavaScript in programming modern browsers.

Our Loyd-15 Puzzle Game is based on a design developed by our company's founder in 1978, and first implemented on the 6502 chip of the Ohio Scientific C-III.  It has since been ported to many platforms and refactored to use object-oriented methodology.

"The Miracle Workers of Computing" since 1989
Our Twenty-fourth Year

Any trademark appearing on this page is the property of its owner.

Please send us your questions or comments about this web site.
Design, Implementation and Contents Copyright © 1998-2013 MGT Computer Solutions.  All rights reserved.