Geocrack

The Guessr Game

Sep 1st, 2022
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.68 KB | None | 0 0
  1.  
  2. # -*- coding: utf-8 -*-
  3. """Untitled
  4.  
  5. Automatically generated by Colaboratory.
  6.  
  7. Original file is located at
  8.    https://colab.research.google.com/drive/1mGC_2zMwv1bRyqc7KHlQzDE_uyfClIDe
  9. """
  10.  
  11. import random
  12. score = 0
  13. tries = 0
  14.  
  15.  
  16. def main_game(score, tries):
  17.     print("""\n\nWELCOME TO THE GUESSR GAME!
  18.    Here, you play against the computer!
  19.    The computer thinks of either 0 and 1.
  20.    Your Job is to guess what the computer guessed!
  21.    If you do it right, you get one point.
  22.    Or, you get none.
  23.    Based on your guesses, you can unlock various things!(Coming soon)
  24.    Then, let us begin!\n\n""")
  25.     while True:
  26.         computer_guess = str(random.randint(0, 1))
  27.         player_guess = input("Please enter your choice (0/1/M) : ").lower()
  28.         if not player_guess in "01m" or player_guess == "":
  29.             print("Please enter a valid choice\n\n")
  30.             continue
  31.         if player_guess == "m":
  32.             print(f"Your Final Score = {score} in {tries} tries\n\n")
  33.             return score, tries
  34.         elif player_guess == computer_guess:
  35.             score += 1
  36.             print("You guessed it right!")
  37.         else:
  38.             print("You didn't guess it right!")
  39.         tries += 1
  40.         print(f"Your Score is {score} \n\n")
  41.  
  42.  
  43. def achievements():
  44.     achieve = {"rookie": 0, "mid": 0, "master": 0, "epic": 0, "impossible": 0}
  45.     if score > 5:
  46.         achieve["rookie"] = 1
  47.     if score > 10:
  48.         achieve["mid"] = 1
  49.     if score > 20:
  50.         achieve["master"] = 1
  51.     if score > 30:
  52.         achieve["epic"] = 1
  53.     if score > 50:
  54.         achieve["impossible"] = 1
  55.     cent = 0
  56.     if all(value == 1 for value in achieve.values()):
  57.         cent = 1
  58.  
  59.     print(f"""\n\n====ACHIEVEMENTS====
  60.  
  61.      ***Your Score = {score}
  62.      ***Achievements completed : {sum(achieve.values())}/5
  63.  
  64.      1. Newbie (Get your score above 5) ({achieve["rookie"]}/1)
  65.      2. Mid (Get your score above 10) ({achieve["mid"]}/1)
  66.      3. Master Guessr (Get your score above 20) ({achieve["master"]}/1)
  67.      4. Epic (Get your score above 30) ({achieve["epic"]}/1)
  68.      5. Impossible (Get your score above 50) ({achieve["impossible"]}/1)
  69.      >> 100% Completion (You completed all the achievements!) ({cent}/1)
  70.      >> TOP SECRET (???) (--/--)\n\n""")
  71.     input("Type 'M' here to return to menu. ")
  72.  
  73.  
  74. while True:
  75.     print("""====GUESSR GAME====
  76.  1. Play
  77.  2. Achievements
  78.  3. Exit""")
  79.     input1 = input("Please enter a choice : ")
  80.     if input1 == "1":
  81.         score, tries = main_game(score, tries)
  82.     elif input1 == "2":
  83.         achievements()
  84.     elif input1 == "3":
  85.         break
  86.     else:
  87.         print("Please enter a valid choice\n\n")
  88.  
Advertisement
Add Comment
Please, Sign In to add comment