""" ------------------------------------------------- Project: Guess The Number Standard: the what? School: Tauranga Boys' College Author: Harry Burt Date: aint done. Python: 3.5 ------------------------------------------------- """ import random import time player_points = 0 ai_points = 0 def introduction(): print("███╗ ██╗██╗ ██╗███╗ ███╗██████╗ ██████╗ ██████╗ ██╗ ██╗███╗ ███╗██████╗ ██████╗") print("████╗ ██║██║ ██║████╗ ████║██╔══██╗██╔═══██╗ ██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔═══██╗") print("██╔██╗ ██║██║ ██║██╔████╔██║██████╔╝██║ ██║ ██████╔╝██║ ██║██╔████╔██║██████╔╝██║ ██║") print("██║╚██╗██║██║ ██║██║╚██╔╝██║██╔══██╗██║ ██║ ██╔══██╗██║ ██║██║╚██╔╝██║██╔══██╗██║ ██║") print("██║ ╚████║╚██████╔╝██║ ╚═╝ ██║██████╔╝╚██████╔╝ ██║ ██║╚██████╔╝██║ ╚═╝ ██║██████╔╝╚██████╔╝") print("╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝╚═════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝╚═════╝ ╚═════╝ ") global player_points, ai_points player_name = input("What is your name?: ") # Asking for player name return player_name def guess_the_number(): global player_points, ai_points random_number = random.randint(1, 1000) max_attempts = 10 # Total attempts given to player print(f"Hello {player_name}! I have chosen a number between 1 and 1000") print(f"You have {max_attempts} attempts to find out the number") while max_attempts > 0: guess = int(input(f"{max_attempts} left to Guess The Number: ")) if guess < random_number: print("The number is higher, Guess again") elif guess > random_number: print("The number is lower, Guess again") else: print("Congratulations! You got it!") player_points += 1 print("Total player points: ", player_points) print("Total AI points: ", ai_points) break max_attempts -= 1 if max_attempts == 0: print("You have run out of guesses. You lose!") print("The real number was.....(drum roll) ") print(random_number) ai_points += 1 def rules(): print("Rules of Guess The Number!") time.sleep(1) print("I will choose a number between 1 and 1000") time.sleep(1) print("You have 10 attempts to guess the number") time.sleep(1) print("If you guess the number, You gather one point. If not then that point will go to me") time.sleep(1) print("Whoever has the most points at the end of the three rounds will be the winner") def play_rounds(): rounds = 0 max_rounds = 3 while rounds < max_rounds: next_round = input("Do you want to continue?: ") if next_round.lower() == "yes" or next_round.lower() == "y": rounds += 1 guess_the_number() elif next_round.lower() == "no" or next_round.lower() == "n": print("You lose! Thank you for playing!") break else: print("That is not a yes or no") # Main program - Tells python the order in what to run things player_name = introduction() choice = input("Welcome to Guess The Number! Would you like to see the [R]ules first or go straight to the [G]ame? ") if choice.lower() == "r" or choice.lower() == "rules": rules() input("Press Enter to start the game") play_rounds() elif choice.lower() == "g" or choice.lower() == "game": play_rounds()