Newsgroups: comp.ai
Path: cantaloupe.srv.cs.cmu.edu!rochester!udel!gatech!howland.reston.ans.net!news.sprintlink.net!redstone.interpath.net!sas!mozart.unx.sas.com!samurai!sasthc
From: sasthc@unx.sas.com (Thomas Cox,R4147,6295,,3081)
Subject: Re: 8 or 15 puzzle problem
Sender: news@unx.sas.com (Noter of Newsworthy Events)
Message-ID: <D80tsJ.G5n@unx.sas.com>
Date: Wed, 3 May 1995 21:17:07 GMT
X-Nntp-Posting-Host: samurai.unx.sas.com
Reply-To: sasthc@unx.sas.com
References: <NAU.95May3112125@frabjous.cs.umd.edu>
Organization: SAS Institute Inc.
Lines: 91

In article 95May3112125@frabjous.cs.umd.edu, nau@cs.umd.edu (Dana S. Nau) writes:
> > I am trying to write a program that will solve an 8 or 15 puzzle.  I
> > have used a breadth first and depth search method.  However, there 
> > are simply too many paths to follow.  I have consulted several books
> > regarding this subject.  Most AI books mention the problem, but no
> > book gives a solution that actually works.  I have spent a lot of time
> > on this problem and I am getting desperate.
> 
> Breadth-first search has problems with both the 8 and 15 puzzles because
> the number of nodes to be stored grows exponentially with the search
> depth.  A* can do reasonably well on the 8 puzzle if you use a good
> heuristic function, but on the 15 puzzle the exponential growth kills A*
> too.  Iterative deepening and various extensions of it (such as IDA* [1]
> and ITS [2], both of which combine iterative deepening with an A*-style
> heuristic function) are better for this problem because they only need to
> store the nodes on the current search path.  For an analysis of the kinds
> of problems on which such algorithms do well or poorly, see [3].
> 
> Such algorithms are discussed in several well known AI textbooks.  For
> example, Luger and Stubblefield's "Artificial Intelligence" discusses
> iterative deepening; and both iterative deepening and IDA* are discussed
> in Ginsberg's "Essentials of Artificial Intelligence" and Russell and
> Norvig's "Artificial Intelligence: A Modern Approach" (the latter is my
> current favorite as an AI textbook).
> 
> [1] R. Korf. Depth First Iterative Deepening: An Optimal Admissible
>     Tree Search.  Artificial Intelligence 27(1): 97-109.
> 
> [2] S. Ghosh, A. Mahanti, and D. S. Nau. ITS: An efficient
>     limited-memory heuristic tree search algorithm. AAAI-94, 1994.
> 
> [3] A. Mahanti, D. S. Nau, S. Ghosh, A. K. Pal, and L. N. Kanal. 
>     Performance of IDA* on trees and graphs. Proc. AAAI-92, pages
>     539--544, July 1992. 
> 
> ** Note to Mark Kantrowitz:  maybe this should be included in the FAQ?

Are you looking for an *optimal* solution, or *any* solution?

A reasonable solution can be found by decomposing the problem:

Consider the board  A  B  C  D  with tiles numbered 1 to 15.
                    E  F  G  H
                    I  J  K  L
                    M  N  O  P

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

First, put 1 in place A.
then 2 in B, without moving 1
then 3 in D, "" 1 or 2 
then 4 in H, "" 1,2,3 and whatever is in C
"Rotate" 3 and 4 into C and D, w/o moving 1 or 2

You can now remove the top row from the problem space

Put 5 in E
then 13 in I, w/o moving 5
then 9 in J, "" 5 or 13
Rotate 9 and 13 into I and M 

You can now remove the left column from the problem space

...etc...

While the solution will probably not be optimal, it won't
be too bad, as you never have too move a piece once it is in place.
(Not counting the "rotate" stuff at the end of a row or column.)

The search for the shortest path to put tile X in position Y w/o
disturbing tiles S{} should be fairly simple.

Have fun!

 ____                     ____                                          ____
(____)-------------------(____)----------------------------------------(____)
 |  |  Thomas W. Cox      |  |          ****      *****          ****   |  |
 |  |                     |  |        ***       ***  **        ***      |  |
 |  |  System Developer   |  |       ***       ***   **       ***       |  |
 |  |  SAS Institute      |  |      ****      ****   **      ****       |  |
 |  |  Office R4147       |  |      ****      ****   **      ****       |  |
 |  |  Cary NC 27513      |  |      ***       *********      ***        |  |
 |  |  919.677.8000x6295  |  |      ***       ***    **      ***        |  |
 |  |                     |  |     ***       ***     **     ***         |  |
 |__|  sasthc@unx.sas.com |__|  ****      ****       **  ****           |__|
(____)-------------------(____)----------------------------------------(____)


