SiteExperts.com Logo Home | Community | Developer's Paradise
User Groups | Site Tools | Site Information | Search
 Main Menu
 Resource

The Puzzler

Categories...
Client User Group
Internet Playground
Language
JavaScript
Product
IE4
Task
Fun Stuff, Image Manipulation
Technology
Dynamic Positioning

Sponsored Links
Developer's Paradise : Inside Technique :
The Puzzler
Submission by SiteExperts Staff

Go to the resource:
The Puzzler

Add to Assistant

Short Description
The Puzzler uses Dynamic HTML to manipulate any image on the web and turn it into a sliding puzzle.

Long Description
The Puzzler uses Dynamic HTML to manipulate any image on the web and turn it into a sliding puzzle. Make your images and web-site more fun and interactive using The Puzzler's step by step wizard.

Author
Scott Isaacs
Submission URL
http://www.SiteExperts.com/games/puzzler/page1.asp
Submission Date
Nov 30,1998
Related To
Inside Techniques
 

Discussion and Rate this Resource
Overall Rating: 4.5

ondra on Nov 2, 2002 at 6:39:08 AMNo Rating
Adding a line in the puzz.htc in the context menu part: str+="<span onclick=\""+uniqueID+"menu1.style.display='none';\"><I>close</I></span>"; you'll be able to close the menu. Otherwise one has to reload the page.
Zealouz on May 7, 1999 at 3:11:18 AMNo Rating
gotilla on Apr 5, 1999 at 12:57:11 PMNo Rating

I was able to locate my copy of 'Fermat´s Enigma,' by Simon Singh, as I mentioned in my last message. He has a very neat mathematical proof, by Sam Loyd himself, showing why certain puzzle configurations might be impossible to resolve.I shall proceed to paraphrase him.

Imagine you have a 4 by 4 puzzle, with 15 pieces, numbered 1 thru 15 from left to right and top to bottom(16 is the empty slot necessary for sliding the other pieces):

1 2 3 4
5 6 7 8
9 10 11 12
13 14 15

Lets now define a Disorder Parameter (Dp) which will be the measure of Disorder within the puzzle. Dp will be a positive integer which stands for the count of puzzle pairs out of order.As the puzzle now stands Dp = 0, since no pieces are out of order.

The puzzle may be easily manipulated in order to produce the following arrangement:

1 2 3 4
5 6 7 8
9 10 12 15
13 14 11

The Dp for this arrangement is 6, since the following puzzle-pairs are out of place:(12,11), (15,13), (15,14), (15,11), (13,11), (14,11). This means that the 12-tile is out of place because it stands before the 11-tile. The 15-tile is out of place because it stands before the 13,14 and 11-tiles. The 13 and 14-tiles are out of order because they stand before the 11-tile.(Note that even though the 10 and 12 tiles stand side-by-side they are not 'out of order' with respect to each other.)

Another possible setup is as follows:

1 2 3 4
5 6 12 7
9 10 8 15
13 14 11

In which case Dp = 12, and the pairs are:(12,7), (12,9), (12,10), (12,8), (12,11), (9,8), (10,8), (15,13), (15,14), (15,11), (13,11), (14,11). The important point to notice is that thru sliding of the puzzle, Dp is always an even number. If a puzzle is created with two pieces inverted, as in Sam Loyd´s puzzle where 14 and 15 were inverted, Dp is an odd number (in this case, 1) and no set of tile-sliding can be performed to arrange the puzzle in the correct, 1 thru 15, manner.

Sliding of any puzzle with an odd Dp value will only generate another odd Dp value. The closest to a solution will be Dp=1, where the 14 and 15-tiles are swapped, and all else is correct.If puzzle pieces are arranged randomically, there´s a 50-50 chance that the generated puzzle will have Dp as an odd number, and thus, be impossible to solve.

As a suggestion for the structure of a 'checking' algortihm, imbedded loops may be used to count the number of disordered puzzle tiles, and if an odd count is reached (Dp%2 == 1) it may be fixed. I'm unsure about this 'fixing' step. Carefull thought must be given in order to un-switch two pieces to produce a even Disoreder parameter.

Unfortunately, all of this means a significant performance hit. Especially with bigger puzzles (more tiles). There seems, however, no way around it.


If anybody has any doubts about this proof, I tried to re-state as best as I could, please email me at gotilla@iname.com

Scott, feel free to alter this message to add clarity.

gotilla on Mar 27, 1999 at 10:22:54 PMNo Rating

Along the lines of Sam Lloyd's puzzle (he sold a 4x4 sliding puzzle with the 14 and 15 keys inverted - 16 was removed to create the blank space necessary to manipulate the puzzle. He would then offer a great sum of money to anybody who could solve the puzzle - which nobody was able to win.) I guess it becomes clear why two adjacent pieces cannot be switched if you imagine a 2x2 puzzle.

I think the key is not to have an algorithm  to check if a puzzle is solveable after it has been randomized, but an algorithm which randomizes the pieces by manipulating the puzzle in much the same way a user would. Some loops can be constructed to 'slide' the pieces around randomly following the same rules a user has to follow: only pieces directly next to the empty space may be moved.

I remember reading about the exact mathematical proof behind this impossible sliding puzzle setup in Simon Singh's book, "Fermat's Last Therorem". I'll try to locate a copy of it. That might help.

Scott Isaacs on Mar 25, 1999 at 10:56:07 PMNo Rating
The algorithm just randomizes the pieces.... Based on Sam Lloyd I guess it is possible that the puzzle may not be solveable....  (anyone have an algorithm to verify a puzzle?)
gotilla on Mar 25, 1999 at 7:21:32 PMRating: 5
I'm interested in knowing if proper care was taken to insure that the puzzles generated are always possible to complete. As the famous puzzler Sam lloyd proved, if just 2 adjacent pieces are interchanged the puzzle becomes impossible. Scott?

More Ratings/ Comments


To rate and comment on a resource, you must first logon.

If you are not registered, please register yourself to become a member of the SiteExperts.community.

User Name
Password

Copyright © 1997-2008 InsideDHTML.com, LLC. All rights reserved.