|
|
@ -11,17 +11,15 @@ def print_board(): # Funkce vytiskne pole v momentálním stavu hry
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def player(x_or_y): # Input hráče, ve stylu X_Y souřadnice, mělo by mít 3 charaktery a to čísla od 1 do 3
|
|
|
|
def player(x_or_y): # Input hráče, ve stylu X_Y souřadnice, mělo by mít 3 charaktery a to čísla od 1 do 3
|
|
|
|
|
|
|
|
repeater = True # Pokud to zachytí chybu/obsazené pole, loop poběží znovu
|
|
|
|
|
|
|
|
while repeater:
|
|
|
|
|
|
|
|
try:
|
|
|
|
player_move = input("Zvol si řadu a sloupec ")
|
|
|
|
player_move = input("Zvol si řadu a sloupec ")
|
|
|
|
while 3 != len(player_move): # Zda-li má hráč 3 charaktery
|
|
|
|
if 3 != len(player_move) or board[int(player_move[0]) - 1][int(player_move[2]) - 1] != " ": # Zda-li má hráč 3 charaktery
|
|
|
|
print("špatný počet znaků")
|
|
|
|
print("Možnost nelze vybrat")
|
|
|
|
player_move = input("Zvol si řadu a sloupec ")
|
|
|
|
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
try:
|
|
|
|
repeater = False
|
|
|
|
if board[int(player_move[0]) - 1][int(player_move[2]) - 1] == " ": # Funguje jen pokud je pole prázdné
|
|
|
|
|
|
|
|
board[int(player_move[0]) - 1][int(player_move[2]) - 1] = x_or_y
|
|
|
|
board[int(player_move[0]) - 1][int(player_move[2]) - 1] = x_or_y
|
|
|
|
else:
|
|
|
|
|
|
|
|
print("Možnost nelze vybrat")
|
|
|
|
|
|
|
|
player_move = input("Zvol si řadu a sloupec ")
|
|
|
|
|
|
|
|
except:
|
|
|
|
except:
|
|
|
|
print("Možnost nelze vybrat")
|
|
|
|
print("Možnost nelze vybrat")
|
|
|
|
player_move = input("Zvol si řadu a sloupec ")
|
|
|
|
player_move = input("Zvol si řadu a sloupec ")
|
|
|
@ -35,12 +33,10 @@ def check_win(): # Kontrola, jestli některý z hráčů nevyhrál kolo
|
|
|
|
if board[0][i] in player_marks and board[1][i] in player_marks and board[2][i] in player_marks:
|
|
|
|
if board[0][i] in player_marks and board[1][i] in player_marks and board[2][i] in player_marks:
|
|
|
|
print(f"Vyhrál hráč {board[0][i]}")
|
|
|
|
print(f"Vyhrál hráč {board[0][i]}")
|
|
|
|
return True
|
|
|
|
return True
|
|
|
|
if board[0][0] in player_marks and board[1][1] in player_marks and board[2][
|
|
|
|
if board[0][0] in player_marks and board[1][1] in player_marks and board[2][2] in player_marks: # Kontrola diagonaly
|
|
|
|
2] in player_marks: # Kontrola diagonaly
|
|
|
|
|
|
|
|
print(f"Vyhrál hráč {board[0][i]}") # z prava do leva
|
|
|
|
print(f"Vyhrál hráč {board[0][i]}") # z prava do leva
|
|
|
|
return True
|
|
|
|
return True
|
|
|
|
elif board[0][2] in player_marks and board[1][1] in player_marks and board[2][
|
|
|
|
elif board[0][2] in player_marks and board[1][1] in player_marks and board[2][0] in player_marks: # Kontrola diagonaly
|
|
|
|
0] in player_marks: # Kontrola diagonaly
|
|
|
|
|
|
|
|
print(f"Vyhrál hráč {board[0][i]}") # z leva do prava
|
|
|
|
print(f"Vyhrál hráč {board[0][i]}") # z leva do prava
|
|
|
|
return True
|
|
|
|
return True
|
|
|
|
return False
|
|
|
|
return False
|
|
|
|