aicodingfun commited on
Commit
c8980c5
·
verified ·
1 Parent(s): b195393

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -1
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
- r, c = evt.index[1] // 100, evt.index[0] // 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