Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- def remainder(count_of_chips):
- if count_of_chips % 10 == 1 and count_of_chips % 100 != 11:
- return str(count_of_chips) + " фишку."
- elif count_of_chips % 10 in [2, 3, 4] and count_of_chips % 100 not in [12, 13, 14]:
- return str(count_of_chips) + " фишки."
- else:
- return str(count_of_chips) + " фишек."
- def greeting():
- global count_of_chips
- global max_count_of_chips
- global first_move
- start = input('''Здравствуй!
- Я очень люблю играть в 'Фишки', давай сыграем?(да/нет)''')
- if start == "да":
- count_of_chips = int(input("Введите кол-во фишек: "))
- max_count_of_chips = int(input("Введите маскимальное кол-во фишек: "))
- first_move = int(input("Кто ходит первый? (1 - ВЫ, 2 - компьютер)"))
- game()
- else:
- print("Сам с собой поиграю:С")
- def game():
- now_move = first_move
- global count_of_chips
- while count_of_chips >= max_count_of_chips:
- if now_move == 1:
- print("Осталось " + remainder(count_of_chips))
- taken_by_player = int(input("Сколько фишек вы хотите взять? (макс." + str(max_count_of_chips) + ")"))
- assert taken_by_player <= max_count_of_chips, "Нельзя взять больше " + str(max_count_of_chips) + " фишек"
- count_of_chips -= taken_by_player
- now_move = 2
- else:
- print("Осталось " + remainder(count_of_chips))
- taken_by_computer = random.randint(1, max_count_of_chips)
- print("Компьютер взял " + remainder(taken_by_computer))
- count_of_chips -= taken_by_computer
- now_move = 1
- if count_of_chips:
- print("Осталось " + remainder(count_of_chips))
- print("Компьютер взял " + remainder(count_of_chips)) if now_move == 2 else print(
- "ВЫ взяли " + remainder(count_of_chips))
- print("ВЫ выиграли!!!!") if now_move == 2 and not count_of_chips else print("Выиграл компьютер:С")
- greeting()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement