Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.26 KB | None | 0 0
  1. import random
  2.  
  3.  
  4. def remainder(count_of_chips):
  5. if count_of_chips % 10 == 1 and count_of_chips % 100 != 11:
  6. return str(count_of_chips) + " фишку."
  7. elif count_of_chips % 10 in [2, 3, 4] and count_of_chips % 100 not in [12, 13, 14]:
  8. return str(count_of_chips) + " фишки."
  9. else:
  10. return str(count_of_chips) + " фишек."
  11.  
  12.  
  13. def greeting():
  14. global count_of_chips
  15. global max_count_of_chips
  16. global first_move
  17. start = input('''Здравствуй!
  18. Я очень люблю играть в 'Фишки', давай сыграем?(да/нет)''')
  19. if start == "да":
  20. count_of_chips = int(input("Введите кол-во фишек: "))
  21. max_count_of_chips = int(input("Введите маскимальное кол-во фишек: "))
  22. first_move = int(input("Кто ходит первый? (1 - ВЫ, 2 - компьютер)"))
  23. game()
  24. else:
  25. print("Сам с собой поиграю:С")
  26.  
  27.  
  28. def game():
  29. now_move = first_move
  30. global count_of_chips
  31. while count_of_chips >= max_count_of_chips:
  32. if now_move == 1:
  33. print("Осталось " + remainder(count_of_chips))
  34. taken_by_player = int(input("Сколько фишек вы хотите взять? (макс." + str(max_count_of_chips) + ")"))
  35. assert taken_by_player <= max_count_of_chips, "Нельзя взять больше " + str(max_count_of_chips) + " фишек"
  36. count_of_chips -= taken_by_player
  37. now_move = 2
  38. else:
  39. print("Осталось " + remainder(count_of_chips))
  40. taken_by_computer = random.randint(1, max_count_of_chips)
  41. print("Компьютер взял " + remainder(taken_by_computer))
  42. count_of_chips -= taken_by_computer
  43. now_move = 1
  44. if count_of_chips:
  45. print("Осталось " + remainder(count_of_chips))
  46. print("Компьютер взял " + remainder(count_of_chips)) if now_move == 2 else print(
  47. "ВЫ взяли " + remainder(count_of_chips))
  48. print("ВЫ выиграли!!!!") if now_move == 2 and not count_of_chips else print("Выиграл компьютер:С")
  49.  
  50.  
  51. greeting()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement