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 »
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 10 days AfterMay 17, 2021

Solution

Bhoomika Sonane answered on May 27 2021
24 Votes

function [] = TTT_Martin_Clark()
% tic-tac-toe game designed by - Martin & Clark ---- Date - 27 May 2021
close all;clc;
uiwait(msgbox('Hi, Welcome to this epic game : TIC-TAC-TOE. Your...

Submit New Assignment

Copy and Paste Your Assignment Here