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 to make choice between two descendant board arrangements in the 8-puzzle game?

I'm trying to write 8-puzzle solver but I couldn't yet: I use Manhattan priority function and I wonder, how to make choice between descendant board arrangements if they have the equal priority values. For example: this is initial board arrangement: …
godot
  • 3,422
  • 6
  • 25
  • 42
0
votes
0 answers

In Java, counting linear conflicts of the state of 8 puzzle

I need to find linear conflicts of 8 puzzle state, state is represented by int[8], goal state is {1,2,3,4,5,6,7,8,0}. A linear conflict would be if in a line two tiles that are supposed to be in that line are reversed. Fo example in goal state the…
Sunny
  • 605
  • 10
  • 35
0
votes
2 answers

NoSuchElementException in 8Puzzle solver

I'm trying to make a Java program that gives me the solution of the 8puzzle problem The solution procedure as the following: -First I create an initial node that contains the initial grid (initial state) I put the node in Queue I test if the node…
0
votes
1 answer

Tackling the 8-puzzle via BFS

I've heard that the 8-puzzle problem can be tackled via BFS, but I don't understand how. I wanna know the intermediate steps that I need to get from a board like this: 3 1 2 6 4 5 0 7 8 to 1 2 3 4 5 6 7 8 0 Are the intermediate steps "levels" on…
andandandand
  • 21,946
  • 60
  • 170
  • 271
0
votes
2 answers

OpenGL glut animation of 8 puzzle solving

I have solved an 8 puzzle using a BFS algorithm and stored the needed moves into an array and then converted those numbers into either 0 to say the blank space needs to move up or 1 down or 2 left or 3 right. I have no idea how i would animate the 8…
0
votes
0 answers

8-Puzzle Solver unexpected behavior

I am working on a 8-Puzzle Solver -using best-first search+ Hamming distance(tiles out of place) heuristic- which was required from us as a project. I first defined a Stat Struct in a separated cpp file which looks like this in the header file…
0
votes
1 answer

Solving the 8 puzzle heuristics

I'm very new to prolog and am having trouble with the 8 puzzle heuristics. I'm not sure how to compare the two lists (goal and start) and figure out my h value. What I am trying to do is send compare_list two list the goal and start. It should…
0
votes
0 answers

Limited DFS, slide puzzle app, path finding

I am writing simple slide puzzle (Loyd) solver. I want to solve any given solveable configuration of puzzle with dimensions 3 x 3 and more. However I got stuck with implementation of recursion. I have got tree and stack. typedef struct Node{ …
0
votes
2 answers

Infinite loop and recursion in Python

I am working on implementing an iterative deepening depth first search to find solutions for the 8 puzzle problem. I am not interested in finding the actual search paths themselves, but rather just to time how long it takes for the program to run.…
0
votes
1 answer

Does the position of the blank in an n-puzzle solution affect the set of valid puzzles?

I'm having trouble with my n-puzzle solver. Thought it was working, but it turns out it is solving insoluble puzzles. I've tried to trace it, but that's a lot of tracing and so far I see no cheating. I think I understand the algorithm for…
Ziggy
  • 21,845
  • 28
  • 75
  • 104
0
votes
5 answers

Need explanation on these bits of codes

i have recently stumbled upon a project(8-puzzle solver using A* alg) in which some codes are weird to me , because i have never seen the likes of it before . what does this line mean ? what is this ?! this[StateIndex] whats this notation ? i cant…
Hossein
  • 24,202
  • 35
  • 119
  • 224
-1
votes
1 answer

BigQuery calculation to count how many unique combinations of 4 items there are across 6 columns

I have the following table (I have covered up the current_holder column for privacy reasons): For each row, I want to find the number of times we could pull 4 unique objects out of a bag (the objects being keys, skulls, gems, coins, daggers and…
locket
  • 729
  • 2
  • 13
-1
votes
2 answers

How can I speed up my misplaced tiles heuristic for the 8 puzzle problem?

My lists are always of length 8 (7 indices), and always contain numbers 0-8 I currently do this to find the sum of misplaced tiles: def misplacedTilesHeuristic(stateObj, goal): sum = 0 for elem in range(len(goal)): if goal[elem] !=…
Aeryes
  • 629
  • 3
  • 10
  • 24
-1
votes
2 answers

Prolog for eight puzzle

%999 represent Blank tile. goal([999,0,1, 2,3,4, 5,6,7]). %To move left in any row ther are two cases: %Case_1: Blank tile in the second index. %Case_2: Blank tile in the third index. % move left in the top row move([X0,999,X2, X3,X4,X5,…
-1
votes
1 answer

generate successors from moves 8 puzzle

import copy goalState = [[1,2,3],[4,5,6],[7,8,0]] def find_zero_tile(state): for i in range(0, 3): for j in range(0, 3): if state[i][j] == 0: x = j y = i return (x,y) def…
John Smith
  • 21
  • 6