Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- import math
- import time
- def askIfPlay():
- wantPlay = False
- askPlay = str(input("Do you want to play MASTERMIND?: "))
- askPlay = askPlay.lower()
- if(askPlay.startswith("y")):
- wantPlay = True
- difficultyAndNumbers([])
- else:
- quit()
- def difficultyAndNumbers(difficultyRating):
- rulesPrint = print("Make sure to seperate the numbers with a comma!")
- uDiff = int(input("Choose difficulty 1-3: "))
- orderCorrect = False
- if(uDiff == 3):
- orderCorrect = True
- else:
- orderCorrect = False
- Attempts = 10
- numbersGuess = 4
- Attempts -= int(uDiff*2)
- numbersGuess += uDiff
- numberStore = []
- numbersGenerated = 0
- while(numbersGenerated <= numbersGuess):
- numGen = random.randint(0,9)
- numbersGenerated += 1
- numberStore.append(numGen)
- if(len(numberStore) == numbersGuess):
- print(numberStore)
- if(orderCorrect == True and Attempts != 0):
- print("This is going to be almost impossible! You have to"
- "guess the numbers in the right order!")
- print(rulesPrint)
- print("You have", Attempts, "tries to get this right!")
- while(Attempts >= 0):
- playerGuess = str(input("Guess: "))
- playerGuess = [int(playerGuess) for playerGuess in playerGuess.split(',')]
- if (playerGuess != numberStore):
- print("You guessed wrong!")
- print("You have", Attempts, "tries left.")
- Attemtpts -= 1
- elif(any(playerGuess == numberStore)):
- print("You have the right numbers, now you have to guess the order")
- print("You have", Attempts, "tries left.")
- elif(playerGuess == numberStore):
- print("You win! You guessed it right!")
- print("Might I add, you're a god.")
- elif(orderCorrect == False and Attempts != 0):
- while(Attempts >= 0):
- playerGuess = str(input("Guess: "))
- playerGuess = [int(playerGuess) for playerGuess in playerGuess.split(',')]
- if any(playerGuess != numberStore):
- print("You guessed wrong!")
- print("You have", Attempts, "tries left.")
- Attempts -= 1
- elif any(playerGuess == numberStore):
- print("You win! You guessed it right!")
- if(Attempts <= 0):
- tryAgain = str(input("Sorry, you've ran out of tries! Do you want to play again?"))
- tryAgain = tryAgain.lower()
- if(tryAgain.startswith("y")):
- askIfPlay()
- else:
- print("Thanks for playing")
- time.sleep(2)
- quit()
- askIfPlay()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement