Assignment #7 - 92B

# Assignment #7 - 92B

```                         ASSIGNMENT 7          (WEIGHT 20)

A KNIGHT'S TOUR OF A CHESSBOARD, IS A SEQUENCE OF 64 MOVES
WHEREBY THE KNIGHT VISITS EACH SQUARE OF THE 8X8 CHESSBOARD
EXACTLY ONCE.  THE KNIGHT MOVES IN AN UNUSUAL MANNER AS FOLLOWS:

X  -  X
X     -     X
-  -  N  -  -
X     -     X
X  -  X

THE NIGHT  N CAN MOVE TO ANY OF THE SQUARES MARKED WITH AN X
(AS LONG AS IT REMAINS ON THE BOARD OF COURSE).

TO GENERATE THE TOUR, THE FOLLOWING ALGORITHM SHOULD BE USED.

A.  EACH SQUARE OF THE CHESSBOARD IS ASSIGNED A NUMBER CORRESPONDING
TO THE NUMBER OF SQUARES TO WHICH THE KNIGHT CAN MOVE.  THIS
MATRIX SHOULD BE PRINTED.

B.  EACH TIME THE KNIGHT MOVES TO A SQUARE, THAT SQUARE IS SET EQUAL
TO -1 * MOVE NUMBER.  NEXT, EACH SQUARE TO WHICH THE KNIGHT CAN
MOVE IS DECREMENTED BY 1 (UNLESS THE SQUARE HAS A NEGATIVE VALUE).
THE KNIGHT THEN MOVES TO THE SQUARE WITH THE SMALLEST POSITIVE
VALUE.  TIES ARE BROKEN ARBITRARILY.

C.  AFTER 64 MOVES, THE TOUR WILL BE FINISHED AND THE BOARD WILL
CONTAIN THE SEQUENCE OF MOVES (EXCEPT THAT EACH VALUE IS NEGATIVE).
PRINT OUT THIS MATRIX (REMEMBERING TO NEGATE EACH VALUE TO MAKE IT
POSITIVE).

YOU SHOULD PRINT THE KNIGHT'S TOUR FOR THE STARTING POSITIONS
(1,1) AND (8,3).
```