Question: Matlab program, need help (Write sepreate scripts to answer all of the following questions. Tic-tac-toe. Write a program to play tic-tac-toe. For now, the interface
Matlab program, need help (Write sepreate scripts to answer all of the following questions.

Tic-tac-toe. Write a program to play tic-tac-toe. For now, the interface will be minimal: you will ask the user for a number (a square) between 1 and 9, and pick one in return. You must make a legal move, and detect when one of you wins. Your gamestate data structure (the way you internally represent the board) should be a nine-element array with empty squares as zero, X (human player) spaces are marked with +1, O (computer) with -1. a. Write a function that asks the user for a move and makes sure it is legal. The input and output should be the gamestate. Show 3 test runs. b. Write a function that determines if either the computer or player has won (return 1 for player, 0 for no winner, -1 for computer). Show 3 test runs. c. Write a function that detects if any valid moves remain. Show 3 test runs. d. Write a function that supplies a computer guess. It can be random or sophisticated - your choice. Show 3 test runs. e. (optional) Write a script that initializes the board and uses a while loop to string together your functions until the game has been won or drawn. Play
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
