Question: Projects x l projects (m,par e chegg Study l Guided projecto%20(1) pdf project6 (1).pdf roblem Write a program that implements the game of Tic-Tac-Toe where












Projects x l projects (m,par e chegg Study l Guided projecto%20(1) pdf project6 (1).pdf roblem Write a program that implements the game of Tic-Tac-Toe where you can play against the computer. Playcr 1 will be the user and player 2 will be the computer. Your program should go through the following steps: . Generate an empty Tic-Tac-Toe board (3x3 array) 2. Run a loop until one of the players places three in a row (a player has won) or the table is full (stalemate). This loop should Display the current layout of the table a. i. Blank spaccs arc displaycd as an undcrscorc ii. O for player 1's moves (user) ii. X for player 2's moves (computer) iv. Put spaces between the squares b. If it is player 1's turn (the user) i. Ask the user to cnter their selection (the location on the board where the O should bc placed (row, col)) ii. Check to make sure that the row and column the user entered is valid iii. If the row or column player 1 entered was invalid (outside the bounds of the board or a spacc that is alrcady occupicd) the program should ask the uscr to enter the option again. c. If is player 2's turn (the computer) i. Randomly generate a move (row, col) in the board that is not currently occupied (if the ii. To generate a random move: generate two random integers, one for the row and one for ii. Print out player 2's move computer selects and occupied space generate a new move) the column, cach bctwecn 0 and 2 O Type here to search 9:34 PM 3/28/2018
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
