Questions tagged [sliding-tile-puzzle]

For algorithm or programming questions about sliding puzzles (such as the 8-puzzle or 15-puzzle), where the player is challenged to slide randomized, numbered tiles along certain routes on a board in order to arrive at a certain end configuration. There is one tile missing, in order to facilitate movement.

For algorithm or programming questions about sliding puzzles, such as the 8-puzzle or 15-puzzle, which challenge the player to slide randomized, numbered tiles along the playing surface in order to arrive at a certain end configuration. There is one tile missing, in order to facilitate movement of other tiles across the board.

Commonly, such puzzles are solved with an A* algorithm.

166 questions
0
votes
1 answer

How do I take inputs from a user and put them into a matrix?

I know this is probably very basic but I have been trying for hours and still can't figure this out on my own. So right now I am doing the 8 puzzle game for my AI class. I need the user to enter a series of numbers, say: "032 145 678" and I need to…
0
votes
1 answer

Objects not being added to HashMap

I am creating a puzzle game and am now having the 8 pieces randomly arranging themselves in a 3x3 grid, but not all the images are be added to the HashMap. Does anyone see why? Here is the code I use to arrange the puzzle: private…
0
votes
0 answers

Best-First Search 8 squares solver works for easy cases only

For my AI class, we were assigned to write a solver for the 8 squares puzzle. My program works for cases with few moves to achieve a solution (up to 9), but much more than that causes infinite recursion. I'm storing the previous states to prevent…
Carrara
  • 1
  • 3
0
votes
0 answers

Optimization for 8 puzzle solutions to store in trees structure

I have a breadth first search to find the best solution to an 8 puzzle. In order to make sure I don't execute the same function call on the same puzzle move I have created a tree structure. It doesn't store the puzzle, just creates a pathway in the…
zissler
  • 107
  • 1
  • 1
  • 11
0
votes
2 answers

Does 8 puzzle solvability rules work for any goal state?

Ive learned that the solvability of a 8 puzzle can be checked via following certain rules. https://www.cs.bham.ac.uk/~mdr/teaching/modules04/java2/TilesSolvability.html http://ldc.usb.ve/~gpalma/ci2693sd08/puzzleFactible.txt. My question is whether…
0
votes
1 answer

Solving a 4x4 Puzzle Grid

I'm attempting to create a program that will find the steps to solve a puzzle with the following rules: Given any set of colors in a 4x4 grid, attempt to match to an ending pattern with the same number of colors. Colors are not swapped, but…
Rhys
  • 3
  • 3
0
votes
2 answers

How to reduce long execution time in an A* search for 8-puzzle

I'm trying to implement heuristic search strategy A* to the puzzle "8-puzzle" in Lisp. To run my search I use the command: (run-best '(0 1 2 3 4 5 6 B 7) '(0 1 2 3 4 5 6 7 B)) Where the first state is the start goal and the second is the end…
Asia x3
  • 606
  • 2
  • 16
  • 37
0
votes
1 answer

Using breadth-first search to solve 8-puzzle

I am trying to solve 8 puzzle problem using breadth first search in PHP, but I keep on getting an error. I tried to find what's the syntax error for the error showing T_Variable in my code, I don't see one. Parse error: syntax error, unexpected…
0
votes
2 answers

Last function code of 8puzzle in Python

def result(matrix): matrix2=matrix for a in possible_moves(matrix2): matrix2=matrix print() liste=swap_blank_tile(matrix2,a) print(liste) print(matrix) I have this code in…
Uğur
  • 47
  • 1
  • 7
0
votes
1 answer

8-puzzle images dimensions incorect

Now it works for get my image in my buttons but there is something wrong when i put the parts of the image in the buttons. I think the fault is in the for loop where i put the parts of my image in the buttons my…
Jan
  • 3
  • 3
0
votes
1 answer

8-puzzle Java methods

i can't get the logic of my shuffling method in my code also my image method idk what I need to do for fix this. I have try almost everything but Always I get exceptions. My isFinished() method is almost working but there is one little problem with…
jan
  • 1
  • 1
0
votes
0 answers

15 puzzle make only the numbers/boxes near the empty one moveable

I'm trying to create a 15 puzzle game(like this one:http://migo.sixbit.org/puzzles/fifteen/) using jquery and javascript. I have come pretty far with the code but now I'm stuck with a little problem. My problem is that all boxes/numbers are moveable…
0
votes
1 answer

A* Algorithm 8-puzzle

I have read many pseudo code for the A* algorithm, but neither of them actually explain how to output the solution. I believe I understand the concept of using a priority queue for the not yet visited and a has table for the explored, but when I go…
Dave Smith
  • 177
  • 1
  • 3
  • 11
0
votes
1 answer

Logic for checking if 15 slider puzzle is solved

I've been writing out a Javascript version of the 15 slider puzzle and am able to simulate the "moving" of the tiles through swapping innerHTML values. I'm also using instead of an array, as I've seen others suggest. Given my code, how would I go…
0
votes
2 answers

Simple Logic to identify edges in matrix

I am trying to calculate valid neighbour of a node Array contains elements like [2,8,3,0,1,4,7,6,5] Matrix: 2 8 3 0 1 4 7 6 5 It's similar to 8 puzzle logic. In the above matrix, i can swap 0 with 2 or 1 or 7. i…
iPhone Guy
  • 1,285
  • 3
  • 23
  • 34