$24.99
Description: For this assignment, you will write a Python version of the Mastermind Game
Mastermind is a two-player logic game and what passed for fun before the internet
existed.
Details: A game of Mastermind begins with one player choosing a hidden pattern of 4
pegs, each of which is one of 6 colors. Colors may be repeated in the pattern. The
other player then tries to deduce the pattern through a series of “guesses.” Each guess
consists of a pattern of 4 pegs. If a guess is correct, the guessing player wins and the
game is over. Otherwise, the player is told how many colors and positions he/she has
right. This is done with white and black pegs. A white peg indicates that a color is
correct while a black pegs indicates that a color and position are correct. However, the
position is not identified. The guesser’s goal is, of course, to deduce the pattern in as
few guesses as possible.
In our version of the game, the computer will always be the player that chooses the
pattern and a human player will be the guesser. Thus, the pattern will be determined
at random. The six colors are: black, white, red, green, purple, and orange. Note that
each begins with a unique first letter so that they can be concisely represented on the
board as a single upper-case letter. The pegs indicating the quality of the guess, will
be represented using a single lower-case ’b’ or ’w’.
1
You will write a number of Python functions to solve this problem. They include:
create new game, get guess, evaluate guess, and print board. Each is specified
below. You may have additional functions a well but those listed must be part of your
implementation. Note that print board prints the current guess and result as well as
all previous guesses and result in the game.
You will choose your representation of the data. Think carefully about this before you
begin coding.
Function Specifications:
• create new game
– Parameters: none
– Returns: a valid game pattern in your chosen representation
• get guess
– Parameters: none
– Returns: a valid game pattern, indicating the user’s guess, in your chosen
representation
• evaluate guess
– Parameters: a valid game pattern
– Returns: sequence of pegs indicating correctness of the guess, in your chosen
representation
• print board
– Parameters: a valid game board
– Returns: none
2
Adhere to common coding conventions and comment your code.. Include a comment
at the top that looks like this:
#
#