I need help with the following program:
In this assignment, we will be making a program to populate a game board with pieces and to move those pieces around on the board. Use the file homework_part_2.c (available on Canvas). You will need to add header comments to each file along with comments for all the methods you will be implementing. You will need to update the condition in the main loops while statement and fill out the procedures below the main procedure. Any changes made to the main method of the file will be penalized unless otherwise instructed. Step 1. First, you need a structure game_piece. It should contain the variable, label (char [30]). In addition, the following functions should be defined. Function Description void game_piece_init_default(struct game_piece* piece) Assign the default string “—” to the game piece’s label. void game_piece_init(struct game_piece* piece, char* new_label) Assign the game piece’s label with the new_label provided. char* game_piece_get_label(struct game_piece* piece) Returns the piece’s label. char* game_piece_to_string(struct game_piece* piece) Constructs a C string of length 3 from the piece’s label (Note: this length does not include the null character). If the label is shorter than length 3, then the new string should be the label with spaces appended to make it the correct length. If the label is longer than 3, then use the first 3 characters of the label. Step 2. You will be creating a structure called game_board in the same code file. The structure will contain a 2-dimensional array called “board” of game_piece type and 2 ints, rows and columns. Define the following functions: Function Description void game_board_init(struct game_board* game_board, int rows, int cols) Instantiates the 2-dimensional array “board” to the size “rows” by “columns” specified by the parameters, then sets the game_board’s rows and columns values. Then it initializes each game_piece element of this array using the game_piece_init_default function. So, each piece will have the default value for its label. int game_board_is_space_valid(struct game_board* game_board, int row, int col) The function checks if the parameters row and col are valid. If at least one of the parameters “row” or “col” is less than 0 or larger than the last index of the array (note that the number of rows and columns can be different), then it return 0 (false). Otherwise it returns 1 (true). int game_board_add_piece(struct game_board* game_board, struct game_piece* piece, int row, int col) This function should validate that the space specified by row and col is valid and that the space is not occupied by a piece. If the game_piece at the space has the default label, the space should be considered not occupied. If the space is both valid and not already occupied, then the space should be replaced by the parameter “piece” and the method should return 1. Otherwise, return 0. int game_board_move_piece(struct game_board* game_board, int src_row, int src_col, int dest_row, int dest_col) This method should validate that both the src and dest spaces are valid and that the dest space is not occupied. If both conditions pass, then the piece located at (src_row, src_col) should be moved to (dest_row, dest_col). The space at (src_row, src_col) should be replaced by the default game_piece. If this method moves the piece, return 1, otherwise return 0. void game_board_print(struct game_board* game_board) It prints information of the “board”. It should show the list of pieces placed on the board using the game_piece_to_string function (it shows the first 3 characters of each piece). Use the following format: The GameBoard ——————– — Kin — Paw — — — — Paw Please see the sample output listed below.
Essay Writing Service Features
Our Experience
No matter how complex your assignment is, we can find the right professional for your specific task. Teacheronhelp is an essay writing company that hires only the smartest minds to help you with your projects. Our expertise allows us to provide students with high-quality academic writing, editing & proofreading services.Free Features
Free revision policy
$10Free bibliography & reference
$8Free title page
$8Free formatting
$8How Our Essay Writing Service Works
First, you will need to complete an order form. It's not difficult but, in case there is anything you find not to be clear, you may always call us so that we can guide you through it. On the order form, you will need to include some basic information concerning your order: subject, topic, number of pages, etc. We also encourage our clients to upload any relevant information or sources that will help.
Complete the order formOnce we have all the information and instructions that we need, we select the most suitable writer for your assignment. While everything seems to be clear, the writer, who has complete knowledge of the subject, may need clarification from you. It is at that point that you would receive a call or email from us.
Writer’s assignmentAs soon as the writer has finished, it will be delivered both to the website and to your email address so that you will not miss it. If your deadline is close at hand, we will place a call to you to make sure that you receive the paper on time.
Completing the order and download