The purpose is to write a program with 2D arrays that will display Knight's Tour. Knight's Tour is a fascinating problem that is done on an electronic chessboard with a knight. Starting at any location on the chessboard, a knight proceeds to move on the board in such a manner that all positions on the chessboard are visited, once and once only. The knight may only move according to the rules of chess playing.  The matrixes below show a sequence of knight moves that starts from the top-left corner.  In most cases, the knight is locked in place and can go no farther. Note: there are only 3 legal knight moves from the 44 locations and they have already been visited.

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter10: Introduction To Inheritance
Section: Chapter Questions
Problem 1DE
icon
Related questions
Question

The purpose is to write a program with 2D arrays that will display Knight's Tour.

Knight's Tour is a fascinating problem that is done on an electronic chessboard with a knight. Starting at any location on the chessboard, a knight proceeds to move on the board in such a manner that all positions on the chessboard are visited, once and once only. The knight may only move according to the rules of chess playing. 

The matrixes below show a sequence of knight moves that starts from the top-left corner.  In most cases, the knight is locked in place and can go no farther. Note: there are only 3 legal knight moves from the 44 locations and they have already been visited.

01 60 39 34 31 18 09 64
38 35 32 61 10 63 30 17
59 02 37 40 33 28 19 08
36 49 42 27 62 11 16 29
43 58 03 50 41 24 07 20
48 51 46 55 26 21 12 15
57 44 53 04 23 14 25 06
52 47 56 45 54 05 22 13

 

01 22 39 20 03 18 09 16
00 37 02 23 08 15 04 13
35 40 21 38 19 12 17 10
00 00 36 41 24 07 14 05
00 34 00 32 00 28 11 26
00 00 00 00 42 25 06 29
00 00 33 00 31 00 27 44
00 00 00 00 00 43 30 00  

Any challenging program, or problem, needs to be broken down into manageable tasks. Start with some simple tasks. First, initialize the 2D array with all 0s and place a 1 in the top-left location. Then complete the method showBoard, which helps by checking if your program logic is correct.

Completing these initial steps is not sufficient enough for 44 moves. It does set up the chessboard and display a sequence of moves if any. Furthermore, these first couple of method completions will help to show if you are making progress in the right direction. ONLY DO 44 MOVES TOTAL

Main.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Labe8vst.java
// This the student starting file for Labes.
Please add your appropriate comments here
$/
import java.text.DecimalFormat;
public class Labesvst
{
public static void main (string[] args)
{
}
int[][] board = new int[8][8];
startBoard (board);
showBoard (board);
/* To Be Completed */
// Initializes the 2D board array with es and 1 at the top-left.
public static void startBoard (int[][] brd)
{
/* To Be Completed */
// Displays a matrix of board values using the 2-digit format.
public static void showBoard (int[][] brd)
{
}
/* To Be Completed */
}
// Used by method nextMove to see if a board location was visited.
public static boolean checkvisit(int[][] brd, int r, int c)
{
/* To Be Completed */
return true;
// Finds a knight-type move to the next location, if possible.
public static void nextMove(int[][] brd)
{
/* To Be Completed */
Transcribed Image Text:Main.java 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 // Labe8vst.java // This the student starting file for Labes. Please add your appropriate comments here $/ import java.text.DecimalFormat; public class Labesvst { public static void main (string[] args) { } int[][] board = new int[8][8]; startBoard (board); showBoard (board); /* To Be Completed */ // Initializes the 2D board array with es and 1 at the top-left. public static void startBoard (int[][] brd) { /* To Be Completed */ // Displays a matrix of board values using the 2-digit format. public static void showBoard (int[][] brd) { } /* To Be Completed */ } // Used by method nextMove to see if a board location was visited. public static boolean checkvisit(int[][] brd, int r, int c) { /* To Be Completed */ return true; // Finds a knight-type move to the next location, if possible. public static void nextMove(int[][] brd) { /* To Be Completed */
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT