Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -97,7 +97,12 @@ def play_tic_tac_toe(evt: gr.SelectData, board, game_over):
|
|
| 97 |
if game_over:
|
| 98 |
return draw_board(board), "Game already finished! Please reset to play again.", True
|
| 99 |
|
| 100 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 101 |
if board[r][c] != "":
|
| 102 |
return draw_board(board), "Invalid move! This spot is already taken. Please select an empty square.", False
|
| 103 |
|
|
|
|
| 97 |
if game_over:
|
| 98 |
return draw_board(board), "Game already finished! Please reset to play again.", True
|
| 99 |
|
| 100 |
+
try:
|
| 101 |
+
r, c = evt.index[1] // 100, evt.index[0] // 100
|
| 102 |
+
except (TypeError, IndexError):
|
| 103 |
+
print(evt.index)
|
| 104 |
+
return draw_board(board), "Invalid selection! Please try again.", False
|
| 105 |
+
|
| 106 |
if board[r][c] != "":
|
| 107 |
return draw_board(board), "Invalid move! This spot is already taken. Please select an empty square.", False
|
| 108 |
|