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