-
Notifications
You must be signed in to change notification settings - Fork 67
/
game.py
75 lines (69 loc) · 2.55 KB
/
game.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
i=input('Wanna play tic tac toe \n yes or no:')
if i=='yes':
print('so lets go!!')
v=input('which character do u want,x or o?')
n=v.lower()
if n=='x':
print('player1=',n)
print('player2=o')
elif n=='o':
print('player1=o')
print('player2=x')
elif i=='no':
print('thank u')
if i=='yes':
Win = 1
Draw = -1
Running = 0
Stop = 1
board=['-','-','-',
'-','-','-',
'-','-','-']
print(board[0],'I',board[1],'I',board[2])
print('-----------')
print(board[3],'I',board[4],'I',board[5])
print('-----------')
print(board[6],'I',board[7],'I',board[8])
def CheckPosition(v):
if(board[v] == ' '):
return True
else:
return False
k=0
while k<9:
i= int(input('player 1:select a spot:'))
if v=='x':
if board[i]!='x' and board[i]!='o':
board[i]=v
print(board[0],'I',board[1],'I',board[2])
print('-----------')
print(board[3],'I',board[4],'I',board[5])
print('-----------')
print(board[6],'I',board[7],'I',board[8])
j=int(input('player2-select a spot:'))
if board[j]!='x' and board[j]!='o':
board[j]='o'
print(board[0],'I',board[1],'I',board[2])
print('-----------')
print(board[3],'I',board[4],'I',board[5])
print('-----------')
print(board[6],'I',board[7],'I',board[8])
k=k+1
else:
if v=='o':
if board[i]!='x' and board[i]!='o':
board[i]=v
print(board[0],'I',board[1],'I',board[2])
print('-----------')
print(board[3],'I',board[4],'I',board[5])
print('-----------')
print(board[6],'I',board[7],'I',board[8])
j=int(input('player2-select a spot'))
if board[j]!='x' and board[j]!='o':
board[j]='x'
print(board[0],'I',board[1],'I',board[2])
print('-----------')
print(board[3],'I',board[4],'I',board[5])
print('-----------')
print(board[6],'I',board[7],'I',board[8])
k=k+1