-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfull code
102 lines (97 loc) · 2.85 KB
/
full code
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
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import random
import array as arr
from array import *
import sys
def fullboard():
for r in table:
for c in r:
if(table[s][p]=="x" or table[s][p]=="o" ): # map(int, input().split())
print("it is a tie")
else:
return
def askinput():
s,p=map(int,input("enter the coordinates").split())
if (n==1):
table[s][p]="x"
for r in table:
for c in r:
print(c,end = " ")
print()
elif (n==2):
table[s][p]="o"
for r in table:
for c in r:
print(c,end = " ")
print()
def checking():
if (table[0][0]=="x" and table[0][1]=="x" and table[0][2]=="x"):
print("player 1 won")
exit()
elif (table[1][0]=="x" and table[1][1]=="x" and table[1][2]=="x"):
print("player 1 won")
exit()
elif (table[2][0]=="x" and table[2][1]=="x" and table[2][2]=="x"):
print("player 1 won")
exit()
elif (table[0][0]=="x" and table[1][0]=="x" and table[2][0]=="x"):
print("player 1 won")
exit()
elif (table[0][1]=="x" and table[1][1]=="x" and table[2][1]=="x"):
print("player 1 won")
exit()
elif (table[0][2]=="x" and table[1][2]=="x" and table[2][2]=="x"):
print("player 1 won")
exit()
elif (table[0][0]=="x" and table[1][1]=="x" and table[2][2]=="x"):
print("player 1 won")
exit()
elif (table[0][2]=="x" and table[1][1]=="x" and table[2][0]=="x"):
print("player 1 won")
exit()
elif (table[0][0]=="o" and table[0][1]=="o" and table[0][2]=="o"): #2nd player winning
print("player 2 won")
exit()
elif (table[1][0]=="o" and table[1][1]=="o" and table[1][2]=="o"):
print("player 2 won")
exit()
elif (table[2][0]=="o" and table[2][1]=="o" and table[2][2]=="o"):
print("player 2 won")
exit()
elif (table[0][0]=="o" and table[1][0]=="o" and table[2][0]=="o"):
print("player 2 won")
exit()
elif (table[0][1]=="o" and table[1][1]=="o" and table[2][1]=="o"):
print("player 2 won")
exit()
elif (table[0][2]=="o" and table[1][2]=="o" and table[2][2]=="o"):
print("player 2 won")
exit()
elif (table[0][0]=="o" and table[1][1]=="o" and table[2][2]=="o"):
print("player 2 won")
exit()
elif (table[0][2]=="o" and table[1][1]=="o" and table[2][0]=="o"):
print("player 2 won")
exit()
else:
return
table=[["-","-","-"],["-","-","-"],["-","-","-"]]
for r in table:
for c in r:
print(c,end = " ")
print()
n=random.randint(1, 2)
print("player",n,"enter the coordinates")
askinput()
checking()
for i in range(0,8):
if(n==1):
n=2
print("its player 2's turn")
askinput()
checking()
elif(n==2):
n=1
print("its player 1's turn")
askinput()
checking()
print("it is a tie")