Your task is to develop a tic-tac-toe game. There are two options for you to choose from. One option is a tic-tac-toe game where two humans may play. The second option is one where a human may play against the computer. Option one is worth less points (90% of total points) than option two (100% of total points).
The program prompts users for their names and ensures (validates) them; users are allowed to enter a single username consisting of alpha chars ONLY.
Use one-dimensional arrays to keep track of the game:
Human moves in the case of option one.
Computer moves as well in the case of option two.
Use functions to pass arrays and implement other program requirements such as input validation, checking to ensure that places selected by users are available on the “game board”.
Validate user input at every opportunity.
Do not allow number entries less than 0 or entries greater than 8 (in the case you are using numbers 0-8 on the “grid”.
Do not allow number entries less than 0 or entries greater than 8 (in the case you are using numbers 1-9 on the “grid”.
Do not allow non-numeric entries.
If your program crashes due to an invalid entry made by the user, then you will not pass the final exam.
The program must be developed using functions so that the main() function consists mostly of function calls. This is exactly the same requirement as your midterm!
Below is a suggested list of functions for you to consider in the development of this project:
splashScreen()//displays game and developer’s information
askForUserNames()//requests for username
switchPlayer()//switch from one player to another
resetGame()//reset the game when one concludes; this includes filling the array with vales 0-8
displayGrid()//display the grid after each player makes a move
playerMakeMove()//prompts player to make a move, invokes validatePlayersMove, checkPositionAvailability
validatePlayersMove()//validates that user entry X is such that 0<=X<=8
checkPositionAvailability()//check that the position selected by the user is available
checkWin()//check for a winning player
checkTie()//check for a tie
In the case of option two, additional functions you may want to consider are:
makeBestMove()//select best option
computerMakeMove()//used to make the move, in other words populate the array
The main() function must use a loop to keep the user in the program until he/she wants to quit. Users should be allowed to play as many games as they want.
You must use meaningful variable names.
You must comment your code.
You must use variables of the correct type and initialize them with a proper value.
Your program must detect a winner if there is one
Your program must determine if a tie occurs