nolik = '\033[92mO\033[0m'
krestik = '\033[91mX\033[0m'
play_1 = '\033[92mИгрок № 1\033[0m'
play_2 = '\033[91mИгрок № 2\033[0m'
Player_1 = [nolik,0,play_1]
Player_2 = [krestik,0,play_2]
Players = [Player_1,Player_2]
pole_nums = {'num_1':1,'num_2':2,'num_3':3,'num_4':4,
'num_5':5,'num_6':6,'num_7':7,'num_8':8,'num_9':9}
list = []
def pole ():
print ("","","-------------------","\n"," | ",pole_nums['num_1']," | ",pole_nums['num_2']," | ",pole_nums['num_3'],
" | ","\n"," -------------------","\n"," | ",pole_nums['num_4']," | ",pole_nums['num_5'],
" | ",pole_nums['num_6']," | ","\n"," -------------------","\n"," | ",pole_nums['num_7']," | ",
pole_nums['num_8']," | ",pole_nums['num_9']," | ","\n"," -------------------")
def Player_input():
while True:
try:
Pl_input = int(input("Укажите клетку c цифрой: "))
if Pl_input > 9:
pole ()
print ("Введите значение от 1 до 9")
elif Pl_input < 1:
pole ()
print ("Введите значение от 1 до 9")
else:
return Pl_input
except ValueError:
pole ()
print ("Введите целое числовое значение")
def proverka():
while True:
num = Player_input()
if num not in list:
return num
else:
pole ()
print('Эта клетка уже занята!')
def game():
for pl in Players:
print(pl[2],"Вам необходимо указать клетку c цифрой от 1 до 9","\n",
"где будет стоять Ваш",pl[0])
pole ()
num = proverka()
list.append(num)
for n in pole_nums:
if pole_nums[n] == num:
pole_nums[n] = pl[0]
pole ()
win(pl)
def win (pl):
if pl[0] == ((pole_nums['num_1']) and (pole_nums['num_2']) and (pole_nums['num_3']))or((pole_nums['num_4'])
and (pole_nums['num_5']) and (pole_nums['num_6']))or ((pole_nums['num_7'])
and (pole_nums['num_8']) and (pole_nums['num_9']))or ((pole_nums['num_1'])
and (pole_nums['num_4']) and (pole_nums['num_7']))or ((pole_nums['num_2'])
and (pole_nums['num_5']) and (pole_nums['num_8']))or ((pole_nums['num_3'])
and (pole_nums['num_6']) and (pole_nums['num_9']))or ((pole_nums['num_1'])
and (pole_nums['num_5']) and (pole_nums['num_9']))or ((pole_nums['num_3'])
and (pole_nums['num_5']) and (pole_nums['num_7'])):
print ('Поздравляем победил ',pl[2])
winner (pl)
def winner (pl):
pl[1] = pl[1]+1
print(pl[2]," победил в ",pl[1]," раз!")
print("~"*20,"ТАБЛИЦА РЕКОРДОВ","~"*20,"\n","\n",play_1," победил ",
Player_1[1]," раз","\n","\n",play_2," победил ",
Player_2[1]," раз","\n","\n")
while True:
game()