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

Attempting to do A* Search with heuristic but states aren't being recorded

So I am working on this 3x3 game, where you are given a current state, for example: 1 5 6 3 7 b 2 8 4 and you want to reach the goal state of: b 1 2 3 4 5 6 7 8 So I have written all the other methods in my code which I posted below. The…
3
votes
2 answers

A good randomizer for puzzle-15

I have implemented a puzzle 15 for people to compete online. My current randomizer works by starting from the good configuration and moving tiles around for 100 moves (arbitrary number) Everything is fine, however, once in a little while the tiles…
user151496
  • 1,849
  • 24
  • 38
3
votes
9 answers

Best way to hash ordered permutation of [1,9]

I'm trying to implement a method to keep the visited states of the 8 puzzle from generating again. My initial approach was to save each visited pattern in a list and do a linear check each time the algorithm wants to generate a child. Now I want to…
Amen
  • 1,524
  • 5
  • 22
  • 41
3
votes
0 answers

8 puzzle using blind search (brute-force) and manhattan distance heuristic

I developed my own program in Python for solving 8-puzzle. Initially I used "blind" or uninformed search (basically brute-forcing) generating and exploring all possible successors and using breadth-first search. When it finds the "goal" state, it…
Abdul Qadir
  • 439
  • 1
  • 6
  • 12
3
votes
1 answer

Using A* algorithm to solve 8-puzzle boards (Board data type works fine)

Hi I'm using java to create a Solver program that uses the assistance of HeapMinPQ and nodes in order to solve any board based on the "8 puzzle" format. I've already created by "Board" data type which uses a two-dimensional array to account for the…
bluesunlight234
  • 95
  • 2
  • 11
3
votes
1 answer

How to solve 15-puzzle paradigm in Prolog with Manhattan & Hamming Heuristics

I have this implementation of the 15-puzzle game, using Prolog (Swipl). I have already implemented the A* search using Manhattan heuristic, but now I need to add hamming heuristic. Do yo know how to implement it? :- op(400,yfx,'@').…
Alex Silva
  • 51
  • 1
  • 6
3
votes
1 answer

Solving 8-puzzle game using DFS

I am trying to solve the 8-puzzle problem with DFS starting from this code implemented with BFS. What is the easiest approach of doing it? All the codes I've researched are either working and incomplete which sheds me into more of a confusion than I…
3
votes
1 answer

Solving 8 puzzle with Best-First Search in Prolog

as the title says, I have to make a prolog progam that solves the 8 puzzle using best-first search, I'm new to Prolog and A. I. so I'm having a hard time. For now what I have is the move rules: %% move left in the top row move([X1,0,X3, X4,X5,X6,…
Sathania
  • 69
  • 1
  • 1
  • 7
2
votes
1 answer

Puzzle 15 Game / Unsolvable configurations

I am making a program with some friends but we run into a problem in the code that often prevents us from testing it. We are making a Puzzle 15 game, we made a code in the separate "functions.c" file where we calculate the configuration inversions…
tomycero
  • 21
  • 1
2
votes
1 answer

Why Best First search Python Implementation is not giving correct output

I've tried to implement a Best First Search Algorithm on 8 puzzle problem.But I get the same path as in A* code no matter whatever matrix I take. Also, can someone help me to print the heuristics under each matrix? I only get "1" in the output. Best…
minsuga
  • 321
  • 3
  • 11
2
votes
1 answer

Why my solution is unable to solve 8puzzle problem for boards that require more than 1 move?

I am trying to solve 8 puzzle problem in python given here in this assignment -https://www.cs.princeton.edu/courses/archive/fall12/cos226/assignments/8puzzle.html My goal state is a little different from what is mentioned in the assignment - #GOAL…
2
votes
2 answers

Python implementation of BFS to solve 8-puzzle takes too long to find a solution

My implementation of BFS in Python to solve the 8-puzzle is taking at least 21 minutes to find a solution. How can I improve my code in order to achieve a better time? The way I've implemented is very inefficient. I'd like to know any advice about…
2
votes
1 answer

Is it wrong practice to modify self inside functions (8-puzzle game)?

I was trying to make my own solution for 8 puzzle game. Online I found mostly solutions with return statements. Is it wrong practice to code this way ? import numpy as np class Game(object): def __init__(self, n, config): array =…
xNesTea
  • 23
  • 5
2
votes
1 answer

How to prevent A* search from repeating paths

I am doing the 8-puzzle challenge where I have to arrange the tiles in the right order with the shortest path cost. for my heuristic, I've combined the # of misplaced tiles+ distances of n tile to its goal position. the goal is 1 2 3 8 0 4 7 6…
msc
  • 67
  • 8
2
votes
0 answers

Prolog: Optimizing a puzzle solver after trying really hard

I am trying to solve a 15 puzzle in Prolog, I need to find the minimal number of moves. Here we have a sample puzzle with detailed answer. https://rosettacode.org/wiki/15_puzzle_solver I am using A* search, using manhattan distance as the…
Andrew Au
  • 812
  • 7
  • 18
1
2
3
11 12