For this assignment you will create a version of the popular game mastermind! You can play an online version of the game here: Mastermind online (Note, your game will look and behave a bit...


For this assignment you will create a version of the popular game mastermind! You can play an online version of the game here: Mastermind online (Note, your game will look and behave a bit differently) The rules for your game are as follows The computer generates a random password according to the following rules of The password is 5 integers long o The password will consist of integers in the range [1,9] o The password should not have any duplicate values o An example password would be: [9,1,7,4,2] o Every run of the game should generate a different password o The random.sample0 and random.shuffle0 functions can solve this problem trivially, and so their use will result in a mark of 0 for this portion of the assignment. The user then has 10 turns to guess the password. Each turn, the user should be notified of how many turns remain. Each turn the user makes one guess, by entering 5 digits (at a single prompt) Next, the computer reports the the user's result as follows o The number of digits in the user's guess that appear (anywhere) in the password o The number of digits in the user's guess that exactly match the digit in the password (same digit, same position) If the user guesses all five digits correctly (correct digits and correct positions), the game ends with a win message If the user runs out of turns, the game ends with a loss message. This should include a 'cleanly' formatted display of the correct password (e.g. 1 2 3 4 5, not [1, 2, 3, 4, 5]) When the game ends, your program should ask the user if they would like to play again. This should be a yes or no question, and any invalid input should cause the question to be repeated you may assume that the user correctly enters 5 numbers each turn, however you must allow them to enter all 5 into a single prompt (separated by spaces as in the examples below). (Tip: the string. split0 method might be useful here.) Your code must be structured in a procedural manner. That is, your code should have a main0 method that orchestrates the main logic of your game, and it should have (at minimum) functions to perform the following operations. Please note, your implementation must use the names given here. GeneratePassword0 This function should generate a random password according to the rules above, and return it as a list. * GetUserGuess0 This function should prompt the user for their guess and return a list of the integers that they enteric. Report Result (password, guess) this function should compare the user's guess to the secret password and determine the results according to the rules above. It should display to the user their results (see examples below), and it should return a Boolean value: True if the user guessed all 5 digits correctly (i.e., the win condition), and False otherwise


May 19, 2022
SOLUTION.PDF

Get Answer To This Question

Submit New Assignment

Copy and Paste Your Assignment Here