"""
In this game you will have to guess a number and if you guess the correct number. You win a set
and if you win 3 sets. Then you win the game. To make this game simpler if you guess the number
50 and the secret number is 60 which you don't know. It will print 'You are close' as the number
50 is in the range of 40-80 which is less 20 less than 60 which is 40 and 20 more than 60 which
is 80. And after that you guess the number 55. It will print 'You are very close' as it is between
the range 55-65. 60-5==55 and 60+5=65 and when you guess the number you win the set. But you
have to guess the number in 10 tries
"""
import random
rounds = 5
level3={'close_key':10,'closer_key':5}
level2={'close_key':15,'closer_key':5}
level1={'close_key':20,'closer_key':5}
level={}
while len(level)==0:
input_level = input('Which level do you want to play at 1 or 2 or 3. one is hardest')
print("This is best of ", rounds, "rounds game. Whoever wins 3 rounds will win the game")
print("********************")
if input_level=='1':
level=level1
elif input_level=='2':
level=level2
elif input_level=='3':
level=level3
else:
print('It was on wrong level')
i = 0
j=0
mylist=[]
print("Computer has selected a number between 0-100. Guess the number which computer has guessed ! ")
print("If the difference between computer selected number and your guessed number is + or - ", level['close_key'] ,",You will get message \"You are close\"")
print("If the difference between computer selected number and your guessed number is + or - ", level['closer_key'] ,",You will get message \"You are really close .\". ")
print("Else you will get message\"You are too Far away\"")
human=0
computer=0
attempts = 10
while j< rounds:
randomizer = random.randint(0, 100)
i=0
print("********************")
print("Start round ",j+1 , " of ", rounds)
print("********************")
while i < attempts:
g = int(input("Attempt "+str(i+1)+ " of "+ str(attempts)+" Enter your guessed number !"))
mylist.append(g)
i += 1
if g == randomizer:
print(' You have won the set ')
j=j+1
human+=1
print('--------------------------------------------------')
break
elif abs(randomizer - g) <= level['closer_key']:
print('You are really close . Guess another number ')
elif abs(randomizer - g) <= level['close_key']:
print('You are close. Guess another number ')
else:
print('You are far away. Guess another number ')
for k in mylist:
if k == randomizer:
pass
print('--------------------------------------------------')
break
else:
print('Computer has won the set.', 'The computer guessed number is',str(randomizer))
j=j+1
computer+=1
print('--------------------------------------------------')
print("Score: You -", human , " Computer - ", computer)
if human==3:
print('You have won the game ',str(human),'-',str(computer))
break
elif computer==3:
print('Computer has won the game ', str(computer), '-', str(human))
break