Questions tagged [knights-tour]

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

223 questions
0
votes
1 answer

optimizing Knight's tour on a chess board

my code below I have a little knight's tour problem I'm trying to solve: find the smallest number of moves from point A to point B on an N*N chess board. I created a board, and used a simple algorithm: 1. add point A to candidate list and start…
CIsForCookies
  • 12,097
  • 11
  • 59
  • 124
0
votes
0 answers

What's wrong with my knights tour solution

I have been trying to solve Knight's tour problem using backtracking.Here is my code :- using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication12 { class…
Anurag
  • 307
  • 5
  • 9
0
votes
1 answer

Get min value of a rule in Prolog

I'm trying to solve Knight Tour problem. I need to get the position that has the minimum amount of movements. I have my rule that calculates the number of moves in a position (search_path), but I need to get the min of that rule (search_path_min). …
Joseph
  • 97
  • 3
  • 9
0
votes
1 answer

how can i move around the board for knights tour [java]

I'm trying to make a knights tour program. Right now I have it so the knight starts at around the middle of the board and moves in a circle. But now if I want the knight to start at 0,0 I just get errors saying array out of bounds. I'm guessing that…
swen
  • 3
  • 5
0
votes
1 answer

java recurison - Need help for solving backtracking Knight's Tour

I am working on the Knight's Tour problem. In my program the user can select a number n equal to 3 or higher. The number will determine the table's size by n*n in a two-dimensional array. Then the knight will start it's tour based on the starting…
0
votes
2 answers

Recursive Java programming, Knight's Tour driving me nuts

I've been working on a school project and can not figure out the problem. The problem that the knight jumps back where it was in the the last step when a dead end occurs. I've added the output for a 4x4 test and you can clarly see that the knight…
0
votes
2 answers

Implementing knight's tour graph and using it with different search algorithms

I want to implement knight tour and run it with different search algorithms like bfs,dfs,a* and so on.User selects a place on chessboard and then things will be done.The question is after choosing, should i create the whole graph, like all possible…
0
votes
1 answer

Knight's Tour algorithm - TypeError: Cannot set property of undefined

I'm trying to implement Knight's Tour algorithm from the book "Algorithms and Data Structures" by N. Wirth. The original version is written in Oberon: https://drive.google.com/file/d/0B7KbTu852Hi3cG5jYUVDX3Z4Yjg/view?usp=sharing The problem is that…
0
votes
1 answer

Why is the following Code for "A knight's tour" not working properly?

I am using following code in Codeblocks IDE in C, trying to solve the Knight's tour problem using recursion and backtracking. But the thing is it goes on forever and doesn't give any output, though I think it is not a case of Infinite…
Prakhar Londhe
  • 1,431
  • 1
  • 12
  • 26
0
votes
2 answers

How to estimate the time and memory consumption of a program that uses recursion Java

I'm solving a Knight's tour problem. The size of a desk is 5X5, and starting point for a tour can be any square. I found all possible open solutions, and calculated the memory usage as well as time consumption of a program. I'm using recursion and…
user2992672
  • 398
  • 1
  • 3
  • 10
0
votes
1 answer

How to determine if a "knight" that can take (i,j) steps at a time can cover an NxN board?

Normally knights move (1,2) steps at a time i.e 1 step in one direction, and two in the other. In a general version it can move (i,j) steps at a time. I'm not sure if this is a knight's tour problem, since I don't remember a restriction on visiting…
ssh
  • 195
  • 1
  • 11
0
votes
2 answers

Knight's tour, count steps that takes to go from A to B

A knight is located in position (a,b) and needs to take the king located in (c,d). How can I: A: Visualize the tour B: Calculate the min steps needed to go from (a,b) to (c,d) The implementation I've found are basically a sequence of moves of a…
user1532587
  • 993
  • 1
  • 14
  • 39
0
votes
0 answers

Implementing the Knights Tour with C#

I'm trying to implement the Knights Tour problem in C#. I refer to the C++ code in this link: http://www.geeksforgeeks.org/backtracking-set-1-the-knights-tour-problem/ I've been scratching my head for hours now, trying to figure out why my c# code…
ohadinho
  • 6,894
  • 16
  • 71
  • 124
0
votes
1 answer

Recursive Breath First Search works on first execution but not following executions

The solution presented at CodeReview works fine on CentOS 7.1. I have tried to port it to Windows 7, Visual Studio 2012. With minor edits to allow for the parts of C++11 that VS 2012 doesn't support the code compiles, and the first execution of the…
0
votes
1 answer

stuck in infinite loop in knight tour backtracking

This code is stuck in an infinite loop in the knight tour problem which i am solving using backtracking. I have used x[8] and y[8] array to access possible moves in 8 directions. Also I have formed these x and y arrays same as an already solved…
tricoder
  • 95
  • 1
  • 8