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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started