Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please implement the following functions for a game of tic tactoe. The rest of t

ID: 3617564 • Letter: P

Question

Please implement the following functions for a game of tic tactoe. The rest of the code is below.
1)bool validMove(char board[][3], char pos);
2)void displayBoard(char board[][3]);
3)void markBoard(char board[][3], char pos, char marker);
4)bool checkHorizontal(char board[][3], char marker);
5)bool checkVertical(char board[][3], char marker);
6)bool checkDiagonal(char board[][3], char marker);
7)bool checkTie(char board[][3]);
8)void printWinner(char marker);


The rest of the code is below.. Please HELP
#include <iostream>
using namespace std;

/* Initializes array in as follows
1 2 3
4 5 6
7 8 9
*/

void initializeBoard(char board[][3]);

/* displays board to console as follows
1 2 3
4 5 6
7 8 9
*/


void displayBoard(char board[][3]);/*gets input from user returnscharacter number of location chosen by user*/  

char getInput(char board[][3], char marker);/* mark charactermarker of player on chosen character pos of board*/

void markBoard(char board[][3],char pos, charmarker);/*checks to see if someone has won returns true orfalse*/

bool gameOver(char board[][3]); /*checks to see if someonewon on rows of board*/

bool checkHorizontal(char board[][3], char marker);/*checksto see if someone won on columns of board*/

bool checkVertical(char board[][3], char marker);/*checks tosee if someone won on diagonal of board*/

bool checkDiagonal(char board[][3], char marker);/*checks tosee if players have tied*/

bool checkTie(char board[][3]);/*prints winner as marker orties*/

void printWinner(char marker);/*checks to see if selectedlocation is available returns false when location has already beentaken or is an invalid number*/

bool validMove(char board[][3], char pos);  

int main()

{
char board[3][3];
char p1,p2, exit;
do
{
initializeBoard(board);
displayBoard(board);
while(true)

{

//player 1's turn
p1 = getInput(board,'X');
markBoard(board, p1, 'X');
displayBoard(board);
if (gameOver(board)) //if player 1 wins break out of loopbreak
;

//player 2's turn
p2 = getInput(board,'O');
markBoard(board, p2, 'O');
displayBoard(board);
if (gameOver(board)) //if player 2 wins break out of loop

break;
}

cout << "Would you like to play again (Y or N):";
cin >> exit;
}while((exit != 'N') && (exit != 'n'));
return 0;

}

/* Initializes array in as follows
1 2 3
4 5 6
7 8 9
*/

void initializeBoard(char board[][3])
{
char count('0');
for (int i = 0; i<3; i++)
{  for (int j = 0; j<3; j++)
{
board[i][j]= ++count;
}

}

}

/*checks to see if selected location is available returns falsewhen location has already been taken or is an invalidnumber*/  

bool validMove(char board[][3], char pos)
{

}

/* displays board to console as follows

1 2 3
4 5 6
7 8 9

*/

void displayBoard(char board[][3])
{

}

/*gets input from user returns character number of location chosenby user*/

char getInput(char board[][3], char marker)
{

char pos;
cout << "Enter number of move Player " << marker<< ": ";
cin >> pos;
if (validMove(board,pos))

{

return pos;
}

else

{
cout << "Invalid Move: Please Try Again ";
getInput( board, marker);
}
}

/*checks to see if someone has won returns true orfalse*/
void markBoard(char board[][3], char pos, char marker)
{

}

/*checks to see if someone won on rows of board*/

bool gameOver(char board[][3])
{
if (checkHorizontal(board,'X'))
{

printWinner('X'); return true;
}

if (checkVertical(board, 'X'))

{
printWinner('X');
return true;
}

if (checkDiagonal(board, 'X'))
{
printWinner('X');
return true;
}
if (checkHorizontal(board,'O'))

{

printWinner('O');

return true;

}

if (checkVertical(board, 'O'))
{

printWinner('O');

return true;

}
if (checkDiagonal(board, 'O'))

{

printWinner('O');
return true;
}

if (checkTie(board))
{
printWinner('T');
return true;
}
return false;
}

/*checks to see if someone won on rows of board*/
bool checkHorizontal(char board[][3], char marker)
{

}
/*checks to see if someone won on columns of board*/

bool checkVertical(char board[][3], char marker)
{

}
/*checks to see if someone won on diagonal of board*/
bool checkDiagonal(char board[][3], char marker)
{
}

/*checks to see if players have tied*/
bool checkTie(char board[][3])
{

}
/*prints winner as marker or ties*/
void printWinner(char marker)
{

} Please implement the following functions for a game of tic tactoe. The rest of the code is below.
1)bool validMove(char board[][3], char pos);
2)void displayBoard(char board[][3]);
3)void markBoard(char board[][3], char pos, char marker);
4)bool checkHorizontal(char board[][3], char marker);
5)bool checkVertical(char board[][3], char marker);
6)bool checkDiagonal(char board[][3], char marker);
7)bool checkTie(char board[][3]);
8)void printWinner(char marker);


The rest of the code is below.. Please HELP
#include <iostream>
using namespace std;

/* Initializes array in as follows
1 2 3
4 5 6
7 8 9
*/

void initializeBoard(char board[][3]);

/* displays board to console as follows
1 2 3
4 5 6
7 8 9
*/


void displayBoard(char board[][3]);/*gets input from user returnscharacter number of location chosen by user*/  

char getInput(char board[][3], char marker);/* mark charactermarker of player on chosen character pos of board*/

void markBoard(char board[][3],char pos, charmarker);/*checks to see if someone has won returns true orfalse*/

bool gameOver(char board[][3]); /*checks to see if someonewon on rows of board*/

bool checkHorizontal(char board[][3], char marker);/*checksto see if someone won on columns of board*/

bool checkVertical(char board[][3], char marker);/*checks tosee if someone won on diagonal of board*/

bool checkDiagonal(char board[][3], char marker);/*checks tosee if players have tied*/

bool checkTie(char board[][3]);/*prints winner as marker orties*/

void printWinner(char marker);/*checks to see if selectedlocation is available returns false when location has already beentaken or is an invalid number*/

bool validMove(char board[][3], char pos);  

int main()

{
char board[3][3];
char p1,p2, exit;
do
{
initializeBoard(board);
displayBoard(board);
while(true)

{

//player 1's turn
p1 = getInput(board,'X');
markBoard(board, p1, 'X');
displayBoard(board);
if (gameOver(board)) //if player 1 wins break out of loopbreak
;

//player 2's turn
p2 = getInput(board,'O');
markBoard(board, p2, 'O');
displayBoard(board);
if (gameOver(board)) //if player 2 wins break out of loop

break;
}

cout << "Would you like to play again (Y or N):";
cin >> exit;
}while((exit != 'N') && (exit != 'n'));
return 0;

}

/* Initializes array in as follows
1 2 3
4 5 6
7 8 9
*/

void initializeBoard(char board[][3])
{
char count('0');
for (int i = 0; i<3; i++)
{  for (int j = 0; j<3; j++)
{
board[i][j]= ++count;
}

}

}

/*checks to see if selected location is available returns falsewhen location has already been taken or is an invalidnumber*/  

bool validMove(char board[][3], char pos)
{

}

/* displays board to console as follows

1 2 3
4 5 6
7 8 9

*/

void displayBoard(char board[][3])
{

}

/*gets input from user returns character number of location chosenby user*/

char getInput(char board[][3], char marker)
{

char pos;
cout << "Enter number of move Player " << marker<< ": ";
cin >> pos;
if (validMove(board,pos))

{

return pos;
}

else

{
cout << "Invalid Move: Please Try Again ";
getInput( board, marker);
}
}

/*checks to see if someone has won returns true orfalse*/
void markBoard(char board[][3], char pos, char marker)
{

}

/*checks to see if someone won on rows of board*/

bool gameOver(char board[][3])
{
if (checkHorizontal(board,'X'))
{

printWinner('X'); return true;
}

if (checkVertical(board, 'X'))

{
printWinner('X');
return true;
}

if (checkDiagonal(board, 'X'))
{
printWinner('X');
return true;
}
if (checkHorizontal(board,'O'))

{

printWinner('O');

return true;

}

if (checkVertical(board, 'O'))
{

printWinner('O');

return true;

}
if (checkDiagonal(board, 'O'))

{

printWinner('O');
return true;
}

if (checkTie(board))
{
printWinner('T');
return true;
}
return false;
}

/*checks to see if someone won on rows of board*/
bool checkHorizontal(char board[][3], char marker)
{

}
/*checks to see if someone won on columns of board*/

bool checkVertical(char board[][3], char marker)
{

}
/*checks to see if someone won on diagonal of board*/
bool checkDiagonal(char board[][3], char marker)
{
}

/*checks to see if players have tied*/
bool checkTie(char board[][3])
{

}
/*prints winner as marker or ties*/
void printWinner(char marker)
{

}

Explanation / Answer

please rate - thanks I corrected a few minor errors too #include using namespace std; /* Initializes array in as follows 1 2 3 4 5 6 7 8 9 */ void initializeBoard(char board[][3]); /* displays board to console as follows 1 2 3 4 5 6 7 8 9 */ void displayBoard(char board[][3]);/*gets input from user returnscharacter number of location chosen by user*/ char getInput(char board[][3], char marker);/* mark charactermarker of player on chosen character pos of board*/ void markBoard(char board[][3],char pos, char marker);/*checks tosee if someone has won returns true or false*/ bool gameOver(char board[][3]); /*checks to see if someone won onrows of board*/ bool checkHorizontal(char board[][3], char marker);/*checks to seeif someone won on columns of board*/ bool checkVertical(char board[][3], char marker);/*checks to see ifsomeone won on diagonal of board*/ bool checkDiagonal(char board[][3], char marker);/*checks to see ifplayers have tied*/ bool checkTie(char board[][3]);/*prints winner as marker orties*/ void printWinner(char marker);/*checks to see if selected locationis available returns false when location has already been taken oris an invalid number*/ bool validMove(char board[][3], char pos); int main() { char board[3][3]; char p1,p2, exit; do { initializeBoard(board); displayBoard(board); while(true) { //player 1's turn p1 = getInput(board,'X'); markBoard(board, p1, 'X'); displayBoard(board); if (gameOver(board)) //if player 1 wins break out of loopbreak break; //player 2's turn p2 = getInput(board,'O'); markBoard(board, p2, 'O'); displayBoard(board); if (gameOver(board)) //if player 2 wins break out of loop break; } cout > exit; }while((exit != 'N') && (exit != 'n')); return 0; } /* Initializes array in as follows 1 2 3 4 5 6 7 8 9 */ void initializeBoard(char board[][3]) { char count('0'); for (int i = 0; i