Question: For this lab assignment, you will write an ARM assembly code from scratch to implement a two-player game of Mastermind (i.e., do not write it

For this lab assignment, you will write an ARM assembly code from scratch to implement a two-player game of Mastermind (i.e., do not write it in C then autogenerate to ASM). In the game of Mastermind, one person (the computer) creates a hidden color combination or code - consisting of 4 color pegs chosen from 6 colors. You may use characters or integers to represent the colors (e.g., 'R' for red, 'G' for green, 'B' for blue, etc... or 1 for red, 2 for green, 3 for blue, etc...) The colors may be repeated. For example, the code might be B, R, R, G (or 3, 1, 1, 2). Your program (i.e., the computer) will play the role of the first person and create a hidden code.

The other player (the user) is the code-breaker and tries to figure out the code by guessing the code. The first player (i.e, your program) gives feedback on the correctness of the guess by telling the user how many correctly positioned color pegs the guess has and how many correct colors but incorrectly positioned pegs the guess has. See the online gameLinks to an external site.. The game usually goes for a maximum of 10 tries before the guesser either wins or loses.

Example program run could look like this:

Computer generated code: B, R, R, G (technically this should be hidden, but you can show this to make sure your code is working properly)

Guess 1: R Y W G

1 correct color(s) in the correct location

1 correct color(s) in the wrong location

Guess 2: Y Y Y Y

0 correct color(s) in the correct location

0 correct color(s) in the wrong location

Guess 3: R Y B B

2 correct color(s) in the correct location

0 correct color(s) in the wrong location

ETC...

Your implementation will use 6 colors, code length 4 and maximum of 10 guesses. These are set as constants (e.g., use "EQU").

At a bare minimum, your code should include the following functions:

generate_key.s - generate the secret code

print_game.s - print the guess and the hints

get_guess.s - get the user guess

find_correct_color.s - determine the number of correct colors but in the wrong locations

find_correct.s - determine the number of correct colors AND in the wright locations

makefile - compile your code

Etc... (you may add additional functions as you see fit)

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!