- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
board = [" ", " ", " "], \
[" ", " ", " "], \
[" ", " ", " "]
i = 1
win = True
place_chek = True
def show():
print("---------")
print("|" + board[0][0] + " " + board[0][1] + " " + board[0][2] + "|")
print("|" + board[1][0] + " " + board[1][1] + " " + board[1][2] + "|")
print("|" + board[2][0] + " " + board[2][1] + " " + board[2][2] + "|")
print("---------")
def move(i):
if i % 2 == 0:
return "X"
else:
return "0"
def choise(x, y):
board[x][y] = move(i)
def repeat(x, y):
global i
global place_chek
if board[x][y] == "0":
print()
print("Choose another location")
print()
place_chek = False
elif board[x][y] == "X":
print()
print("Choose another location")
print()
place_chek = False
elif board[x][y] == " ":
i = i + 1
place_chek = True
def win_check():
global win
if board[0][0] == board[0][1] == board[0][2] == "X" or \
board[1][0] == board[1][1] == board[1][2] == "X" or \
board[2][0] == board[2][1] == board[2][2] == "X" or \
board[0][0] == board[1][0] == board[2][0] == "X" or \
board[0][1] == board[1][1] == board[2][1] == "X" or \
board[0][2] == board[1][2] == board[2][2] == "X" or \
board[0][0] == board[1][1] == board[2][2] == "X" or \
board[0][2] == board[1][1] == board[2][0] == "X":
print("X won")
win = False
elif board[0][0] == board[0][1] == board[0][2] == "0" or \
board[1][0] == board[1][1] == board[1][2] == "0" or \
board[2][0] == board[2][1] == board[2][2] == "0" or \
board[0][0] == board[1][0] == board[2][0] == "0" or \
board[0][1] == board[1][1] == board[2][1] == "0" or \
board[0][2] == board[1][2] == board[2][2] == "0" or \
board[0][0] == board[1][1] == board[2][2] == "0" or \
board[0][2] == board[1][1] == board[2][0] == "0":
print("0 won")
win = False
show() # first time show
while win:
x, y = input("Enter the coordinates: ").split()
repeat(int(x) - 1, int(y) - 1)
if place_chek:
choise(int(x) - 1, int(y) - 1)
show()
win_check()
Крестики нолики на питоне. Самый большой позор это способ определение победы, не смог ничего придумать и сделал такой позор