Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

CISC 130 Lab M4 - Tic-Tac-Toe Introduction This Lab should be completed by each student, individually. That is, devise a solution of your own and

image text in transcribed
image text in transcribed
CISC 130 Lab M4 - Tic-Tac-Toe Introduction This Lab should be completed by each student, individually. That is, devise a solution of your own and then implement it. In this lab, in addition to the Matlab programming that you have already learned, and the usual problem solving, you will use a variety of means to share data between functions. The Lab Setup The following steps will help you set up the lab. 1. In your CISC 130 directory, using Matlab, create a new directory LabM4 and new file LabM4_TTT.m 2. Put a comment at the top of the file listing yourself as the author. Activities Implement a Tic-Tac-Toe* game with a user interface and computer opponents: 1. Code the solution as a set of functions (within a single file); the first function sets up the interface, and the others implement various tasks. 2. Create a user interface employing buttons as the 33 playing field. (uicontrols must be used.) Connect each of the buttons to the same update function. 3. Enforce the rules (including determination of wins and ties). 4. On successive games: alternate the player that starts, or have the loser start. 5. Notify the User of the result of each round. 6. Create a scoreboard indicating the number of wins for each player as well as ties. 7. Create About, Next, and Quit buttons. 8. Create (at least) two (computer) opponents and provide the associated buttons. The opponent(s) must be able to play both sides.** "The game is also known as "noughts and crosses", "Xs and Os",... **The code for the opponent(s) should only be attempted after all of the other features are implemented. Submission Submit the single file containing all of the functions through Canvas. More Notes Sketch the interface (so that you know what you are building). Break the project into smaller tasks (i.e., features); consider whether each feature should be within its own function or incorporated into an existing function. Create the setup portion of the code to match your sketch (and then implement each callback, testing each as it is implemented). Use must use global to enable sharing of variables between the functions. (That is, those that are not passed as calling arguments). Use persistent to hold on to values of local variables between function calls if needed. Alternate between two symbols that are displayed on the buttons (e.g. X...O......O...). Confirm that you could play a game using the GUI as your "paper" before moving on to other features. Create a function to update pushed TTT buttons; this function will perform the "bookkeeping" tasks for the game. In addition to displaying the "moves" on the 33 field of buttons, record the moves in an internal "surrogate" matrix. This matrix is more readily examined than attempting to directly read the strings off of the buttons. Create a function to determine if the game has ended (by turns (i.e., a tie) or because of a win). The method to determine a winner can use the surrogate matrix of moves (mentioned above). Remember that a tie can only occur when all squares within the field have been used. Create a scoreboard and keep it up to date: X wins, O wins, ties. Create a function to reset the GUI in preparation for the next game (i.e., "erases" the paper) Create two opponents. Each opponent is "activated" by a button push rather than being automatic. The "opponents" can play either side at any time. Remember that an opponent performs the same tasks/functions that are performed by the human user and no more. DO NOT do any bookkeeping within the opponent. (1) Create an opponent that does not try to win (random play?). (2) Create an opponent that tries to win. (This should be your last task.) Typically, this "smarter" opponent is based on the code that is used to determine a win

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Learning MySQL Get A Handle On Your Data

Authors: Seyed M M Tahaghoghi

1st Edition

0596529465, 9780596529468

Students also viewed these Databases questions

Question

305 mg of C6H12O6 in 55.2 mL of solution whats the molarity

Answered: 1 week ago