Please refer to the following instructions and the following template to write a
ID: 3819251 • Letter: P
Question
Please refer to the following instructions and the following template to write a C program that displays the same results as shown in the sample. Please be sure to use the macros, arrays, and functions in the template. Instructions:
Template:
Sample:
Thank you.
This week you will create a game board array that will save player moves. Start by declaring this array as a 2D-array of integers with size BOARD SIZE (at this time make sure BOARD-SIZE is equal to 8). Create a set of macros that will define whether a space on the game board is an EMPTY SPACE, P1-SPACE, or P2 SPACE. An example of the #define directives is as follows: Board Size Constant #define BOARD SIZE Board Space Constants #define EMPTY SPACE 0 #define P1 SPACE #define P2 SPACE //Player Constants #define PLAYER1 #define PLAYER2 You will use these macros as values in your game board array. Set every cell in the game board array to EMPTY SPACE. Then set indices [3][3] and [4][4] to P1-SPACE and indices 13][4] and [4][3] to P2 SPACE. Now modify your printBoard function to take the game board array as the only parameter. Modify the function to print out 'B' (for P1-SPACED, 'W' (for P2-SPACED, and (for EMPTY SPACE) using your macros defined earlier. Finally, modify the code in your program where you call the printBoard function to now take the 2D game board array as a parameter Next, you may delete the code in your game loop that asks for a second coordinate, as well as the print statements that print the alignment of the coordinates. You will only be asking for one coordinate from now on (See sample output for example) Finally create a function called playMove, which takes the x and y coordinates the current player's turn variable, and the 2D game board array as parameters and returns an integer. The function should set the board space at index [x]ly to the appropriate space macro defined from earlier (P1-SPACE or P2-SPACE) depending on the player variable passed in. This function should return 1 for now. We will modify this function more in the coming weeks (as of right now, players will be able to overwrite previous moves We will change this later) The prototypes of the functions are as follows int getAlignment (int, int int int); //Returns Alignment Constant void print Board (int [B0ARD SIZEJ [B0ARD SIZE]) //Prints Game Board int validate Input int play Move (int, int int int [B0ARD SIZE] [BOARD SIZE]) (Continued on next page)Explanation / Answer
display menu
do
{
for(int i=0;i<8;i++)
{
for(j=0;j<8;j++)
{
printf("%3d",".");
}
}
}while(false condition)
Display player details
.........................
do
{
printf("Enter the palayer details:");
int n;
scanf("%d",&n);
for(int i=0;i<8;i++)
{
for(j=0;j<8;j++)
{
printf("%3d",n);
}
}
}while(false condition)
change the code using like this
and take tow arrays and compare count value
print result
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.