|
|
@ -1,4 +1,5 @@
|
|
|
|
board = [[" ", " ", " "],[" ", " ", " "],[" ", " ", " "]]
|
|
|
|
board = [[" ", " ", " "],[" ", " ", " "],[" ", " ", " "]]
|
|
|
|
|
|
|
|
player_marks = ["x", "y"]
|
|
|
|
|
|
|
|
|
|
|
|
def print_board(board):
|
|
|
|
def print_board(board):
|
|
|
|
print(f""" 1 2 3
|
|
|
|
print(f""" 1 2 3
|
|
|
@ -7,11 +8,14 @@ def print_board(board):
|
|
|
|
3 |{board[2][0]}|{board[2][1]}|{board[2][2]}|
|
|
|
|
3 |{board[2][0]}|{board[2][1]}|{board[2][2]}|
|
|
|
|
""")
|
|
|
|
""")
|
|
|
|
|
|
|
|
|
|
|
|
def player(board):
|
|
|
|
def player(x_or_y):
|
|
|
|
player_move = input("Zvol si radu a sloupec ")
|
|
|
|
player_move = input("Zvol si radu a sloupec ")
|
|
|
|
|
|
|
|
while length(player_move) != 3:
|
|
|
|
|
|
|
|
print("spatny pocet znaku")
|
|
|
|
|
|
|
|
else:
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
if board[int(player_move[0])][int(player_move[0])] == " ":
|
|
|
|
if board[int(player_move[0]) - 1][int(player_move[2]) - 1] == " ":
|
|
|
|
pass
|
|
|
|
board[int(player_move[0]) - 1][int(player_move[2]) - 1] = x_or_y
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
print("Moznost nelze vybrat")
|
|
|
|
print("Moznost nelze vybrat")
|
|
|
|
player_move = input("Zvol si radu a sloupec ")
|
|
|
|
player_move = input("Zvol si radu a sloupec ")
|
|
|
@ -19,5 +23,19 @@ def player(board):
|
|
|
|
print("Moznost nelze vybrat")
|
|
|
|
print("Moznost nelze vybrat")
|
|
|
|
player_move = input("Zvol si radu a sloupec ")
|
|
|
|
player_move = input("Zvol si radu a sloupec ")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def check_win():
|
|
|
|
|
|
|
|
for i in range(3): #Kontrola sloupcu
|
|
|
|
|
|
|
|
if board[i][0] in player_marks and board[i][1] in player_marks and board[i][2] in player_marks:
|
|
|
|
|
|
|
|
print(f"Vyhral hrac {board[i][0]}")
|
|
|
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
for i in range(3): # Kontrola rad
|
|
|
|
|
|
|
|
if board[0][i] in player_marks and board[1][i] in player_marks and board[2][i] in player_marks:
|
|
|
|
|
|
|
|
print(f"Vyhral hrac {board[0][i]}")
|
|
|
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
if
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
player()
|
|
|
|
x_or_y = "x"
|
|
|
|
|
|
|
|
player(x_or_y)
|
|
|
|
|
|
|
|
print_board(board)
|
|
|
|
|
|
|
|
check_win()
|
|
|
|