Advertisement
Guest User

Untitled

a guest
Mar 26th, 2019
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.50 KB | None | 0 0
  1. import random
  2.  
  3. def print_kart():
  4. for i in range(c):
  5. print(i, end=' ')
  6. print()
  7. for i in my_kart:
  8. print(i, end=' ')
  9. print()
  10.  
  11. def first_step():
  12. print_kart()
  13. my_index = int(input())
  14. print(my_kart[my_index])
  15. temp_str = my_kart[my_index]
  16. temp_str_len = len(temp_str)
  17. if temp_str_len == 3:
  18. my_a = temp_str[0]
  19. my_b = temp_str[2]
  20. else:
  21. my_a = temp_str[0]
  22. my_b = temp_str[1]
  23. del my_kart[my_index]
  24. #
  25. return my_a, my_b
  26.  
  27. def step_true(a, b, arr):
  28. temp_arr = []
  29. for i in arr:
  30. if a in i or b in i:
  31. temp_arr.append(i)
  32. return temp_arr
  33.  
  34. def computer_step(temp_arr, my_a, my_b, temp_arr_my, computer_a, computer_b, temp_str):
  35. computer_a = ''
  36. computer_b = ''
  37. p = random.choice(temp_arr)
  38. p_len = len(p)
  39. if p_len == 3:
  40. computer_a = p[0]
  41. computer_b = p[2]
  42. else:
  43. computer_a = p[0]
  44. computer_b = p[1]
  45. print(p)
  46. computer_kart.remove(p)
  47. temp_arr = []
  48. temp_str = ''
  49. my_a = ''
  50. my_b = ''
  51. temp_arr_my = []
  52. return computer_a, computer_b
  53.  
  54. def step_users(a, b, arr):
  55. temp_arr = []
  56. for i in arr:
  57. if a in i or b in i:
  58. temp_arr.append(i)
  59. if not temp_arr:
  60. return False
  61. else:
  62. return True
  63.  
  64. def user_step(computer_a, computer_b, c):
  65. while True:
  66. print_kart()
  67. my_index = int(input())
  68. if my_index >= c:
  69. print('Введите правильное значение: ')
  70. # my_index = int(input())
  71. continue
  72. if computer_a in my_kart[my_index] or computer_b in my_kart[my_index]:
  73. print(my_kart[my_index])
  74. break
  75. else:
  76. print('Не мухлюйте!!!')
  77. temp_str = my_kart[my_index]
  78. temp_str_len = len(temp_str)
  79. if temp_str_len == 3:
  80. my_a = temp_str[0]
  81. my_b = temp_str[2]
  82. else:
  83. my_a = temp_str[0]
  84. my_b = temp_str[1]
  85. del my_kart[my_index]
  86. return my_a, my_b
  87.  
  88. if __name__ == '__main__':
  89. my_kart = ['7p', '7b', '8k', '8c', '9p', '9b', '10k', '10c', 'Jp', 'Jb', 'Qk', 'Qc', 'Kp', 'Kb', 'Ak', 'Ac']
  90. computer_kart = ['7c', '7k', '8b', '8p', '9c', '9k', '10b', '10p', 'Jk', 'Jc', 'Qp', 'Qb', 'Kc', 'Kk', 'Ap', 'Ab']
  91. c = 16
  92. my_index = 0
  93. computer_index = 0
  94. temp_str = '' #00000
  95. temp_arr = [] #00000
  96. my_a = '' #00000
  97. my_b = '' #00000
  98. computer_a = ''
  99. computer_b = ''
  100. temp_arr_my = []
  101. win = True
  102.  
  103. first_step()
  104. c -= 1
  105. while True:
  106. if not my_kart and not computer_kart:
  107. print('Ничья!')
  108. break
  109. temp_arr = step_true(my_a, my_b, computer_kart)
  110. win = step_users(my_a, my_b, temp_arr)
  111. if win == False:
  112. print('Компьютер проиграл!')
  113. break
  114. #computer_step(temp_arr, my_a, my_b, temp_arr_my, computer_a, computer_b, temp_str)
  115. computer_a, computer_b = computer_step(temp_arr, my_a, my_b, temp_arr_my, computer_a, computer_b, temp_str)
  116. temp_arr_my = step_true(computer_a, computer_b, my_kart)
  117. win = step_users(computer_a, computer_b, temp_arr_my)
  118. if win == False:
  119. print('Вы проиграли!')
  120. break
  121. #user_step(computer_a, computer_b, c)
  122. my_a, my_b = user_step(computer_a, computer_b, c)
  123. c -= 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement