- Details
- Parent Category: Programming Assignments' Solutions
We Helped With This MATLAB Programming Assignment: Have A Similar One?

Category | Programming |
---|---|
Subject | MATLAB |
Difficulty | College |
Status | Solved |
More Info | Pay Someone To Do My Matlab Homework |
Assignment Description
MATLAB Lab # 3 - Homework
General Requirements:
READ THE FOLLOWING VERY CAREFULLY
• Pseudocode or flowchart.
o For this assignment, you must submit a pseudo-code or flowchart for each part.
o It is the policy of myself and the FYELIC that if you do not have pseudo-code or a flowchart to show you’ve put thought into the logic, you will not get help on writing the actual code.
§ You can get some help on the logic but you have to make a first attempt on your own.
o Your pseudo code does not have to be perfect.
§ It just needs to be a decent attempt at solving the problem. Your final code may vary somewhat or even entirely from the pseudocode. Simply update it.
o Handwritten is acceptable if legible
§ If not, use a word or drawing program to assist
• This is not a group assignment. It is an INDIVIDUAL one.
o But I do understand if you work together. Limit it to a pair.
o You must turn in your own code o You must acknowledge who helped you in the Title block.
§ If it was a student, name them.
§ If it was a Red Shirt, just say “Red Shirt” and their first name if you recall it. The same goes for if you get help from one of our TAs.
• INCLUDE comments in your code
o Code is not accepted if it is not annotated to help us understand what you are trying to do in your code.
Part 1 – Tic Tac Toe
Write a program that allows 2 players to play a game of Tic Tac Toe. Within that program, you will need to write and use 3 functions to determine which player starts, update a plot of the game board after each player’s move, and determine if a player has won the game.
Requirements:
• You may work with one (1) partner on this homework assignment.
o If you do, include their name in a comment on the second line of your code.
• Create a high detail “plan” of your program before you sit down to code o IE write your pseudo code or flowchart first, not after o Don’t forget you’ll have multiple functions involved
o If you come to me with programming questions about “How do I write the code for this assignment?” without any attempt at planning your logic, you get a 0 on the assignment.
Objectives:
• Write a MATLAB program (in an m-file) to play an interactive Tic-Tac-Toe game:
o each player is prompted for his/her marker position o followed by the program “plotting” his/her marker
• Create a friendly user interface to gather player moves
• Use a loop to keep the game moving between two players
• Use one of the built-in random number generation functions to simulate a coin toss o This will determine which player will go first
• Write a function that reads the game board for a winning row (CheckWin) o This will determine if a win has occurred
• Write a function that plots an up to date game board between moves (BoardPlot) o This will track and show the data from users’ previous moves
• For your submission of your outputs, play 1 game to a win.
Hints for the program
• Use a 3 x 3 matrix to track the status of the board.
Hints for Checkwin:
• A winning scenario would be 3 similar markers vertically, horizontally or diagonally.
• Check a passed array using math!
• DRAW A LINE THROUGH THE WINNING
Hints for BoardPlot:
• Draw two grid lines on each axis on a figure
• Label the grid with numbers, letters or whatever you like to help users choose a position
• Evaluate what the user inputs using an if /elseif statement
• Use a 3x3 matrix to pass your selections around
• Don’t try and draw your Xs and Os. Just plot a single marker.
o You can adjust the size of marker with linespec specifications o Check the documentation for the plot command for more details
• Try to be efficient but brute force is also ok.
HIGH LEVEL NON-FORMATED Pseudocode for the Main Program:
1. Start the game with a greeting to the players
2. Have the code decide who goes first
3. Explain the rules (Make sure you give them enough time)
4. Use a function, BoardPlot, to show an empty board
5. Have the players play the game
a. update the board with the function BoardPlot
6. After each turn, use a function, CheckWin, to see if the game has ended.
7. At the end of the game, display who won or that it was a draw
8. Ask user if they would like to play again
a. If they do, reset and restart
b. If not, end program
For Extra Credit:
• Add an additional function to the program that checks if a space is already taken before allowing the game to proceed. If the user tries to select a taken area, the program asks them to select again.
o Call this function: CheckTaken
• Add ‘-EC’ to the end of the filename for all parts of the assignment
• You may submit standard versions along with your Extra Credit version o So you still get credit if your EC version doesn’t work.
Submissions
1. <Properly named outputs>.pdf
a. Try to combine. Use ‘_1’ and ‘_2’ if you don’t know how to combine pdfs.
i. Print out of your command window output ii. Print out of your figure
If no Title Blocks in the following, -5% each
2. <Properly named main script>.m
3. Checkwin.m
4. BoardPlot.m
5. CheckTaken.m
a. Only if you’re doing the extra credit
Rubric
• P1: Tic Tac Toe ................................................................ 100% Total
o Pseudocode/Flowchart
§ Logical Approach to problem .................................. 15% § Well communicated/written ....................................... 5%
o Programming
§ Meets functional objectives
• Randomly selects first player .......................... 5%
• Tracks user inputs ............................................ 5%
• Updates board ................................................... 5%
• Determines a winner ........................................ 5% § CheckWin runs without errors ...................................... 5%
§ BoardPlot runs without errors ..................................... 5%
§ Main App runs without errors ..................................... 5%
§ Appropriate Commands ............................................ 10%
§ Clean and clear UI ....................................................... 5%
§ CheckWin commented throughout............................. 10% § BoardPlot commented throughout ............................ 10%
§ Main Application commented throughout ............... 10%
• For Extra Credit ................................................................ 5% Possible o Additional function runs without errors ................................. 1% o Warns user space is taken ......................................................... 1% o Asks for new input .................................................................... 1% o Commented throughout ............................................................ 2%