Skip to content
Advertisement

Tag: knights-tour

In the knights tour challenge, from the coordinates the player is currently on to show the user where they can move

This is from my attempt at the knights tour game, and what I was trying to do here was show the user what moves they could make from whatever position they are in, in the array. The problem arrives with NextPos[x+1][y-2]!=null in the if statement, as the exception java.lang.ArrayIndexOutOfBoundsException: -2 is thrown. I know the array is out of bounds

Knight’s Tour random move picker not working

I am working on randomizing which move my knight takes in my knight’s tour code. For some reason though, my switch statement always goes to default, instead of executing a possible move. I know my possible moves methods work because I have separately ran firstMoveChoice() on it’s own and it worked. So I know the problem is with my random

Knights tour – results in an infinite loop and i can’t figure out why

I’m trying to solve the knight’s tour problem using backtracking. I think the algorithm I have should work. I’ve tried but I can’t figure out why it isn’t working. It results in an infinite loop. However if I comment out the line that back track solutionBoard[dst.x][dst.y]=-1; it works! I just don’t understand why! Any help would be appreciated. Answer Your

Java Knight’s Tour Homework [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn’t work, and the expected results. See also: Stack Overflow question checklist Closed 9 years ago. Improve this question I am having some problems with this

Knight’s tour depth-first search infinite loop

I’m trying to solve the knight’s tour problem using a depth-first search algorithm. The algorithm seems te be looping whenever it has two choices that both result in a dead end. I understand that this is caused because the algorithm resets the ‘wasVisited’ boolean to false again whenever a dead end is found but i simply don’t know how to

Advertisement