1

I have modified the question on n-puzzle. In this scenario, the puzzle has two blanks instead of one blank.

Initial State
3   5   1   
4   6   -   
7   2   -   


Goal State
-   1   7   
3   2   -   
5   6   4   

Is there any algorithm that I can use for this?

  • 2
    It's always solvable, because for example you can swap the 6 with the 2 without changing anything else. – user3386109 May 13 '20 at 20:12
  • Sorry, I don't get it? @user3386109 – Lakshan Weerasinghe May 13 '20 at 20:21
  • 1
    In the standard puzzle (with one blank) [exactly half of the starting positions are not solvable](https://en.wikipedia.org/wiki/15_puzzle#Solvability). If you have a starting position that *is* solvable, you can make it unsolvable by switching two adjacent numbers. But with two blanks, you can always swap any two numbers without changing any of the other numbers. So you can always solve the puzzle. – user3386109 May 13 '20 at 20:27

1 Answers1

1

All existing algorithms that solve the regular sliding tile puzzle (such as A* or IDA*) can solve this variant as well. The puzzle with multiple blanks is equivalent to a pattern database for the sliding-tile puzzle - the exact solution to the puzzle with some pieces replaced with blanks can be used as a heuristic for the original puzzle with only a single blank.

(To be precise they are equivalent to additive pattern databases. You can combine several together and add their heuristic values as long as the action cost of swapping two blanks is 0 and none of the tiles are duplicated.)

Nathan S.
  • 5,244
  • 3
  • 45
  • 55