Question: Write a Matlab function called random move.m that generates a random (but valid) move for Player 2 (X). The function should take as input the

Write a Matlab function called random move.m that generates a random (but valid) move for Player 2 (X). The function should take as input the current game board, and output a 22 array giving the row and column of Player 2s random move. See sample function definition below:

function move = random_move ( board )

% Inputs :

% board - a 3 x3 character array representing the current game board

% Outputs :

% move - a 2 x2 array giving a random ( but valid ) move for Player 2 (X), based on the value of board

See sample output below:

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

>> random_move ( board )

ans = 3 3

>> random_move ( board )

ans = 3 3

>> random_move ( board )

ans = 1 3

>> random_move ( board )

ans = 3 3

>> random_move ( board )

ans = 3 3

>> random_move ( board )

ans = 1 3

>>

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!