Question: C + + HOMEWORK TIC TAC TOE The classic game of Tic Tac Toe is played on a 3 x 3 grid. Players take turns
C HOMEWORK TIC TAC TOE
The classic game of Tic Tac Toe is played on a x grid. Players take turns marking empty
spaces with X or O and whoever gets in a row row column, or diagonal wins the game.
Consider Programming Project in the textbook. This is standard Tic Tac Toe.
Modify the program as follows:
Have the program prompt for the dimensionality of the board. This can be any integer.
o We reject or as trivial.
o We reject as the first player to move always wins
o We accept dimensions of up to
o If the user enters an invalid value here, make them try again.
Then have the program prompt for the names of the two players.
The program will then create and display the n x n board and randomly select the player
who moves first. The game then alternates between the players.
o If a player enters an invalid move, make them try again
After each move, the program must determine if someone has won. If so indicate this.
If the board is full and no one has won, have the program state that the game was a draw.
The program then asks if they want to play again.
o If yes, play again, and make sure to switch who goes first this time.
o If no give the final score including draws and exit.
Note that this requires the use of a dynamic n x n array. These are covered in Chapter and in
the Power Point slides. Your program will read the desired dimensionality, create the game board
dynamically, and then play the game.
You can number the squares as done in the textbook, or by row and column.
Hint: think about the various tasks required here and write your functions first, then put them all
together to create the game.
Note: you should keep the same array for all of the games; just clear all of the entries after each
game ends. Naturally you will write a function to do this.
Note: Our practice is to write function prototypes at the top of the code above main and
function code below. Later we will put our function code in a separate header file.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
