Question
In this assignment, you will have to create a program to display a full game board and add/remove game pieces . T he board is
In this assignment, you will have to create a program to display a full game board and add/remove game pieces . T he board is a grid of 8 x8 squares. Figure 1 shows what such a grid might look like in a regular game. Figure 1 NOTE: YOUR BOARD MUST BE 8x8 . OTHER BOARD SIZES WILL NOT RECEIVE CREDIT. Examples of how your board might look ( your ve rsi on MUST BE 8 x8 ) : Figure 2 : Board with no pieces placed Figure 3 : B oard wit h two regular pieces and two king s placed. The development of this procedure to display the board will be broken down into several problems. Do your best to solve all the questions for this assignment as future progra mming assignments will depend on your success here . Problem #1 (10 pts) Allocate enough memory (4 bytes for each square) in a 8x8 square board. Assign the value s following values at the specified row,column locations: Board[2,3] = 5 Board[1,5] = 3 Board[4,3] = 7 Board[1,0] = 1 All other board locations have the value zero assigned to them. Using a nested loop, print the value of each board location as an integer using syscall $print_int. Problem # 2 (10 pts) Use a loop to print a single row of black and white squares. Start with a white square, then print a black square, then a white square, etc until the program prints six squares. Problem #3 (15 pts) Using 2 nested loops, write a program to print a 6x6 che cker board using black and white squares. The upper left and lower right corners of the checker board should be white. Problem #4 (20 pts) Merge the programs from problems #1 and #3. Also a dd a set of if/else or a switch/case style statement to the neste d loops so that the proper game piece is printed. For example: for (...) { for (...) { if ( ) print ; else if (board[r*6+c]==3) print w; else if (board[r*6+c]== 1) print r; else if (...) print R; else if (...) print W ; else print ; } } Problem #5 (25 pts) In the final problem, you must convert the display routine (the 2 nested loops and if/else statements) from problem 4 into a function. Next, you should write a program to test that your display function works. The flow of the program should go as follows: 1. allocate space for board state [problem 1] 2. initialize board state to all zeros [problem 1] 3. Begin loop a. print board state (display the board) [problems 2 - 5] b. ask for row c. ask for column d. ask for va lue e. set board (row,column) to value [problem 1] f. go to (3a) The input parameter to this function is the board state. The function prototype would be defined as follows: void displayBoard(int* board) { ... } The board is a data object that stores the locations of all the checkers on the board and the information associated with it. This is referred to as the state of the board. When you declare your function in MIPS assembly, please pass the variable board by reference i.e. it is a pointer. Do not try to allocate space for the entire board on the stack every time you call displayBoard. Use $a0 to pass the pointer to the board data instea
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