CIS071 Lab08 - Tic Tac Toe (Part 2) DUE: (Friday, Mar 24, NOON)
Tic Tac Toe (Part 2)
In this assignment, you should write a program that
You should write and use the following functions:
void enter_symbol(char tictactoe, int player)
void print_board(char tictactoe)
int if_winner(char tictactoe)
Function enter_symbol should prompt player 1 or 2 (described by variable player) to choose a position on the board to fill. In case the desired position is already filled with ‘X’ or ‘O’ this function should inform the user that this position is taken, and prompt him to fill one of the available positions. Hint: the function call can look like this: enter_symbol(tictactoe,2), which would prompt player 2 to enter ‘O’ symbol.
Function print_board should display the current state of the board (similarly to what you did in lab 7), by displaying ‘X’, ‘O’, or ‘.’ if the position is not filled yet. (Hint: you should initialize tictactoe array with values ‘.’). You should call this function after each move.
Function if_winner should determine if, based on the current state of the board, there is a winner. The function should return 0 if there is no winner yet, 1 if winner is player 1, and 2 if the winner is player 2.
Submit your program; show a few sample runs of the program.
Make a program that allows a single player mode of the Tic Tac Toe game. In this case, the first player (that enters ‘X’s) is a user of the program, while the second player (that enters ‘O’s) is computer. The challenge is to decide where to enter ‘O’ after each move by the first player, such that computer tries to prevent the first player from winning. Alternatively, you can also allow the computer to have the first move. You will be graded based on the ability of computer to play the game well against the human opponent.