Advertisement
Guest User

Untitled

a guest
Oct 13th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.89 KB | None | 0 0
  1. #!/usr/bin/env python3
  2. import random
  3. import time
  4.  
  5. """
  6.  
  7. RockScissorsPaper
  8. КаменьНожницыБумага
  9.  
  10. - ЛОГ добавить историю выбора
  11. - показывать в процентах
  12.  
  13. - Написать с графикой
  14.  
  15. """
  16.  
  17. endColor = '\033[0m'
  18. boldText = '\033[01m' # жирный текст
  19.  
  20. options = {"1": "Камень", "2": "Ножницы", "3": "Бумага"}
  21.  
  22. win_u = 0 # победы пользователя
  23. win_c = 0 # победы пк
  24.  
  25. print(boldText + '\t\tКамень Ножницы Бумага' + endColor)
  26. print(boldText + '\t\tRock Scissors Paper' + endColor)
  27.  
  28. while True:
  29. time.sleep(0.2)
  30. print(boldText + '\nSCORE:' + endColor)
  31. print('\tВы:', win_u)
  32. print('\tКомпьютер:', win_c)
  33.  
  34. time.sleep(0.2)
  35. print(boldText + '\n1' + endColor + ' - Камень | ' + boldText + '2' + endColor + ' - Ножницы | ' + boldText + '3' + endColor + ' - Бумага | ' + boldText + 'q ' + endColor + ' - выйти')
  36.  
  37. user = input(boldText + '\n> ' + endColor)
  38. user = user.lower()
  39.  
  40. if user == 'q':
  41. break
  42.  
  43. if user not in options.keys():
  44. print(boldText + '\nВведите число от 1 до 3. \n0 или q - выход' + endColor)
  45. continue
  46.  
  47. choice = random.choice(list(options.keys()))
  48. print('\nВы:', boldText + options[user] + endColor)
  49. print('Рандом:', boldText + options[choice] + endColor)
  50.  
  51. if choice == user:
  52. time.sleep(0.1)
  53. print(boldText + '\nНичья :|' + endColor)
  54. win_u = win_u + 0
  55. win_c = win_c + 0
  56.  
  57. elif (user, choice) in (("1", "2"), ("3", "1"), ("2", "3")):
  58. time.sleep(0.1)
  59. print(boldText + '\nВы выиграли :)' + endColor)
  60. win_u = win_u + 1
  61.  
  62. else:
  63. time.sleep(0.1)
  64. print(boldText + '\nВы проиграли :(' + endColor)
  65. win_c = win_c + 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement