Questions tagged [knights-tour]

A knight's tour is a sequence of moves of a knight on a chessboard.

223 questions
0
votes
0 answers

Infinity Loop in Knight's Tour Using C++

I am trying to solve the knight's tour problem, but it's getting stuck in an infinite loop. I tried debugging but no change. Could someone please help me out? Thank you. #include #include using namespace std; void…
Sridev
  • 1
0
votes
1 answer

Trying to solve Knights Tour on nested vector> but is is not working

I have written a code for knights tour problem which work for 2D array but not for vector> WORKING CODE #include #define N 8 using namespace std; bool isPossible(int sol[N][N], int x, int y) { if (…
0
votes
1 answer

Removing a1 field from chess board in Clingo knight path program

I need to do some symulations about knight path and Hamilton cycle on chesseboard, but i wondering what if i exclude some fields from chesseboard xchessboard(1..8). ychessboard(1..8). time(1..8*8+1). xypos(X,Y) :- xchessboard(X),…
0
votes
1 answer

Knight's tour problem compilation doesn't end

Could anyone point the flaw in the code? The idea that I used is backtracking with recurrence and I would like to stick to this way of sloving the given problem. When the variable moves is <= 60 couple of answers are printed instantly though the…
somerndguy
  • 103
  • 3
0
votes
1 answer

Backtracking problem similar to Knight-Tour-Problem

I am trying to solve a similar problem to the Knight-Tour-Problem. The problem: A knight is placed on the upper-left square of a chess board. You are given a vector of numbers(the numbers represent the squares of the chess board, as numbered from…
0
votes
0 answers

Returning boolean values in a backtracking algorithm

I am working on the famous knight tour problem in python using the backtracking algorithm. I'm confused as to why the computer goes back to the last working case if the current case returns a False value. Let me elaborate. In the above program, the…
Pravimish
  • 111
  • 4
0
votes
2 answers

Issues with Knights Tour

I've made this piece of code to complete the knight's tour, where you have to make it to every square on the chessboard with a knight with no repeats, but I'm having some issues. It only ever prints an empty chessboard with no moves made, and I'm…
0
votes
0 answers

Find bug in my Knight's Move Python Program

Code I am trying to build a Knight's Move Program everything working fine but there is a hidden bug in this code that I cannot find. Can anybody spot the problem? from itertools import product def solution(src, dest): A = [[0, 1, 2, 3, 4, …
0
votes
0 answers

Knight's tour in Java with rocks

I am working on the following problem: Write a method that, given a chessboard with one knight, rocks on some of the squares, and a target position, indicates whether or not the knight can reach the target without landing on any rocks, and if so,…
ppan92
  • 1
  • 1
0
votes
0 answers

C programming: live console display of recursive function output (knight's tour)

I'm stuck at my first more complex coding task in C: developing a program that solves the knight's tour (chess, knight has to visit every field on the board only once) and it also should have a live display, showing which move the program is taking…
Marcus
  • 11
  • 1
0
votes
0 answers

Knight's Tour Heuristic c++

I'm stuck. I know that I want my program to make a move, subtract one value from the possible moves of the heuristic and when a place reaches 0 or if it is touched then I don't want it to try for it. I'm trying to make the Knight's tour go for the…
Tank Main
  • 9
  • 1
0
votes
0 answers

Online Judge Give Wrong Answer

I am doing the Knight move Problem for my class. My codes (Python 3) are like this. I get the right output on my PC But when I submit to Online Judge, I get this result. I think the that input should be multiple line and put it in to the list. What…
faijiuy
  • 55
  • 1
  • 9
0
votes
1 answer

Breadth First Search Knight Moves - pop() empty queue

I am doing the Knight move Problem for my class. My codes (Python 3) are like this. But when I run, I get this error. I think the values are not going in the list. What should I do? Help me!!! This is the question: Find the shortest closed tour of…
faijiuy
  • 55
  • 1
  • 9
0
votes
1 answer

R, creating a knights tour plot with a matrix indicating the path

I need to create a knight tour plot out of such an exemplary matrix: Mat = matrix(c(1, 38, 55, 34, 3, 36, 19, 22, 54, 47, 2, 37, 20, 23, 4, 17, 39, 56, 33, 46, 35, 18, 21, 10, 48, 53, 40, 57, 24, 11, 16,…
mathew
  • 3
  • 3
0
votes
1 answer

Classic Knight Tour Problem , 1 cell unvisited

I am trying to solve Knight's tour using Backtracking, where Knight has to visit all the cells Anyhow I am always getting 1 cell unvisited. Example for 4x4 chessBoard size, I am getting output as: 1 8 13 10 14 11 4 7 5 2 9 12 0 15 6 3 As you can…