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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -2
app.py CHANGED
@@ -91,7 +91,7 @@ def play_tic_tac_toe(evt: gr.SelectData, board, game_over):
91
  # print(f"Index = {evt.index}")
92
 
93
  # 確認 evt 是否有效
94
- if not evt or not evt.index:
95
  return draw_board(board), "Invalid move! Please select a valid square.", False
96
 
97
  if game_over:
@@ -126,7 +126,7 @@ with gr.Blocks() as app:
126
  gr.Markdown("# Tic-Tac-Toe AI Game")
127
 
128
  board = initialize_board()
129
- board_image = gr.Image(value=draw_board(board), interactive=False, label="Board", show_download_button=False, show_fullscreen_button=False)
130
  message_display = gr.Textbox(label="Game Status", value="Game in progress")
131
  reset_button = gr.Button("Reset Game")
132
  board_state = gr.State(board)
 
91
  # print(f"Index = {evt.index}")
92
 
93
  # 確認 evt 是否有效
94
+ if not evt or not hasattr(evt, "index") or not evt.index:
95
  return draw_board(board), "Invalid move! Please select a valid square.", False
96
 
97
  if game_over:
 
126
  gr.Markdown("# Tic-Tac-Toe AI Game")
127
 
128
  board = initialize_board()
129
+ board_image = gr.Image(value=draw_board(board), interactive=True, label="Board", show_download_button=False, show_fullscreen_button=False)
130
  message_display = gr.Textbox(label="Game Status", value="Game in progress")
131
  reset_button = gr.Button("Reset Game")
132
  board_state = gr.State(board)