2

I am applying A* (and IDA*) search with manhattan heuristic for finding solution to 15-puzzle problem.

Using the fact that i dont want an optimal solution for the problem how can i can speed up the search as the current routine is too slow.

gabber12
  • 1,114
  • 2
  • 11
  • 18
  • Please note that 15-puzzle may not have a solution; a known example is the basic setup with "15" and "14" swapped. – Lyth Jun 04 '13 at 07:07

1 Answers1

1

Well, it's not exactly a solution, but it might help. Once I've been working for a HOG game with that same puzzle as a minigame and it turned much easier to generate a problem, than find a solution.

What I mean is, we can turn a solved puzzle into unsolved by randomly moving "window" according to rules. And logging each field position for future use. Then we let user play a bit and if she gives up, we can solve a puzzle for her easily by finding the common position in user and our log. We just play back via user log to the common position and back from it to the solved position via ours log.

Of course, this is a hack and not a real solution, but it works fine in gamedev. And not only for this particular game. Most repositioning puzzles can be "solved" this way.

akalenuk
  • 3,815
  • 4
  • 34
  • 56
  • It must have looked like "Ok, player, you did everything wrong, so I undo now what you did and show you the right thing" – Lyth Jun 04 '13 at 06:52
  • Not i what i am looking for! – gabber12 Jun 04 '13 at 06:53
  • That's why we play "solving" really fast. – akalenuk Jun 04 '13 at 06:55
  • But seriously, common position is not always found before the first move. Player can be very close to the head of our log while quiting. And people don't quite well remember all of own moves so it have never been an issue. But yes, considering moves count and logic it is not the best solution at all. – akalenuk Jun 04 '13 at 07:01