Start of implementation of check_win
This commit is contained in:
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
.idea
|
||||||
|
|
||||||
18
tictactoe.py
18
tictactoe.py
@@ -29,7 +29,7 @@ def turn(): # function that checks whose turn it is and where they can place th
|
|||||||
while True:
|
while True:
|
||||||
next_move_x = int(input(
|
next_move_x = int(input(
|
||||||
f"Player {1 if player1 else 2}, please choose the x (horizontal) coordinates of your next move: "))
|
f"Player {1 if player1 else 2}, please choose the x (horizontal) coordinates of your next move: "))
|
||||||
if next_move_x in list(range(3)): # TODO Implement check to see if move is legal
|
if next_move_x in list(range(3)):
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
print("Please be sure to input a valid number (0-2). \nPlease try Again.")
|
print("Please be sure to input a valid number (0-2). \nPlease try Again.")
|
||||||
@@ -37,7 +37,7 @@ def turn(): # function that checks whose turn it is and where they can place th
|
|||||||
while True:
|
while True:
|
||||||
next_move_y = int(input(
|
next_move_y = int(input(
|
||||||
f"Player {1 if player1 else 2}, please choose the y (vertical) coordinates of your next move: "))
|
f"Player {1 if player1 else 2}, please choose the y (vertical) coordinates of your next move: "))
|
||||||
if next_move_y in list(range(3)): # TODO Implement check to see if move is legal
|
if next_move_y in list(range(3)):
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
print("Please be sure to input a valid number (0-2). \nPlease try Again.")
|
print("Please be sure to input a valid number (0-2). \nPlease try Again.")
|
||||||
@@ -47,13 +47,21 @@ def turn(): # function that checks whose turn it is and where they can place th
|
|||||||
return check_move(next_move_x, next_move_y)
|
return check_move(next_move_x, next_move_y)
|
||||||
|
|
||||||
|
|
||||||
|
def check_win():
|
||||||
|
# a
|
||||||
|
for j in range(0, len(field)):
|
||||||
|
for k in range(0, len(field)):
|
||||||
|
if j == k:
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
def do_move(x, y):
|
def do_move(x, y):
|
||||||
global player1 # Tells do_move to look for the global var player1
|
global player1 # Tells do_move to look for the global var player1
|
||||||
field[y][x] = (player1_char if player1 else player2_char)
|
field[y][x] = (player1_char if player1 else player2_char)
|
||||||
printer()
|
printer()
|
||||||
# TODO implement win checker here
|
if not check_win(): # TODO implement win checker here
|
||||||
player1 = not player1
|
player1 = not player1
|
||||||
turn()
|
turn()
|
||||||
|
|
||||||
|
|
||||||
def check_move(x, y):
|
def check_move(x, y):
|
||||||
|
|||||||
Reference in New Issue
Block a user