Question: code for part 1 and 2 is provided need code for part 3 import java.util.Scanner; public class Main { static int[] horizontalMovement = {2, 1,

code for part 1 and 2 is provided need code for part 3

code for part 1 and 2 is provided need code for part

import java.util.Scanner;

public class Main { static int[] horizontalMovement = {2, 1, -1, -2, -2, -1, 1, 2}; static int[] verticalMovement = {-1, -2, -2, -1, 1, 2, 2, 1}; static int[][] chessBoard = new int[8][8]; static int[][] accessibility = new int[8][8]; static int knightMove; static int currentX; static int currentY; public static void main(String[] args) { //Scanner inputScanner = new Scanner(System.in); /* System.out.print("Enter starting row (0-7): "); currentX = inputScanner.nextInt(); System.out.print("Enter starting column (0-7): "); //allows user to select starting location currentY = inputScanner.nextInt(); inputScanner.close();*/ knightMove = 1; chessBoard[currentX][currentY] = knightMove; for (int i = 0; i = 0 && nextX = 0 && nextY Part 3 (6 points) In this part you will write a Java program that uses heuristics (or strategy) to try to get further in the Knight's Tour. Heuristics do not guarantee success, but a carefully developed heuristic greatly improves the chance of success. After completing Parts 1 and 2, you may have noticed that the outer squares are harder to land on than squares nearer the center. The four corners are the most inaccessible. So, let's try to move to the most inaccessible squares first, and leave easiest squares for when the board gets congested, near the end of the tour. We can develop an accessibility heuristic by classifying each square according to how accessible it is. Then at each move, we can move to an open square that is least accessible. We can represent the accessibility of each square using a 2-Dimensional array of integers called accessibility. Each square in this accessibility matrix corresponds to a square on the board. The number stored in accessibility [row] [column] is the number of open squares on the board from which board [row] [column] can be reached. On a blank chessboard, each center square is rated as 8, each corner square is rated as 2 , and the other squares have accessibility numbers of 3,4 , or 6 . The figure at the top of the next page summanized the initial values for the accessibility array. Write a version of the Knight's Tour using the accessibility heuristic. The knight should always move to the square with the lowest accessibility number. In case of a tie, the knight may move to any of the tied squares. Therefore, the tour should begin in any of the four comers. As the knight moves around the chessboard, your program needs to reduce the accessibility numbers as more squares become occupied. In this way, at any given time during the tour, each available square's accessibility number will remain equal to precisely the number of squares from which that square may be reached. Sample Run for Part 3 In this sample run, the knight started at position (0,0) and the program was able to visit all 64 squares. The final square reached was (5,6)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!