Question: this is one program that needs to be implemented in C. Please help In this assignment, you are woed to write a program that stores
this is one program that needs to be implemented in C. Please help




In this assignment, you are woed to write a program that stores a chessboard in a 2D array of integers. Your program must make necessary changes on the array after each more or capture of the two players of the game. 1 Array Format A chessboard can be represented by an 8 x 8 table of integers in which every cell is corre sponding to one of the 64 squares of the board and determines the occupant of the square. As seen in Figure 1, the table row with index 0 is labeled with "g" and the table row with Figure 1: Row and column labels in a chessboard. index 7 is labeled with "1". Also, the table column with index O is labeled with "*", while the table column with index 7 is labeled with "h". If the value of a table cell is zero, it means that the square corresponding to that cell is empty. If the value is positive, it means that a white piece occupies the corresponding square, while a negative value means that the occupying piece color is black. The absolute value of the cell specifies type of piece occupying the corresponding square. Here is the general rule O cell is empty 1 cell is occupied by a pawn 2 cell is occupied by a knight table[11 - 3 cell is occupied by a bishop 4 cell is occupied by a rook 5 vell is occupied by a queen 6 cell is occupied by a king For the sake of simplicity, you can store this table in a static or external 2D array of integers in your program 2 Initial Setting of Pieces on the Board The program starts by initializing the table in the following fashion which corresponds to -1-1-1-1-1-1-1-1 00000000 OD OD 0 0 0 0 ODODO 0 0 0 00000000 11111111 4 2 3 5 6 3 24 the following chessboard wetup: 1 1 Figure 2 Movement and capture of knight (left), movement (middle) and capture of Dawn (right) on chessboard. 3 Program Commands Your program must perform the following commands entered by user vin standard input stream: .my 030181: moves the piece in cell with label to cell with label B where al and as can be letters from a to h; while 3 and B. can be integers from 1 to 8. poll captures the piece in cell with label , with the piece in cello whereas and a can be letters from a to h; while Bo and Bt can be integers from 1 to show: prints out the content of the 2D array on the screen in the form of a table like this (the ranks 1,2,..., 8 and files a, b, ..., h must be printed as well): board a b c d 6 5 4 3 2 1 -1 -1 -1 -1 0 -111 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 1 1 1 4 2 3 5 6 3 24 Figure 2 shows how knight can move on the board and capture pieces with opposite color on the board. Also, it shows the direction in which white pawn moves and captures. The black pawn moves and captures in the opposite direction. In summary, a pawn can move only one cell forward at a time, however, if it is white and is in the second rank (or is black and is in the seventh rank), it has the option of moving two cells forward as well if there is no piece on its way. Bishop moves diagonally and took moves vertically or horizontally. Queen can move like a bishop or rook. King moves one square at a time to one of the four adjacent squares If a 'cp' or 'm' command tries to make illegal move, your program prints out an error message
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
