Question
PYTHON CODE BREAKER Vault Breaker (similar to Mastermind, or Guess the Number) is traditionally a two-player game where one player makes up a combination composed
PYTHON CODE BREAKER
Vault Breaker (similar to Mastermind, or Guess the Number) is traditionally a two-player game where one player makes up a combination composed of four digits and the other players goal is to guess the combination. The second player guesses what she thinks the combination might be, then the first player gives feedback in a very specific way to give the second player hints about the combination. Using logic and process of elimination, the second player guesses until they get the combination correct. To play a variation of Vault Breaker, to here http://www.goobix.com/games/guess-the-number/
In this variation of Vault Breaker, here are the rules: 1. No digit is used twice in the (the one required to break the vault). 2. The first player (computer) gives feedback as follows:
A. For every correct digit in the correct place, the computer prints a =.
B. For every digit less than the digit in its place, the computer prints a <.
C. For every digit greater than the digit in its place, the computer prints a >.
So, for example, if the combination was 1234, and the guess was 1324, the feedback would be ==<>. Note that the feedback is not in the order of the digits, but in the order of the A/B/C rule above. (This makes the game harderafter all we want our vault to be secure!)
For this program, you can hard code the vault to have a combination of 1234.
Your program should do the following:
1. Prompt the player for a guess.
2. Check to see if the player guessed the combination right.
3. a. If they got it right, tell them they won and end the game by printing out You broke the vault!
b. Print out the number of times they took to guess the correct answer. For example: - if they took 5 tries print out, you took five tries to break the vault.
4. If they didnt get it right, give the player feedback for that guess, and let them guess again, continuing the guess/feedback process until they get it right.
Example Input & Output
student@ubuntu-vm:~/cpsc1110examples/program2a$ ./a.out
Guess the combination (four digits): 1324
Nope! Your clue is: ==<>
Guess the combination (four digits): 1243
Nope! Your clue is: ==<>
Guess the combination (four digits): 1111
Nope! Your clue is: =<<<
Guess the combination (four digits): 2222
Nope! Your clue is: =<<>
Guess the combination (four digits): 7834
Nope! Your clue is: ==>>
Guess the combination (four digits): 1234
You broke the vault! You took 5 tries to break the vault!
Handle errors gracefully. If the user puts in a number thats fewer than 3 digits or greater than four digits, print an error message: Please use a four-digit number for the combination
Have the computer generate a new combination every time you run the program. The input/output will look different each time depending on what the computer generates, so there is no example input/output provided. If any of the four guess characters is a 0, the computer prints out the combination it chose. Do not forget to guarantee that the same digit does not appear twice!
Hints: Look up documentation for a module called random
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started