Home / Expert Answers / Computer Science / need-help-in-python-creating-mastermind-game-while-including-the-bottom-image-formula-import-random-pa594

(Solved): Need help in python creating mastermind game while including the bottom image formula. import random ...



Need help in python creating mastermind game while including the bottom image formula.

import random

def generate_goal(valid_choices, n)

goal = ""

      for i in range(0, n):

           goal += random.choice(valid_choices)

      return goal

 

Stage Seven:
Modify your previous program. In this stage, additional requirements are added. Your program must calculate and

Answer: (penalty regime: \( 0,0,5,10,15,20,25,30,35,40,45,50 \% \) )

 

Stage Seven: Modify your previous program. In this stage, additional requirements are added. Your program must calculate and report the number of similar matches between the guess and the hidden code. The similar matches are represented with a white peg, shown in this program using the capital letter "W". After the user makes a guess, the board should display the guess from the codebreaker and the feedback from the codemaker on the same row. Similar matches are where the guess has the correct letter, but in an incorrect location. Once a letter in the guess or the hidden code has been used in feedback (i.e., has resulted in a B or \( \mathrm{W} \) response), then it is not used again in another response. The exact matches are calculated first and letters with an exact match cannot also result in a similar match. Example For example, if the hidden code is "oooy" and the guess is "rboo" then we first check for exact matches, and find the third letter is an " 0 " in both the guess and the hidden code, so the feedback will include one "B". Since those letters cannot be reused, we can cross them out and consider the remaining letters from the hidden code "oo- \( \mathrm{y} \) " and the guess "rb-o". When comparing these two, we can see the guess has one letter that is the correct colour but in the wrong location, so the feedback will include one "W". The response to this combination of hidden code and guess will therefore be "BW" New requirements - When displaying the board after a guess, report the number of similar matches between the guess and the hidden code with one letter "W" for each similar match. - The similar matches should be displayed on the right side of the board in the same row as the guess. - The mark column should therefore display both the exact and similar matches with exact matches (B) displayed before similar matches (W) Display format The goal should continue to be displayed to make it easy to develop and test your program. The following example shows a single turn with goal, the guess, and the display of the board with the guesses on the left and the feedback on the right. Goal: goyy 9 (roygbv): yyoo Code||Mark govv||??. . vvgo| \( \mid \) WN. . \( \operatorname{gggg}|| \mathrm{B} \ldots \) oggg||WN. . yvvv||W... yyvv|||WN. yyyv||Bw. . ????||??.. yyoo||WNl. Hint Identifying similar matches is challenging because you must ignore any exact matches. It may help to remove all the exact matches from the two strings before you look for similar matches, and remove the similar matches from the strings as you find them (to avoid accidentally matching similar colours more times than is appropriate). This is the most challenging part of the assignment, so it is OK if you stop before completing this step. Answer: (penalty regime: \( 0,0,5,10,15,20,25,30,35,40,45,50 \% \) )


We have an Answer from Expert

View Expert Answer

Expert Answer


Screenshot --------------------------------------------------- Program #random generator package import random #method to generate random package def generatePassword(): random_list=[] assert 5 <= 10 l = list(range(1,10)) while l[0] == 1: random.shuf
We have an Answer from Expert

Buy This Answer $2

Place Order

We Provide Services Across The Globe