Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -87,9 +87,6 @@ def minimax(board, depth, is_maximizing):
|
|
| 87 |
|
| 88 |
def play_tic_tac_toe(evt: gr.SelectData, board, game_over):
|
| 89 |
|
| 90 |
-
print(f"Event = {evt}")
|
| 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
|
|
@@ -100,7 +97,6 @@ def play_tic_tac_toe(evt: gr.SelectData, board, game_over):
|
|
| 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] != "":
|
|
@@ -126,7 +122,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)
|
|
|
|
| 87 |
|
| 88 |
def play_tic_tac_toe(evt: gr.SelectData, board, game_over):
|
| 89 |
|
|
|
|
|
|
|
|
|
|
| 90 |
# 確認 evt 是否有效
|
| 91 |
if not evt or not hasattr(evt, "index") or not evt.index:
|
| 92 |
return draw_board(board), "Invalid move! Please select a valid square.", False
|
|
|
|
| 97 |
try:
|
| 98 |
r, c = evt.index[1] // 100, evt.index[0] // 100
|
| 99 |
except (TypeError, IndexError):
|
|
|
|
| 100 |
return draw_board(board), "Invalid selection! Please try again.", False
|
| 101 |
|
| 102 |
if board[r][c] != "":
|
|
|
|
| 122 |
gr.Markdown("# Tic-Tac-Toe AI Game")
|
| 123 |
|
| 124 |
board = initialize_board()
|
| 125 |
+
board_image = gr.Image(value=draw_board(board), interactive=False, label="Board", show_download_button=False, show_fullscreen_button=False)
|
| 126 |
message_display = gr.Textbox(label="Game Status", value="Game in progress")
|
| 127 |
reset_button = gr.Button("Reset Game")
|
| 128 |
board_state = gr.State(board)
|