-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck.py
49 lines (40 loc) · 1.17 KB
/
check.py
1
2
3
4
5
6
7
8
9
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
def check(b):
#print countt
# Checking for Rows for X or O victory.
for row in range(3):
if (b[row][0]==b[row][1]) &(b[row][1]==b[row][2]):
if (b[row][0]=="X"):
return +10;
elif (b[row][0]=="O"):
return -10;
# Checking for Columns for X or O victory.
for col in range(3):
if (b[0][col]==b[1][col]) &(b[1][col]==b[2][col]):
if (b[0][col]=="X"):
return +10;
elif (b[0][col]=="O"):
return -10;
#Checking for Diagonals for X or O victory.
if (b[0][0]==b[1][1])&(b[1][1]==b[2][2]):
if (b[0][0]=="X"):
return +10;
elif (b[0][0]=="O"):
return -10;
if (b[0][2]==b[1][1])&(b[1][1]==b[2][0]):
if (b[0][2]=="X"):
return +10;
elif (b[0][2]=="O"):
return -10;
for i in range(3):
for j in range(3):
if b[i][j]==" ":
return 0
# Else if none of them have won then return 0
return 2;
def print2(m):
i=0
print (" ",0," ",1," ",2)
for x in m:
print (i,x)
i+=1
print ("\n")