Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

General Description The goal of this project is to create the matching game Memory. This is a small project and so make sure to read

General Description

The goal of this project is to create the matching game Memory. This is a small project and so make sure to read this whole description and start well in advance. Follow all instructions given and make sure to build every element of the game. If the instructions are not followed, you will lose points.

Game Description

In the game Memory, a board is created randomly. The board is either 4x4, or 6x6. Each location on the board holds a single number that has a hidden pair somewhere else on the board.

On the start of each turn, the player selects two locations on the board and the character/number is revealed in those two locations. If the characters are the same then the player has made a pair and the characters stay clear on the board. If the characters are not the same then they disappear again once the player hits enter.

The game is won by the player determining every pair and thereby displaying every space. The game is only lost if the player gives up, but you do not need to account for that. A more detailed description of the game can be found by googling memory matching game description. Most of the variants include two players, but the one you will build is only one player.

Code Instructions

There are several portions of the knowledge taught over the course of this semester that you will need to use to complete this project including: loops (for and while), conditionals(if-statements), functions, matrices and scripts. The following instructions are necessary and are elements that should help to get the wheel rolling on this project.

Attached with this homework assignment is a function that will randomly create the board for you. Use this function to initially create your board based off of the size given by the user. This function is called BoardGenerator.

You must write a function that prints the board somehow in a format that is useful and easy to read. See attached example for a good layout.

Write a script which will first ask the user for a size and then use the BoardGenerator function to create a board of that size. The program will then display a blank board (see Output attached). The program will then ask the user for the locations of the characters that they would like to flip and flip them one at a time and printing out the board simultaneously. After a pair is made the characters shall stay displayed and not change. Once all the characters have been displayed the program will end.

Comments, simple as that.

Use fprintf and input functions to print out matrices and messages to the user. If you have not used input yet then there is a description in the hints below. For fprintf use past homeworks as a reference.

Use the input function to get input from the user. Syntax for this function below:

var = input(Enter the size of the board: );

For more instructions look to: https://www.mathworks.com/help/matlab/ref/input.html

Hints

Just a couple of recommendations for completing parts of this project, these are not necessary:

Use another array in addition to the board that solely keeps track of whether a location has been matched already. This will help for printing. This matrix will also help to determine the end of the game.

If you want to take the sum of multidimensional matrix then take the sum on it multiple times. For example: sum(sum( [ 1 0 0 1; 0 1 1 1; 0 0 1 1] ) = 7. If you are confused why I would give you this hint, then consider the first hint.

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

Beginning Apache Cassandra Development

Authors: Vivek Mishra

1st Edition

1484201426, 9781484201428

More Books

Students also viewed these Databases questions

Question

evaluate the quality of your data;

Answered: 1 week ago