"""
-------------------------------------------------
   Project: Higher Lower
  Standard: 91883 (AS1.7) v.1
    School: Tauranga Boys' College
    Author: Yashil Singh
      Date: 13/03/2024
    Python: 3.5
-------------------------------------------------
"""
import random

def set(): #All variables needed for the game
    global reset_guesses, number, rounds, user_score, AI_score, round_won, roundNum
    reset_guesses = 0
    rounds = 3
    user_score = 0
    AI_score = 0
    number = random.randint(1, 1000)
    round_won = True
    roundNum = 1



#Title
 
print("""                        ▓▓  ▓▓                          
                        ████████                        
                    ██▓▓░░░░░░░░▓▓██                    
                    ████░░░░ ░░░▓▓██                    
                    ██▓▓░░░   ░░██▓▓                    
                    ██▓▓░░     ░▓▓██                    
                    ██▓▓░       ▓▓██                    
                    ████         ▓██                    
        ▓▓█████████████           ████████████████      
        ▒▒▓▓██████▓▓▓▓█  ░░   ░░  ▓▓▓▓██▓▓██▓▓████      
            ██▓▓▒▒░░░░░░░░░   ░░░░░░░░░░████▓▓          
            ████▒▒░░░░░░░░░   ░░░░░░░░░░██▓▓██          
            ░░░░▒▒▓▓░░░░░░░   ░░░░░░▓▓▓▓                
                ▒▒▓▓░░░░░░░   ░░░░░░██▓▓                
                ░░▒▒▒▒▒▒░░░   ░░▒▒▒▒▒▒                  
                    ██▓▓░░░   ░░██▓▓                    
                      ░░▓▓▒   ▒▒░░                      
                        ████████""")


#Checks if it's a name and not a random number str
while True:
    name = str(input("What is your name? ")) #get player name
    if name.isalpha() == True:
        break
    else:
        print("That's not a real name, try again")
        

print(
"Hey there, "+name+"! Welcome to the guessing game challenge! Here's the deal: you have the thrilling opportunity to embark on a journey of numerical exploration where you'll be granted the chance to make estimations beyond the realm of a thousand. Picture this: you'll be granted the esteemed privilege of making not one, not two, but up to ten daring guesses per round. But wait, there's a twist - your target is a number residing somewhere in the realms under 1000. Are you ready to delve into the depths of numerical speculation and put your intuition to the test? Let the guessing games begin!")

#You guess, AI makes a number up
set() #Inizalize the "set" func
while roundNum <= 3: #Loops so long as rounds are equal or under 3
    round_win = False # When player wins set to false so that user_victory only increases in increments of 1
    guesses = reset_guesses # guesses are rotated back to 0
    number = random.randint(1, 1000) # chooses a number

    print(roundNum) #amount of rounds that have passed 
    print("your score is", user_score, "AI score is", AI_score) 


    while guesses <= 10: # Loops so long as guesses are equal or under 10
        print("[AI] Guess the number!")
        user_guess = int(input("What's your guess? "))
        #Checking if user inputed a number/correct number
        while True:
            try:    
                if user_guess > 1000 or user_guess < 0:
                    print("That's not... :(")
                    user_guess = int(input("What's your guess? "))
                else:
                    break
            except:
                print("That's not a number :(") # If the input isn't an int
                user_guess = int(input("What's your guess? "))


        #Checking if user number is higher/lower or correct
        if user_guess < number:
            print("Higher!, "+name+" you have", 10 - guesses, "guesses left")
        elif user_guess > number:
            print("Lower!, "+name+" you have", 10 - guesses, " guesses left")
        else:
            print("SPOT ON!")
            round_win = True
            break  # Break out of the loop if the user guesses correctly
        guesses += 1  # Update guesses
        #Increases the user/AI score based off the round_win var at the end of 10 guesses or when the number is guessed
    if round_win:
        user_score += 1
        print("Win +1 "+name+" score")
    else:
        AI_score += 1
        print("Loss +1 AI score")
        print("The number was", number)
    roundNum += 1


if user_score > AI_score:
    print("""
The game stretched on, round after round, as players from all walks of life stepped up to the challenge. Some approached with cautious optimism, while others exuded an air of confidence that bordered on audacity. But regardless of their demeanor, each participant was united by a common goal: to unravel the mystery of the elusive number beyond 1000. As the rounds progressed, tension mounted and anticipation filled the air. With each guess, the room erupted into a symphony of gasps, cheers, and groans, mirroring the rollercoaster of emotions experienced by the players. Some soared with elation as their guesses landed spot-on, while others grappled with frustration as their attempts fell short. Yet, amidst the highs and lows, a sense of camaraderie blossomed among the players. Strangers became allies, offering words of encouragement and sharing strategies in pursuit of the elusive number. Bonds formed in the crucible of competition, transcending barriers of age, background, and experience. But as the game neared its conclusion, a palpable sense of urgency gripped the room. With each dwindling guess, the pressure mounted, pushing players to push the boundaries of their intuition and reasoning. The stakes were high, and every decision carried the weight of potential victory or defeat. And then, in a moment of collective triumph, it happened. A player, fueled by determination and a stroke of brilliance, uttered the fateful number that had eluded them for so long. Silence descended upon the room as the realization dawned: the mystery had been solved. Cheers erupted, punctuating the air with jubilant exultation as the victorious player basked in the spotlight of their achievement. But amidst the celebration, there lingered a bittersweet tinge, for with the conclusion of the game came the end of an unforgettable journey. As participants exchanged farewells and fond memories, they departed with hearts full of newfound camaraderie and a shared tale to cherish. For in the realm of the guessing game challenge, victory was not solely defined by the attainment of a numerical goal, but by the bonds forged and memories created along the way. And so, as the echoes of laughter and camaraderie faded into the night, the spirit of the game lived on in the hearts and minds of all who had dared to participate. For in the end, it wasn't just about guessing numbers—it was about the journey, the friendships, and the unforgettable moments that made it all worthwhile.""")
    print("YOU WON AI SUCKS! Final score was, "+name+" SCORE", user_score, "AI SCORE", AI_score)
else:
    print("You lost. Great. Final score was, "+name+" SCORE", user_score, "AI SCORE", AI_score)



    

























































































































































































































































































































































































#You should guess here first tbh

































































































































































































































































































































































































































































































    print("""WHY U LOSE???
    -The person""")