GE1101 ML-3 MATLAB ADVANCED GAME DESIGN: TIC TAC TOE LAB OBJECTIVES In this lab, you will: • Work with one (1) partner. • Create a high detail “plan” of your program before you sit down to code •...

1 answer below »
please show work so i can try to learn what you did thanks


GE1101 ML-3 MATLAB ADVANCED GAME DESIGN: TIC TAC TOE LAB OBJECTIVES In this lab, you will: • Work with one (1) partner. • Create a high detail “plan” of your program before you sit down to code • Write a MATLAB program (in an m-file) to play an interactive Tic-Tac-Toe game where: o each player is prompted for his/her marker position o followed by the program “plotting” his/her marker (graph this) • Create a friendly user interface to gather player moves from the command prompt • Use the random number generation function to simulate a coin toss to determine who will go first • Use a loop to keep the game moving between two players • Write a function to evaluate if a player has won (checkwin) • Write a function that plots the data from users in MATLAB on a game board that continuously updates between moves (boardplot) PSUEDOCODE FOR MAIN PROGRAM: 1. We start the game on a fun note, with a happy greeting to the players telling them who wrote the program. 2. The first part of the program is a coin toss to decide who goes first. 3. Use a block of text to explain what the rules are to the players. 4. Place a pause in your program so that the user can read before moving on. 5. Start with an empty board to show to the user using a function called boardplot 6. Ask Player 1 for their choice on the board 7. Use boardplot to plot Player 1’s marker on the board. 8. Use a checkwin function to check if Player 1 has won. 9. Ask Player 2 for their choice on the board 10. Use boardplot to plot Player 2’s marker on the board. 11. Use a checkwin function to check if Player 2 has won. 12. Repeat steps 6 – 11 until the board is full or someone has won. 13. At the end of the game, display who won (if anyone did) HINTS FOR BOARD PLOTTING: • Draw two grid lines on each axis • Label the grid with numbers, letters or whatever you like to help users choose a position • Evaluate what the user inputs using an if /else if statement • Use a 3x3 matrix to pass your selections around HINTS FOR CHECKWIN: • A winning scenario would be 3 similar markers vertically, horizontally or diagonally. • Check a passed array using math! The rest is up to you, be creative! ML-3 SUBMISSION DETAILS 1. Upload all 3 m-files to Canvas 2. Upload Partner Time Sheet 3. Be prepared to have the TA and Prof. Schulte Grahame play your game on the due date. The grading rubric is provided below: Item Comments Points Check in and Planning: At check in date students present: • Partial program • Flushed out “Plan” (pseudo code or flow chat of high detail) 10 Canvas: 3 (4 for extra credit) Files Uploaded: • TTT_BothLastNames.m (main file) • Checkwin_ BothLastNameInitials.m • Boardplot_ BothLastNameInitials.m • (checktaken_ BothLastNamesInitials.m) 10 Partner Timesheet: Present? (yes/no) 5 Code: Program works as requested (no GUI!!!) 20 Program Clarity • Commented with clear comments that help the user understand the logic of this code • First comments contain students’ names and date. • Formatted appropriately (indentations/parentheses) 10 3 files were created and interact with each other 10 Function files have help text and proper formatting 20 Professor Evaluation: Game play is smooth and fun 5 Game has easy to understand directions and board 5 Game determines a winner (if any) 5 TOTAL 100 PARTNER TIME SHEET Should be in the following format: BONUS CHALLENGE (WORTH 3 POINTS IF SUCCESSFUL) The following challenge is optional for students looking to challenge themselves and mandatory for honors students. • Add an additional function to the program that checks if a value is already taken before allowing the game to proceed. If the user tries to select a taken area, the program asks then to select again. • Call this function: checktaken_BothLastNameIntitals.m • Indicate in the comments section that you at competed the bonus (on Canvas)
Answered 1 days AfterFeb 12, 2021

Answer To: GE1101 ML-3 MATLAB ADVANCED GAME DESIGN: TIC TAC TOE LAB OBJECTIVES In this lab, you will: • Work...

Rahul answered on Feb 14 2021
137 Votes
Prompt = 'Enter Heads/Tails 0/1 ';
x=input(Prompt);
y=randi([0 1],1,1);
if x==y
fprintf('Player
1 wins toss');
a=1;
b=0;
else
fprintf('Player 2 wins toss');
b=1;
a=0;
end
board = zeros(3,3);
% Draw Board
figure
plot([.5 3.5],[-1.5 -1.5], 'k','linewidth',2);
hold on
plot([.5 3.5],[-2.5 -2.5], 'k','linewidth',2)
plot([1.5 1.5],[-.5 -3.5], 'k','linewidth',2)
plot([2.5 2.5],[-.5 -3.5], 'k','linewidth',2)
hold off
axis off
% Obtain first move
while a==1
move = input('enter player 1 move [r,c] ');
r = move(1);
c = move(2);
board(r,c) = 1;
text(c,-r,'X','horizontalalignment','center','fontsize',20)
a=0;
b=0;
for turn = 1:4
move = input('enter player 2 move [r,c] ');
r = move(1);
c = move(2);
board(r,c) = -1;
text(c,-r,'O','horizontalalignment','center','fontsize',20)
% Check for victory by 0, 2nd player
result = [sum(board), sum(board) ];
result(1) = board(1,1) + board(1,2) + board(1,3);
result(2) = board(2,1) + board(2,2) + board(2,3);
...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here