Create alfa-version game
This commit is contained in:
commit
2b90bb8f3a
|
@ -0,0 +1,13 @@
|
||||||
|
№1 Короткий план
|
||||||
|
|
||||||
|
1) Задать значения максимального количества попыток и количества символов в одной попытке
|
||||||
|
|
||||||
|
2) Вывод условия игры
|
||||||
|
|
||||||
|
3) Создание случайного числа
|
||||||
|
|
||||||
|
4) Создание основного цикла while для завершения или повторения игры
|
||||||
|
|
||||||
|
5) Создание цикла while для ввода попыток
|
||||||
|
|
||||||
|
6) Создание цикла while для анализа попытки и вывода подсказки
|
|
@ -0,0 +1,48 @@
|
||||||
|
import random
|
||||||
|
|
||||||
|
|
||||||
|
max_nam = 10
|
||||||
|
guess_num = 3
|
||||||
|
digits = "0123456789"
|
||||||
|
|
||||||
|
while True:
|
||||||
|
digits = list(digits)
|
||||||
|
random.shuffle(digits)
|
||||||
|
secret_num = ''
|
||||||
|
for i in digits[0:3]:
|
||||||
|
secret_num += i
|
||||||
|
|
||||||
|
print("I mean digit.")
|
||||||
|
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("> ")
|
||||||
|
|
||||||
|
clue = []
|
||||||
|
|
||||||
|
if secret_num == attemt:
|
||||||
|
print("You win!")
|
||||||
|
break
|
||||||
|
|
||||||
|
for i in range(len(attemt)):
|
||||||
|
|
||||||
|
if secret_num[i] == attemt[i]:
|
||||||
|
clue.append("Fermi")
|
||||||
|
if attemt[i] in secret_num:
|
||||||
|
clue.append("Pico")
|
||||||
|
if len(clue) == 0:
|
||||||
|
print("Bagle")
|
||||||
|
else:
|
||||||
|
sorted(clue)
|
||||||
|
print(' '.join(clue))
|
||||||
|
attemt_num += 1
|
||||||
|
print("You spent your attemt")
|
||||||
|
print(f"You want repit the game. The hiden numbers is {secret_num}? 'yes' or 'no'")
|
||||||
|
answer = input("> ")
|
||||||
|
if answer == 'no':
|
||||||
|
print("Thanks for playing")
|
||||||
|
break
|
Loading…
Reference in New Issue