Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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=
|
| 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)
|