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

Check adjacency of tiles in a grid

I am working on a sliding block puzzle solver, and I would like to extend the game to a grid with arbitrary sides and blocks of all kinds of shapes. I define a grid with a given height and width and I translate that into a dictionary with a running…
JansthcirlU
  • 688
  • 5
  • 21
1
vote
0 answers

A-star search. Sliding tile puzzle. Which heuristic is this?

I am currently trying to learn how to code a sliding tile puzzle with 8 tiles in Python 3. In one of the resources I've found, the person explains the Manhattan distances heuristic, but then goes on to write the piece of code shown below. By looking…
1
vote
1 answer

How to check n-puzzle with two blanks is Solvable?

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…
1
vote
0 answers

Java solving 15-puzzle with iterative deppening search

I'm trying to solve 15-puzzle (sliding tile puzzle) with iterative deppening search. This is my initial state : 1 2 12 13 5 6 7 8 9 3 4 0 11 14 15 10 And this os my goal state : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 0 I have a class of node to…
Daniel16
  • 113
  • 8
1
vote
1 answer

Searching/deleting from STL Priority Queue?

I am tasked with programming an A* Search Algorithm for an assignment that involves solving an '8-Puzzle'. One of the algorithm's steps is to: Add all the extended paths to Q. If the descendant state is already in Q, keep only the shorter path to…
LJ__
  • 23
  • 3
1
vote
1 answer

8 Puzzle: Sorting STL Heap/Priorirty Queue containing pointers to object by member variable

I'm working on implementing a Best-First Search algorithm to solve an 8-Puzzle problem for an assignment. Based on the requirements, it must be implemented using a (min) Priority Queue or Heap located in the Standard Template Library (STL). I…
LJ__
  • 23
  • 3
1
vote
0 answers

"5-Puzzle" Common LISP using different searches

Im trying to use my professors "5-Puzzle" program in order to perform depth-first, best-first, and breadth-first searches. I have the program loaded into Allegro CL and I was given a finish but I need to create a start for the program and then call…
1
vote
0 answers

8 puzzle using depth first search method

Here is my code for 8 puzzle using dfs. Can someone tell how to remove duplicate elements from qList and visitedList? I want only one element representing a single state in queue and visitedList. The problem solves the 8 puzzle problem with the use…
1
vote
0 answers

Manhattan distance for 8-puzzle in python

I'm trying to compute the manhattan distance for an 8-puzzle with A*. I realize that I'm doing something wrong with how I compare the current positions with the goal, but I can't figure exactly what I'm doing wrong (I'm pretty new to python). Please…
1
vote
2 answers

ArrayList add does not increase the list

I'm trying to solve the 8-puzzle problem using the heuristic search. I'm using a 3*3 matrix to represent a possibility. The code is not complete, but when I try to add the explored element to the explored set(which is an ArrayList), it only updates…
1
vote
1 answer

Doubly-Linked list Parent pointer changing

implementing a greedy solution to solve and 8-puzzle Greedy.h: class Greedy { const string Goal = "12345678_"; State current; string startState; int nodesCreated, nodesExpanded; priority_queue greedyQueue; set
Kyle Gray
  • 115
  • 1
  • 7
1
vote
2 answers

n-puzzle DFS solution works for 2X2 but StackOverflowError for 3X3

My solution for npuzzle works with 2x2 but stack over flow error with 3x3. I am not able to figure out whats wrong. I am using DFS to check if any of the path has the solution. Algorithm, - Move piece left, right, up & down. - For each check…
1
vote
1 answer

A* 8 puzzle written in Java not working for certain initial states

I had to implement an 8 puzzle solver utilizing the A* algorithm with two heuristics. The first heuristic was just the sum of the out-of-place tiles, the second is the sum of the Manhattan distances of all tiles from the goal state, which we are…
1
vote
2 answers

Trying to implement my movement with left down right and up arrow keys for 15 puzzle game

I need help with fixing my movement code. I am not so javascript friendly. I am just using the old fashion table technique and javascript. I cannot use any jquery or other sources. Here is the code: