Format
There really is no hope of making this code even half-way decent without spending the time to rewrite them all properly. Don't want to do any of that
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
#TICTACTOE V 1.0
|
||||
# TICTACTOE V 1.0
|
||||
|
||||
import time
|
||||
|
||||
#Variables5
|
||||
# Variables5
|
||||
global bd
|
||||
bd = [[0,0,0],[0,0,0],[0,0,0]]
|
||||
bd = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
|
||||
global filled_fields
|
||||
filled_fields = 0
|
||||
global player
|
||||
@@ -15,8 +15,8 @@ global play
|
||||
play = 1
|
||||
|
||||
|
||||
#FUNCTIONS
|
||||
#--------------------
|
||||
# FUNCTIONS
|
||||
# --------------------
|
||||
def inputs():
|
||||
global playershow
|
||||
global bd
|
||||
@@ -28,17 +28,22 @@ def inputs():
|
||||
z = int(zl) - 1
|
||||
s = ord(sp) - 65
|
||||
if bd[z][s] > 0:
|
||||
print("""
|
||||
print(
|
||||
"""
|
||||
THAT FIELD IS ALREADY TAKEN, CHOOSE DIFFERENT ONE!
|
||||
""")
|
||||
"""
|
||||
)
|
||||
else:
|
||||
inputremap(z,s)
|
||||
inputremap(z, s)
|
||||
else:
|
||||
print("""
|
||||
print(
|
||||
"""
|
||||
PLEASE TYPE IN A LEGIT COORDINATE:
|
||||
FORM: Coordinate Y Coordinate X --> Ex. A1/A2
|
||||
""")
|
||||
|
||||
"""
|
||||
)
|
||||
|
||||
|
||||
def inputremap(z, s):
|
||||
global player
|
||||
global playershow
|
||||
@@ -51,9 +56,9 @@ def inputremap(z, s):
|
||||
playershow = 1
|
||||
player = 1
|
||||
global filled_fields
|
||||
filled_fields += 1
|
||||
filled_fields += 1
|
||||
full(filled_fields)
|
||||
|
||||
|
||||
|
||||
def winning():
|
||||
global play
|
||||
@@ -63,9 +68,11 @@ def winning():
|
||||
global go
|
||||
go = 1
|
||||
count = 0
|
||||
print("""
|
||||
print(
|
||||
"""
|
||||
checking for winner
|
||||
""")
|
||||
"""
|
||||
)
|
||||
while go == 1:
|
||||
if sum(bd[x]) == 3:
|
||||
go = 0
|
||||
@@ -88,11 +95,14 @@ checking for winner
|
||||
y += 1
|
||||
if count >= 2:
|
||||
go = 0
|
||||
print("""no winner yet
|
||||
""")
|
||||
print(
|
||||
"""no winner yet
|
||||
"""
|
||||
)
|
||||
else:
|
||||
count += 1
|
||||
|
||||
|
||||
def full(filled_field):
|
||||
global bd
|
||||
if filled_field == 9:
|
||||
@@ -103,7 +113,7 @@ def full(filled_field):
|
||||
winning()
|
||||
|
||||
|
||||
#BOARD DRAWING
|
||||
# BOARD DRAWING
|
||||
def board_draw():
|
||||
print("\n")
|
||||
xx = 0
|
||||
@@ -112,17 +122,17 @@ def board_draw():
|
||||
while yy < 3:
|
||||
while xx < 3:
|
||||
if bd[xx][yy] == 0:
|
||||
print(" ", end = " ")
|
||||
print(" ", end=" ")
|
||||
elif bd[xx][yy] == 1:
|
||||
print(" X ", end = " ")
|
||||
print(" X ", end=" ")
|
||||
elif bd[xx][yy] == 7:
|
||||
print(" O ", end = " ")
|
||||
print(" O ", end=" ")
|
||||
else:
|
||||
print(""" CRITICAL ERROR""")
|
||||
if xx < 2:
|
||||
print("|", end = " ")
|
||||
print("|", end=" ")
|
||||
else:
|
||||
print(" ", end = " ")
|
||||
print(" ", end=" ")
|
||||
xx += 1
|
||||
print(" ")
|
||||
xx = 0
|
||||
@@ -131,14 +141,13 @@ def board_draw():
|
||||
else:
|
||||
print(" ")
|
||||
yy += 1
|
||||
|
||||
|
||||
|
||||
|
||||
#MAIN CYCLE
|
||||
print(50*("\n"))
|
||||
|
||||
print("""
|
||||
# MAIN CYCLE
|
||||
print(50 * ("\n"))
|
||||
|
||||
print(
|
||||
"""
|
||||
|
||||
------------------------------------------------------
|
||||
|
||||
@@ -153,35 +162,42 @@ print("""
|
||||
|
||||
|
||||
by Janis Hutz
|
||||
""")
|
||||
"""
|
||||
)
|
||||
time.sleep(2)
|
||||
print("starting...")
|
||||
time.sleep(3)
|
||||
print("\n\n\n")
|
||||
goahead = 1
|
||||
print("""
|
||||
print(
|
||||
"""
|
||||
| |
|
||||
----------------
|
||||
| |
|
||||
----------------
|
||||
| |
|
||||
""")
|
||||
"""
|
||||
)
|
||||
while goahead == 1:
|
||||
while play == 1:
|
||||
inputs()
|
||||
board_draw()
|
||||
time.sleep(2)
|
||||
print("""
|
||||
print(
|
||||
"""
|
||||
REPLAY?
|
||||
""")
|
||||
"""
|
||||
)
|
||||
i = input("""Choose: (y/n)""")
|
||||
if i == "y":
|
||||
goahead = 1
|
||||
play = 1
|
||||
else:
|
||||
goahead = 0
|
||||
print("""
|
||||
print(
|
||||
"""
|
||||
|
||||
GOOD BYE!
|
||||
|
||||
""")
|
||||
"""
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user