Skip to content

Commit 3d526bf

Browse files
author
NerdOfCode
committed
Working on a tictactoe game
1 parent d565066 commit 3d526bf

1 file changed

Lines changed: 69 additions & 0 deletions

File tree

Python/tic-tac-toe.py

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
################################################3
2+
#In extremely early stages... There is no win checking
3+
###############################################4
4+
5+
import sys
6+
from pprint import pprint
7+
8+
def init():
9+
global row1
10+
global row2
11+
global row3
12+
row1 = [0, 0, 0]
13+
row2 = [0, 0, 0]
14+
row3 = [0, 0, 0]
15+
pprint(row1)
16+
pprint(row2)
17+
pprint(row3)
18+
19+
def current_game():
20+
pprint(row1)
21+
pprint(row2)
22+
pprint(row3)
23+
24+
def move():
25+
global count
26+
count = 0
27+
28+
if count == "0":
29+
turn = user
30+
count += 1
31+
first_play == False
32+
elif first_play == False or count != "0":
33+
turn = user2
34+
count == 1
35+
36+
new_move = input("Enter move(ex: 1,3): ")
37+
new_move = new_move.split(",")
38+
row = new_move[0]
39+
column = int(new_move[1])
40+
41+
#Gurantee no extra whitespaces
42+
row = row.replace(" ", "")
43+
int(row)
44+
45+
if row == "1":
46+
row1[column] = turn
47+
elif row == "2":
48+
row2[column] = turn
49+
elif row == "3":
50+
row3[column] = turn
51+
else:
52+
print("Unrecognized input...")
53+
54+
print("Only two player mode is currently available...")
55+
init()
56+
57+
print("Enter user one's character(ex: 'x'): ")
58+
user = input()
59+
60+
print("Enter user two's character(ex: o): ")
61+
user2 = input()
62+
63+
#For player switching technique
64+
first_play = True
65+
66+
while True:
67+
move()
68+
current_game()
69+

0 commit comments

Comments
 (0)