forked from ankitrathore01/FIRST_EFFORT
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AR_VS_USERS.py
124 lines (121 loc) · 3.18 KB
/
AR_VS_USERS.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
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
from ar_fn_1 import *
from ar_fn_2 import *
a=['1','2','3']
b=['4','5','6']
c=['7','8','9']
i=0
print a,'\n',b,'\n',c,'\n'
turn=input("wanna play first then press 0")
if turn!=0:
i=1
turn=0
according_me=[4,0,2,6,8,1,3,5,7]
while True:
if i%2==0:
print "user turn"
x=input("enter positon ")
if x not in range(1,10):
print "oops try another no "
continue
if x<=3:
if a[x-1]=='x' or a[x-1]=='o':
print "oops try another no "
continue
a[x-1]='x'
elif x<=6:
if b[x-4]=='x' or b[x-4]=='o':
print "oops try another no "
continue
b[x-4]='x'
elif x<=9:
if c[x-7]=='x' or c[x-7]=='o':
print "oops try another no "
continue
c[x-7]='x'
print a,'\n',b,'\n',c,'\n'
i+=1
turn+=1
if check_c(a,b,c) or check_r(a,b,c) or check_d(a,b,c): #checking for winner
break
else:
print "cumputer's turn\n"
p=check_comp_r(a,b,c)
q=check_comp_c(a,b,c)
r=check_comp_d(a,b,c)
s=check_special_corner(a,b,c)
t=check_user_r(a,b,c)
u=check_user_c(a,b,c)
v=check_user_d(a,b,c)
if p!=-1:
if p<3:
a[p]='o'
elif p<6:
p-=3
b[p]='o'
else:
p-=6
c[p]='o'
elif q!=-1:
if q<3:
a[q]='o'
elif q<6:
q-=3
b[q]='o'
else:
q-=6
c[q]='o'
elif r!=-1:
if r<3:
a[r]='o'
elif r<6:
r-=3
b[r]='o'
else:
r-=6
c[r]='o'
elif t!=-1:
if t<3:
a[t]='o'
elif t<6:
t-=3
b[t]='o'
else:
t-=6
c[t]='o'
elif u!=-1:
if u<3:
a[u]='o'
elif u<6:
u-=3
b[u]='o'
else:
u-=6
c[u]='o'
elif v!=-1:
if v<3:
a[v]='o'
elif v<6:
v-=3
b[v]='o'
else:
v-=6
c[v]='o'
elif s!=-1:
if s<3:
a[s]='o'
elif s<6:
s-=3
b[s]='o'
else:
s-=6
c[s]='o'
else:
check_according_me(a,b,c,according_me)
print a,'\n',b,'\n',c,'\n'
i+=1
turn+=1
if check_c(a,b,c) or check_r(a,b,c) or check_d(a,b,c):
break
if turn==9:
print "match is draw"
break