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
-1
votes
1 answer

Why are both of the arrays being modified when I copy one array into another?

I am trying to solve 8puzzle problem and for that, I need neighboring elements of the current state. Current state(or data) looks like this - a 2D array with 0 representing blank state. 1 0 2 3 4 5 6 7 8 I have created a function that takes 5…
-1
votes
1 answer

8 Puzzle A* java Implemenation

I am told that A* implementation on following 8 puzzle Solver is wrong, can anybody please tell me where it's wrong and how to correct it? Also: this throws Exception in thread "main" java.lang.OutOfMemoryError: Java heap space even though Build…
BlueMango
  • 463
  • 7
  • 21
-1
votes
1 answer

Garbage value in parent node

I am implementing breadth-first search to solve the 8-puzzle. When I try to create new nodes and point at the current node using the this pointer the parent pointer returns garbage values. Is this due to iterator invalidation? Is there a way to…
-1
votes
1 answer

How can I simplify the code for moving tiles in a 8 puzzle?

In an 8-puzzle, when it finds the blank tile (which is represented by 0) in the board, it needs to get all neighboring boards that can be reached in one move. As I have mapped a 2-dimensional board to a 1-dimensional array in my implementation, it…
pedim
  • 69
  • 2
  • 5
-1
votes
1 answer

JavaScript slider puzzle

Ultimately I'm making a slider puzzle with a table, but at the moment I am generating a new puzzle and shuffling the tiles, but it appears that something in my code is making this work incorrectly. (not all the table cells are populated, etc.) Any…
user5407906
  • 87
  • 1
  • 8
-1
votes
1 answer

Prolog - print list 2

I have a Prolog project to create about the "Puzzle 8". I'm new with this language. I have many doubts so I came here to resolve at least one. Here is my code: puzzle([1, 2, 3, 4, 5, 6, 7, 8, 0]). affiche_puzzle :- puzzle(Puzzle), …
Cesar
  • 25
  • 4
-1
votes
1 answer

Trouble passing 2D array in C++ 8 Puzzle

For some reason I can't get the distance function to work. Could someone explain to me what I am doing wrong? Main Function: #include #include using namespace std; int distance(int**, int); int main() { int m; int goal…
Kurt
  • 196
  • 1
  • 14
-1
votes
2 answers

How to begin coding a brain for a 8-puzzle game to calculate least moves

I managed to solve this problem with a brute force with RNG it takes around 4-5 seconds to find the best solution even though the working grid is a 3x3. I want to know how do I make it possible to generate the same moves the brute force finds…
SSpoke
  • 5,656
  • 10
  • 72
  • 124
-2
votes
3 answers

Generate 3x3 puzzles with the same difficulty?

I want to generate several 3x3 puzzles (https://datawookie.netlify.app/blog/2019/04/sliding-puzzle-solvable/) with the same difficulty where difficulty is defined as the minimum necessary moves to reach the solution. For example, in a puzzle…
-2
votes
1 answer

" free(): invalid pointer:" 8-puzzle BFS

I am trying to write a breadth first search program to solve the 8-puzzle. When I run the following code I get the following error: * Error in `/home/a.out': free(): invalid pointer: 0x0000000001f81430 * Aborted I am pretty sure the issue is…
-2
votes
1 answer

How to do the code in Slide Puzzle. On JAVA

*First my English is not good please try to understand me. I want to create the Slide Puzzle game but I didn't understand about method to slide a block and method Click for slide event.(I mean MouseLister) Now I have only GUI public PGWindow() { …
-2
votes
1 answer

Finding unique solution puzzle python

x = np.array([[0,1,11],[0,2,11],[0,3,10],[0,4,10],[0,5,9],[0,6,9],[1,7,9], [1,5,11],[1,6,11],[2,7,11],[2,8,10]]) I'm pretty new to this so i'm gonna call things like this [element1,element2,element3] i have an array as shown above,…
Arohi Gupta
  • 95
  • 1
  • 8
-3
votes
1 answer

How to solve 8-puzzle problem using Breadth-First search in C++

I want to build a c++ program that would solve 8-puzzle problem using BFS. I want to show every generated state. But the problem is, I don't know how to generate state. I just want some clean function which will efficiently generate states and there…
-3
votes
1 answer

8 Puzzle Code. Having Issues with my my queue not populating and i can not find the location of my bug

As the title states i'm having trouble finding the error with the way in which my queue is being populated. It should be holding every visited state node until they have been processed. but the queue is not being populated as it should be. Can…
-3
votes
2 answers

Starting the 8 puzzles

How would I go about creating the board given any x and y coordinates for the start nodes. For example, if x=3 and y=2 the board should like: 1 2 3 4 5 x 6 7 8 An example in java or pseudocode would be extremely useful.
mcseth antwi
  • 131
  • 1
  • 1
  • 9
1 2 3
11
12