Question: My questions is what code do I write using vectors that will determine a winner or loser? Tic Tac Toe Tic-tac-toe is a paper-and-pencil game

My questions is what code do I write using vectors that will determine a winner or loser?

My questions is what code do I write using vectors that willdetermine a winner or loser? Tic Tac Toe Tic-tac-toe is a paper-and-pencil

Tic Tac Toe Tic-tac-toe is a paper-and-pencil game for two players, X and 0, who take turns marking the spaces in a 3x3 grid. The player who succeeds in placing three of their marks in a horizontal, vertical, or diagonal row is the winner (Wikipedia). We've provided a main.cc which gets input from the user and draws a tic-tac-toe board. Users take turns entering their preferred move into the terminal until one of the player wins or no spaces are left. Your task is to implement the function CheckGame in tic tac_toe.cc which will determine if the game is over, and if so, the result. Implement CheckGame Here is the function prototype for CheckGame defined in tic tac toe.h: // Return 1 if player 1 wins, 2 if player 2 wins, o if no one has won but // there's still space, and -1 if the board is full. int CheckGame(std::vector<:vector>>& game); Here the game parameter is a vector of vectors. Specifically, game[@] is a vector which represents the first row in the board, game[1] is a vector int> representing the second row, and game [2] represents the third row. Each number in the game grid represents the state of a cell in the board. a means no one has played that square, 1 means player 1 has gone there, and 2 means player 2 has gone there. For example, in the grid below, you could access the bottom left cell (value 1) with game[2][0] or the middle cell (value 2 ) with game[1][1] . 20 100 Your task is to look at the game and determine whether someone has won. Return 1 if player 1 has won, 2 if player 2 has won, o if no one has won but there are still empty spaces, or -1 if there are no empty spaces and no one has won. main.cc main.cc tic_tac_toe.cc tic_tac_toe.h 1 #include 2 #include 3 4 int CheckGame(std::vector<:vector int>>& game) { 5 // Your code here to determine if there was a winner, a draw, or if the // game can continue. 6 7 9} 10

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!