Question
4.24 (Knights tour) C++ and please try not to use any special string libraries. A program that will move the knight around a chessboard. The
4.24 (Knights tour) C++ and please try not to use any special string libraries.
A program that will move the knight around a chessboard. The board is represented by an 8-by-8 double-subscripted array board. Each of the squares is initialized to zero. We describe each of the eight possible moves in terms of both their horizontal and vertical components. For example, a move of type O, consists of moving two squares horizontally to the right and one square vertically upward. Move 2 consists of moving one square horizontally to the left and two squares vertically upward. Horizontal moves to the left and vertical moves upward are indicated with negative numbers. The eight moves may be described by two single-subscripted arrays, horizontal and vertical, as follows: horizontal [0] = 2 horizontal [1] = 1 horizontal [2] = -1 horizontal [3] = -2 horizontal [4] = -2 horizontal [5] = -1 horizontal [6] = 1 horizontal [7] = 2 Vertical [0] = -1 Vertical [1] = -2 Vertical [2] = -2 Vertical [3] = -1 Vertical [4] = 1 Vertical [5] = 2 Vertical [6] = 2 Vertical [7] = 1 Let the variables currentRow and currentCoIumn indicate the row and column of the knight's current position. To make a move of type moveNumber, where moveNumber is between O and 7, your program uses the statements, currentRow += vertical [ moveNumber ]; currentCoIumn horizontal [ moveNumber ]; Keep a counter that varies from 1 to 64. Record the latest count in each square the knight moves to. Remember to test each potential move to see if the knight has already visited that square, and, of course, test every potential move to make sure that the knight does not land off the chessboard. After attempting to write and run the knights tour program, next develop accessibility heuristic by classifying each of the squares according to how accessible they are and then always moving the knight to the square that is most inaccessible.Label a double-subscripted array accessibility with numbers indicating from how many squares each particular square is accessible. On the blank chessboard, each center square is rated 8, each corner square is rated 2 and the other squares have accessibility numbers of 3, 4 and 6 as follows: 23444432 34666643 46888864 46888864 46888864 46888864 34666643 23444432 Modify the program to run 64 tours. Please do not use define 8!! Please write C++
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started