A knight's tour is a sequence of moves of a knight on a chessboard.
Questions tagged [knights-tour]
223 questions
0
votes
1 answer
The Knight's Tour problem in C isn't working for me
I wrote this program that did something similar to the knight's tour problem and decided to try and get the same program to solve the knight's tour without changing too much of the code. Unfortunately I was not able to do it, not because it wasn't…

why
- 37
- 4
0
votes
3 answers
My knight's tour algorithm possibly is running on an infinite loop
Here's the code i wrote.
#include "genlib.h"
#include
#include
#include "vector.h"
struct square
{
int x;
int y;
};
bool knighttour(square start,int &counter,int cb[][8]);
Vector generatemoves (square…

Vaios Argiropoulos
- 387
- 1
- 8
- 18
0
votes
1 answer
How to execute all squares the knight will stop on along the way while going from the one position to another?
I've been doing Knights Travails project, and I just can't come up with a solution like I want: (should show the shortest possible way to get from one square to another by outputting all squares the knight will stop on along the way), I can do that…
0
votes
0 answers
how to show the coordinates of each minimum moves the knight took to reach the target?
the code so far only displays an integer of the minimum steps the knight took to reach the target but how can i display that and all the moves coordinates that it took to reach said target position whilst avoiding the trap coordinates and still…

tomato
- 1
- 1
0
votes
1 answer
Python Knight's Tour Special Program
I want to make a program where I can input a:
chess board size (w and h)
max number of moves the knight can make to reach any square
knight's starting position
I want it in this format:
Size: 10
Moves: 2
Knight: 2,4
2 . . 1 2 1 . . 2 .
. 2 1 2 . 2…

Lashen Dharmadasa
- 197
- 8
0
votes
0 answers
Backtracking problem in Knights tour algorithm
**Edit: I managed to find solution for my problem so i put the correct code in place. Everything works perfect now.
I'm trying to complete the last stage of a project in Jetbrains Academy but I can't make my approach to the problem work:
It gives…

Kostas
- 13
- 5
0
votes
1 answer
Move and update chess piece on chessboard without clicks Tkinter Python
I am trying to make a GUI for the Knight's Tour problem. I already have the solution of the problem in the form of a sorted dictionary. Now I just want the Knight's chess piece to follow the path shown by the saved dictionary and trace it in the…

Aman
- 113
- 2
- 10
0
votes
1 answer
how to write the moves the knight can perform?
I wrote a program that examines threats of tools on a chessboard on other tools.
I want to write the movements that a knight can perform. I thought about checking the distance in Math abs in two options- two Horizontal blocks and one vertical or two…

Shadow
- 1
- 2
0
votes
2 answers
Determining if a knight can pass through all cells in a 2d array - if so print board
I need an advice regarding this problem called "Knight Path".
Given an n*n board whose cells are initialized to 0, I need to determine, given an arbitrary Knight's position, if the knight can pass through every cell on the board exactly once, where…

oryan7
- 1
- 4
0
votes
1 answer
Does Knight tour Problem solve depend on sequence of knight move?
Hello I am currently reading at the knight tour problem at Geeksforgeeks https://www.geeksforgeeks.org/the-knights-tour-problem-backtracking-1
I am testing the code bymyself and when I change the sequence of
knight moves at the code
let xMove = […

echo
- 15
- 4
0
votes
1 answer
Why the same algorithm and the same data appied to different application can show significant difference.(Knight's Tour)
This is a Knight's Tour problem.
The first application:
import java.awt.*;
import java.util.ArrayList;
import java.util.Comparator;
public class GcdsHorse {
private static int X;
private static int Y;
private static boolean[] visited;
…

Frederick_Chen
- 1
- 1
- 2
0
votes
1 answer
How do you find possible x, y values for the Knight's Tour Problem?
I was looking into the Knight's Tour Problem, where the solution is obtained when a chess knight piece moves to every square on a grid exactly once. However, upon looking at different solutions for the problem, I keep seeing a specific array of…
0
votes
1 answer
How to avoid accessing an invalid position in a 2d array?
I'm working on the Knight's Tour problem and I'm making a recursive solution for it. https://www.chess.com/terms/knights-tour-chess#:~:text=The%20knight's%20tour%20is%20a,same%20square%20more%20than%20once.
I have a matrix[8][8] and a method called…

Waifu_Forever
- 87
- 3
- 7
0
votes
0 answers
Knight Tour time limit exceeded
Problem Statement:
Given a N*N board with the Knight placed on the first block of an empty board. Moving according to the rules of chess knight must visit each square exactly once. Print the order of each the cell in which they are…

bhaibtado
- 1
- 1
0
votes
1 answer
Knight's Tour only solvable for one size board
I am trying to implement a knight's tour finder in python. Assuming the knight must start at the top left corner (called (0,0) here), it finds a solution for a 4x3 field, but not for any other fields.
def maneuvrability(position, path, width,…

PeterPefi
- 87
- 1
- 1
- 7