Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

let the Tic Tac Toe game board be stored as a 3 × 3 character array called ‘boar

ID: 3871122 • Letter: L

Question

let the Tic Tac Toe game board be stored as a 3 × 3 character array called ‘board.’ For example, at a given point the board might look like the one shown below:

>> board = [ ’ - ’ , ’O ’ , ’X ’; ’ - ’ ,’ - ’ , ’O ’; ’X ’ , ’O ’ , ’ - ’]

board =

3 x3 char array

’ - OX ’

’ --O ’

’XO - ’

Problem 1 Using a ‘while’ loop, write a Matlab script called problem1.m that prompts the user to select how many players there will be (either One or Two) until a valid selection is made. See sample output below:

>> problem1 Enter the number of human players (1 ,2): 3

Enter the number of human players (1 ,2): -2

Enter the number of human players (1 ,2): 0

Enter the number of human players (1 ,2): 1.5

Enter the number of human players (1 ,2): 2.5

Enter the number of human players (1 ,2): 2

>>

Explanation / Answer

n=0;
while n < 1
player = input('Enter the number of human players (1 ,2):');
if(player==1 || player==2)
n=1;
end
end