Question

I need code for a problem in Matlab Create a single Matlab script that accomplishes the...

I need code for a problem in Matlab

Create a single Matlab script that accomplishes the following:

Defines a blank tic tac toe board, a 3 x 3 matrix, called board with blank spots represented by zeros.

Asks player 1 for a row and column, then puts 1 in a given location.

Asks player 2 for a row and column, then puts 2 in a given location

Homework Answers

Answer #1

board = [3][3];
turn = 0; // determines whose chance it is
if turn == 0: // player 1 turn
print('enter row number and column');
   x1 = input(); // row
   y1 = input(); // column
   board[x1][y1] = 1; // place his move
   turn = 1;
else if turn == 1: // player 2 turn
   print('enter row number and column');
   x2 = input(); // row
   y2 = input(); // column
   board[x2][y2] = 2; // place his move
   turn = 0

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
In java //Create a New Project called LastNameTicTacToe.// //Write a class (and a client class to...
In java //Create a New Project called LastNameTicTacToe.// //Write a class (and a client class to test it) that encapsulates a tic-tac-toe board. // A tic-tac-toe board looks like a table of three rows and three columns partially or completely filled with the characters X and O. // At any point, a cell of that table could be empty or could contain an X or an O. You should have one instance variable, a two-dimensional array of values representing the...
Part 1: Create the grid tic-tac-toe gameboard using buttons and iteration. Part 2: Human user gets...
Part 1: Create the grid tic-tac-toe gameboard using buttons and iteration. Part 2: Human user gets to select an open cell on the grid - place an X on that button selected Part 3: Check for a win using DOM iteration - new game option if row or column matching X pattern Part 4: Computer gets to select an open cell on the grid - place an O on that button selected Part 5: Check for a win using DOM...
In the code space provided in Matlab Grader, create a function that: 1. Accepts an input...
In the code space provided in Matlab Grader, create a function that: 1. Accepts an input matrix A as its only input argument. Matrix A is a 3x3 matrix of random integers between 1 and 4 2. Produces and output matrix B as its only output argument. Matrix B will also be a 3x3 matrix. 3. Calculates the elements of matrix B such that: a. the values of B along the diagonal are equal to the respective elements in A...
MATLAB Write a script "readFile.m" which:   a. reads a given file "file.dat" into a matrix "XYZ",  ...
MATLAB Write a script "readFile.m" which:   a. reads a given file "file.dat" into a matrix "XYZ",   b. extracts the columns of the data from "XYZ" into arrays "c1", "c2", ..., "cN",   c. plots some column versus another column, with a title, and labeled axes.   To test and debug your code, create a "file.dat" with 3 rows and N=2 columns ( so a 3×2 matrix ).   The first column should be sorted. You can just enter some numbers in "file.dat" in...
PLEASE USE MAT LAB ONLY. THANK YOU (a) Create and plot the signals listed below and...
PLEASE USE MAT LAB ONLY. THANK YOU (a) Create and plot the signals listed below and save your Matlab code in a script file. i) Cosine signal of frequency 100 Hz over the range [0,0.1] seconds and samples spaced 10^- 4 seconds apart with a phase of pi/2 and an amplitude of 1.   PLEASE USE MAT LAB ONLY. THANK YOU ii) A square wave that oscillates between 0 and 1 every five samples, plot 3 periods of the waveform. iii)...
Please use Mat lab only. Thanks (b) Plotting Sunspots Load the Matlab data file, sunspot.dat, and...
Please use Mat lab only. Thanks (b) Plotting Sunspots Load the Matlab data file, sunspot.dat, and experiment with making plots and subplots. The file is a simple 288 row by 2 column matrix where the first column has consecutive years from 1700 until 1987 and the second column has the mean sunspot number for that year. Then we will construct year and spots vectors from the two columns and plot spots as a function of year. load sunspot.dat; year =...
For a C program hangman game: Create the function int setup_game [int setup_game ( Game *g,...
For a C program hangman game: Create the function int setup_game [int setup_game ( Game *g, char wordlist[][MAX_WORD_LENGTH], int numwords)] for a C program hangman game. (The existing code for other functions and the program is below, along with what the function needs to do) What int setup_game needs to do setup_game() does exactly what the name suggests. It sets up a new game of hangman. This means that it picks a random word from the supplied wordlist array and...
Using the model proposed by Lafley and Charan, analyze how Apigee was able to drive innovation....
Using the model proposed by Lafley and Charan, analyze how Apigee was able to drive innovation. case:    W17400 APIGEE: PEOPLE MANAGEMENT PRACTICES AND THE CHALLENGE OF GROWTH Ranjeet Nambudiri, S. Ramnarayan, and Catherine Xavier wrote this case solely to provide material for class discussion. The authors do not intend to illustrate either effective or ineffective handling of a managerial situation. The authors may have disguised certain names and other identifying information to protect confidentiality. This publication may not be...
Please answer the following Case analysis questions 1-How is New Balance performing compared to its primary...
Please answer the following Case analysis questions 1-How is New Balance performing compared to its primary rivals? How will the acquisition of Reebok by Adidas impact the structure of the athletic shoe industry? Is this likely to be favorable or unfavorable for New Balance? 2- What issues does New Balance management need to address? 3-What recommendations would you make to New Balance Management? What does New Balance need to do to continue to be successful? Should management continue to invest...
Delta airlines case study Global strategy. Describe the current global strategy and provide evidence about how...
Delta airlines case study Global strategy. Describe the current global strategy and provide evidence about how the firms resources incompetencies support the given pressures regarding costs and local responsiveness. Describe entry modes have they usually used, and whether they are appropriate for the given strategy. Any key issues in their global strategy? casestudy: Atlanta, June 17, 2014. Sea of Delta employees and their families swarmed between food trucks, amusement park booths, and entertainment venues that were scattered throughout what would...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT