Question: For your homework, turn in two m files, called hw5 yourinitials func.m and hwy 5 yourinitials script.m. One should be a function, and the other

 For your homework, turn in two m files, called hw5 yourinitialsfunc.m and hwy 5 yourinitials script.m. One should be a function, andthe other should be a script file respectively. You will be playing

For your homework, turn in two m files, called hw5 yourinitials func.m and hwy 5 yourinitials script.m. One should be a function, and the other should be a script file respectively. You will be playing a game called Mastermind For the game "Mastermind", you will create a function that simulates the game between two players. In the game, the first player is the Code Maker, who creates a certain code selected from the available colors. So for example, a three digit code could be: green, yellow, blue. The second player is the Code Breaker, who is trying to guess the code made by the Code Maker Each round, the Code Breaker makes a guess, and the Code Maker returns information regarding the guess. The Code Maker returns the number of correct colors that are in the correct spot, but does not reveal which colors are in the right spot. The Code Breaker then guesses again. The game continues until the Code Breaker guesses the right code or until 8 guesses have been made. Another example: if there are 6 possible colors (red, yellow, green, blue, white, black) and 4 digits, the Code Maker could create the following code in this order: yellow, green, white, blue NO COLORS MAY BE REPEATED. The Code Breaker does not know what the code is, so they will make their first guess, which could be: green, blue, white, red. The Code Maker would then return 1, because there is only one correct color in the correct spot. In this case, white was correctly placed. The Code Breaker would then guess a new combination in an attempt to match the Code Maker's code, and the Code Maker would return the new information For your function, you will represent the colors as numbers. For example, if there are 6 possible colors (red, yellow, green, blue, white, black), red 1, yellow 2, green 3, blue 4, white 5, black 36. So, in the previous example, the code would be equal to 2354. The Code Breaker first guess would be equal to 3451. NOTE: YOU CANNOT HAVE MORE THAN 9 OR LESS THAN 1 COLORS YOUR FUNCTION hw5 yourinitials func. m Create a function with two inputs: number of colors and number of digits Dl, and one output: number of rounds of guesses (R) 1) Using the provided function named gen vector.m, create a vector called guess vector that stores all possible color combinations given the digits. Do not alter the gen vector m function. The inputs to gen vector are C and D, and the output is a vector with all possible codes given the values of Cand D. So if 6 4 and D 4, then there are 360 possible codes 2) Randomly select a single value from guess vector, and assign it to the variable answer. For your homework, turn in two m files, called hw5 yourinitials func.m and hwy 5 yourinitials script.m. One should be a function, and the other should be a script file respectively. You will be playing a game called Mastermind For the game "Mastermind", you will create a function that simulates the game between two players. In the game, the first player is the Code Maker, who creates a certain code selected from the available colors. So for example, a three digit code could be: green, yellow, blue. The second player is the Code Breaker, who is trying to guess the code made by the Code Maker Each round, the Code Breaker makes a guess, and the Code Maker returns information regarding the guess. The Code Maker returns the number of correct colors that are in the correct spot, but does not reveal which colors are in the right spot. The Code Breaker then guesses again. The game continues until the Code Breaker guesses the right code or until 8 guesses have been made. Another example: if there are 6 possible colors (red, yellow, green, blue, white, black) and 4 digits, the Code Maker could create the following code in this order: yellow, green, white, blue NO COLORS MAY BE REPEATED. The Code Breaker does not know what the code is, so they will make their first guess, which could be: green, blue, white, red. The Code Maker would then return 1, because there is only one correct color in the correct spot. In this case, white was correctly placed. The Code Breaker would then guess a new combination in an attempt to match the Code Maker's code, and the Code Maker would return the new information For your function, you will represent the colors as numbers. For example, if there are 6 possible colors (red, yellow, green, blue, white, black), red 1, yellow 2, green 3, blue 4, white 5, black 36. So, in the previous example, the code would be equal to 2354. The Code Breaker first guess would be equal to 3451. NOTE: YOU CANNOT HAVE MORE THAN 9 OR LESS THAN 1 COLORS YOUR FUNCTION hw5 yourinitials func. m Create a function with two inputs: number of colors and number of digits Dl, and one output: number of rounds of guesses (R) 1) Using the provided function named gen vector.m, create a vector called guess vector that stores all possible color combinations given the digits. Do not alter the gen vector m function. The inputs to gen vector are C and D, and the output is a vector with all possible codes given the values of Cand D. So if 6 4 and D 4, then there are 360 possible codes 2) Randomly select a single value from guess vector, and assign it to the variable

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!