problem 1) Implement this function in C:
void populateGameBoard(char gameBoard[][COL_SIZE], int rowSize, int colSize, int numPieces);
This function takes in entire game board passed from main, the row size, the column size of the playable game board, and number of pieces to place (num_pieces). Inside the function develop the way to populate 2D array randomly by calling getPieceType (basically function which randomly generates (returns) character of either 'T' or 'A') to obtain either ‘A’ or ‘T’ to place on the playable game board portion up to the size of numPieces. numPieces is decided by the row size of the 2D array -- meaning that if rowSize = 10, then the board would start with 10 game pieces.
Note: This function also should handle the case that max element size would be met and number of units plus incoming number pieces would create an infinite loop. Develop the way to prevent the infinite loop.
A solution is below
For ex: a 3 * 3 game board has at max 9 elements but also requires a placement of 3 additional units, but already 7 units present on game board. If this is the case decrement the number of additional units to fit the max number of units in the playable game board portion.
THIS IS WHAT THE GAMEBOARD LOOKS LIKE:
Player's life left is [100]
Number of devastor missiles is [0]
Player's score is [0]
a b c d e f g h i j
a [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ A ] [ ] [ ]
b [ ][ T ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ]
c [ ] [ ] [ ] [ ] [ A ] [ ] [ ] [ ] [ ] [ ]