Adding an increase in difficulty level
This commit is contained in:
parent
7bd154691e
commit
28913baa5e
|
@ -11,3 +11,8 @@
|
|||
5) Создание цикла while для ввода попыток
|
||||
|
||||
6) Создание цикла while для анализа попытки и вывода подсказки
|
||||
|
||||
Идеи:
|
||||
|
||||
1) Добавить уровни сложности, с повышением которых будет
|
||||
увеличиваться длина загаданного слова и уменьшаться количество попыток
|
||||
|
|
55
main.py
55
main.py
|
@ -8,44 +8,57 @@ def create_secret_num(guess_num):
|
|||
random.shuffle(digits)
|
||||
return ''.join(digits[:guess_num])
|
||||
|
||||
def attempt_check(attemt):
|
||||
def attempt_check(attemt, secret_num):
|
||||
clue = []
|
||||
for i in range(len(attemt)):
|
||||
|
||||
if attemt[i] == attemt[i]:
|
||||
if attemt[i] == secret_num[i]:
|
||||
clue.append("Fermi")
|
||||
if attemt[i] in attemt:
|
||||
elif attemt[i] in secret_num:
|
||||
clue.append("Pico")
|
||||
return ' '.join(clue) if clue else 'Bagle'
|
||||
sorted(clue)
|
||||
return ' '.join(clue) if clue else 'Bagels'
|
||||
|
||||
def game(max_nam, guess_num):
|
||||
|
||||
def game():
|
||||
secret_num = create_secret_num(guess_num)
|
||||
print("I meade a number.")
|
||||
attemt_num = 1
|
||||
|
||||
while max_nam >= attemt_num:
|
||||
|
||||
attemt = ''
|
||||
while len(attemt) != guess_num or not attemt.isdecimal():
|
||||
print(f"Attemt № {attemt_num}") # Вывод информации о том, сколько попыток сделал игрок
|
||||
attemt = input("> ")
|
||||
|
||||
if secret_num == attemt:
|
||||
print("You win!")
|
||||
level = 1
|
||||
while True:
|
||||
if max_nam <= attemt_num:
|
||||
break
|
||||
if level != 1:
|
||||
max_nam += 2
|
||||
guess_num += 1
|
||||
attemt_num = 1
|
||||
secret_num = create_secret_num(guess_num)
|
||||
|
||||
print(attempt_check(attemt)) # А вот и подсказка
|
||||
while max_nam >= attemt_num:
|
||||
|
||||
attemt_num += 1
|
||||
attemt = ''
|
||||
print(f"You have {max_nam} attempt and {guess_num}-digit number")
|
||||
while len(attemt) != guess_num or not attemt.isdecimal():
|
||||
print(f"Attemt {attemt_num}, Level {level}") # Вывод информации о том, сколько попыток сделал игрок
|
||||
attemt = input("> ")
|
||||
|
||||
if secret_num == attemt:
|
||||
print("You win!")
|
||||
print("Next level...")
|
||||
break
|
||||
|
||||
print(attempt_check(attemt,secret_num)) # А вот и подсказка
|
||||
|
||||
attemt_num += 1
|
||||
level += 1
|
||||
print("You're done trying")
|
||||
print(f"The hiden numbers is {secret_num}")
|
||||
|
||||
|
||||
|
||||
def main():
|
||||
while True:
|
||||
game()
|
||||
answer = input("You want repeat the game?> ").lower()
|
||||
if answer == 'no':
|
||||
game(max_nam, guess_num)
|
||||
if input("You want repeat the game?> ").lower().startswith('n'):
|
||||
print("Thanks for playing")
|
||||
break
|
||||
|
||||
|
|
Loading…
Reference in New Issue