Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- def print_kart():
- for i in range(c):
- print(i, end=' ')
- print()
- for i in my_kart:
- print(i, end=' ')
- print()
- def first_step():
- print_kart()
- my_index = int(input())
- print(my_kart[my_index])
- temp_str = my_kart[my_index]
- temp_str_len = len(temp_str)
- if temp_str_len == 3:
- my_a = temp_str[0]
- my_b = temp_str[2]
- else:
- my_a = temp_str[0]
- my_b = temp_str[1]
- del my_kart[my_index]
- #
- return my_a, my_b
- def step_true(a, b, arr):
- temp_arr = []
- for i in arr:
- if a in i or b in i:
- temp_arr.append(i)
- return temp_arr
- def computer_step(temp_arr, my_a, my_b, temp_arr_my, computer_a, computer_b, temp_str):
- computer_a = ''
- computer_b = ''
- p = random.choice(temp_arr)
- p_len = len(p)
- if p_len == 3:
- computer_a = p[0]
- computer_b = p[2]
- else:
- computer_a = p[0]
- computer_b = p[1]
- print(p)
- computer_kart.remove(p)
- temp_arr = []
- temp_str = ''
- my_a = ''
- my_b = ''
- temp_arr_my = []
- return computer_a, computer_b
- def step_users(a, b, arr):
- temp_arr = []
- for i in arr:
- if a in i or b in i:
- temp_arr.append(i)
- if not temp_arr:
- return False
- else:
- return True
- def user_step(computer_a, computer_b, c):
- while True:
- print_kart()
- my_index = int(input())
- if my_index >= c:
- print('Введите правильное значение: ')
- # my_index = int(input())
- continue
- if computer_a in my_kart[my_index] or computer_b in my_kart[my_index]:
- print(my_kart[my_index])
- break
- else:
- print('Не мухлюйте!!!')
- temp_str = my_kart[my_index]
- temp_str_len = len(temp_str)
- if temp_str_len == 3:
- my_a = temp_str[0]
- my_b = temp_str[2]
- else:
- my_a = temp_str[0]
- my_b = temp_str[1]
- del my_kart[my_index]
- return my_a, my_b
- if __name__ == '__main__':
- my_kart = ['7p', '7b', '8k', '8c', '9p', '9b', '10k', '10c', 'Jp', 'Jb', 'Qk', 'Qc', 'Kp', 'Kb', 'Ak', 'Ac']
- computer_kart = ['7c', '7k', '8b', '8p', '9c', '9k', '10b', '10p', 'Jk', 'Jc', 'Qp', 'Qb', 'Kc', 'Kk', 'Ap', 'Ab']
- c = 16
- my_index = 0
- computer_index = 0
- temp_str = '' #00000
- temp_arr = [] #00000
- my_a = '' #00000
- my_b = '' #00000
- computer_a = ''
- computer_b = ''
- temp_arr_my = []
- win = True
- first_step()
- c -= 1
- while True:
- if not my_kart and not computer_kart:
- print('Ничья!')
- break
- temp_arr = step_true(my_a, my_b, computer_kart)
- win = step_users(my_a, my_b, temp_arr)
- if win == False:
- print('Компьютер проиграл!')
- break
- #computer_step(temp_arr, my_a, my_b, temp_arr_my, computer_a, computer_b, temp_str)
- computer_a, computer_b = computer_step(temp_arr, my_a, my_b, temp_arr_my, computer_a, computer_b, temp_str)
- temp_arr_my = step_true(computer_a, computer_b, my_kart)
- win = step_users(computer_a, computer_b, temp_arr_my)
- if win == False:
- print('Вы проиграли!')
- break
- #user_step(computer_a, computer_b, c)
- my_a, my_b = user_step(computer_a, computer_b, c)
- c -= 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement