-Create a two-player, human vs. human, tic tac toe game. (plz use c lunguage) -Use the source code file tictactoe.c for your solution. The file is included with this assignment. You are required to...

-Create a two-player, human vs. human, tic tac toe game. (plz use c lunguage) -Use the source code file tictactoe.c for your solution. The file is included with this assignment. You are required to code all the functions listed. You may add any extra functions needed, but you must use all the functions described in the comments. -Write a function that displays a start screen when the program begins running Start Screen Example Main menu function b. Display a main menu, giving the user a choice to play a game or quit the program. This must be written as a separate function. Main Menu Example Display Board function Create a display_board function. This displays the game board in its current state. An example game board at the start of a new game is shown below. Display Board Example In the example, the upper tic tac toe board is used to indicate the number of each board position. The empty board indicates a new game has started. Player X is prompted to enter a position on the game board. Suppose Player X enters a 4, then the updated game board would appear as follows: Board updated after Player X enters 4 Other functions · initialize_board. This function should be called whenever you start a new game. Its purpose is to set all the gameboard spaces to OPEN. This is equivalent to the pencil and paper step of drawing a blank game. · get_player_move: This function gets the square number where the current player wants to put an X or an O. · check_valid_move function. This function ensures the number Player X or Player O entered is in the correct range and that the spot is OPEN. For example, if a player enters a number less than zero or greater than 8, there is no valid game board position. If Player O enters a 4 and that position is not open, this is not a valid move. · check_winner function. Function should return the following: Return 0 if game is won by XPLAYER Return 1 if game is won by OPLAYER Return 2 if game is a tie Return 3 if game is still going on · main function. This is your controlling function. It will contain all necessary logic to start the game, control game play, detect when a game ends, and print the result. main must call these other required functions. If you write all your code in main and do not write and call the other functions specified, you will lose significant credit, even if your program works perfectly. You may write any other helper functions you need. Preprocessor Macros The following are defined in the given program shell. Use these macro definitions to make your code readable. #define XPLAYER 0 #define OPLAYER 1 #define OPEN 32 #define TIEGAME 2 #define LIVEGAME 3 this is what i got so far, #include #define XPLAYER 0 #define OPLAYER 1 #define OPEN 32 #define TIEGAME 2 #define LIVEGAME 3 int main(void) { int i = 0; int player = 0; int go = 0; int row = 0; int column = 0; int line = 0; int winner = 0; char board[3][3]; for( i = 0; i9 && winner==0; i++) { printf("\n\n"); printf(" %c | %c | %c\n", board[0][0], board[0][1], board[0][2]); printf("-----------\n"); printf(" %c | %c | %c\n", board[1][0], board[1][1], board[1][2]); printf("-----------\n"); printf(" %c | %c | %c\n", board[2][0], board[2][1], board[2][2]); player = i%2 + 1; do { printf("\nPlayer %d, please enter the number of the square " "where you want to place your %c: ", player,(player==1)?'X':'O'); scanf("%d", &go); row = --go/3; column = go%3; } while(go0 || go>9 || board[row][column]>'9'); board[row][column] = (player == 1) ? 'X' : 'O'; if((board[0][0] == board[1][1] && board[0][0] == board[2][2]) || (board[0][2] == board[1][1] && board[0][2] == board[2][0])) winner = player; else for(line = 0; line 2; line ++) if((board[line][0] == board[line][1] && board[line][0] == board[line][2])|| (board[0][line] == board[1][line] && board[0][line] == board[2][line])) winner = player; } printf("\n\n"); printf(" %c | %c | %c\n", board[0][0], board[0][1], board[0][2]); printf("-----------\n"); printf(" %c | %c | %c\n", board[1][0], board[1][1], board[1][2]); printf("-----------\n"); printf(" %c | %c | %c\n", board[2][0], board[2][1], board[2][2]); if(winner == 0) printf("\nDraw\n"); else printf("\nplayer %d, YOU WON!\n", winner); }
May 19, 2022
SOLUTION.PDF

Get Answer To This Question

Submit New Assignment

Copy and Paste Your Assignment Here