From 0694a20c794180c04e3f8402c0bbf74914b3d3e1 Mon Sep 17 00:00:00 2001 From: Rh17S15 Date: Mon, 22 Sep 2025 19:43:52 +0200 Subject: [PATCH] implemented right player check after loading savestate --- tictactoe.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tictactoe.py b/tictactoe.py index 56ecd1e..4c88983 100644 --- a/tictactoe.py +++ b/tictactoe.py @@ -115,10 +115,19 @@ if os.path.isfile('./savestate.py'): if inp == "y": field = save + spacecount = 0 + for j in range(0, len(field)): + for k in range(0, len(field)): + if field[j][k] == " ": + spacecount += 1 + # (player1 = True) if spacecount % 2 == 1 else (player1 = False) + if spacecount % 2 == 0: + player1 = False + break inp = input("That was not a valid input. Type y/n if you want to continue or not: ") printer() -print("Player 1 (X) will start playing.") +print(f"Player {1 if player1 else 2} ({player1_char if player1 else player2_char}) will start playing.") turn()