Question: help me to solve this assignment in C++. #include #include using namespace std; void displayBoard(char b[3][3]); void getUserChoice(int &r, int &c); void getCompChoice(char b[3][3], int

 help me to solve this assignment in C++. #include #include usingnamespace std; void displayBoard(char b[3][3]); void getUserChoice(int &r, int &c); void getCompChoice(charb[3][3], int &r, int &c); bool hasWinner(char b[3][3], char &winner); int main()

help me to solve this assignment in C++.

#include #include using namespace std;

void displayBoard(char b[3][3]); void getUserChoice(int &r, int &c); void getCompChoice(char b[3][3], int &r, int &c); bool hasWinner(char b[3][3], char &winner);

int main() { char board[3][3]; /* TODO: Initialize board */ char winner = ' '; bool userTurn = true;

while (!(hasWinner(board, winner) || /* TODO: isDraw */ false)) { int r, c; do { displayBoard(board); if (userTurn) getUserChoice(r, c); else getCompChoice(board, r, c); if (/* TODO: ! isOpen */ false) cout

cout

return 0; }

void displayBoard(char b[3][3]) { /* TODO: Fill in this function */ }

void getUserChoice(int &r, int &c) { r = 0; c = 0; /* TODO: Fill in this function*/ }

void getCompChoice(char b[3][3], int &r, int &c) { /* You are welcome to change this function * This is a simple AI function that finds the first available position */

for (r = 0; r

bool hasWinner(char b[3][3], char &winner) { char tmp;

/* Verticals */ for (int i = 0; i

/* Horizontal */ for (int i = 0; i

/* Diagonal #1 */ tmp = b[1][1]; if (tmp != ' ' && tmp == b[0][0] && tmp == b[2][2]) { winner = tmp; return true; } if (tmp != ' ' && tmp == b[2][0] && tmp == b[0][2]) { winner = tmp; return true; }

return false; }

Description Write a Tic-Tac-Toe game, using the provided framework. You will ill in the functions (as noted), as well as create two functions: isOpen and isDraw Sample Outputs Choose a row (1-3) 1 Choose a column (1-3) 1 Choose a row (1-3) 2 Choose a column (1-3) 2 Choose a row (1-3) 3 Choose a column (1-3): 3 WINNER: Player Press any key to continue

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!