Update app.py
Browse files
app.py
CHANGED
|
@@ -79,7 +79,8 @@ def click_handler(evt, state):
|
|
| 79 |
if state is None:
|
| 80 |
state = (initialize_board(), -1, None, None)
|
| 81 |
board, player, last_user, last_ai = state
|
| 82 |
-
x, y = evt.index
|
|
|
|
| 83 |
c = int((x-off)//cell); r = int((y-off)//cell)
|
| 84 |
if 0<=r<8 and 0<=c<8 and not is_game_over(board):
|
| 85 |
if apply_move(board, r, c, player):
|
|
@@ -104,4 +105,4 @@ with demo:
|
|
| 104 |
new = gr.Button('New Game')
|
| 105 |
img.select(click_handler, inputs=[state], outputs=[img, state], show_progress=True)
|
| 106 |
new.click(reset_game, outputs=[img, state])
|
| 107 |
-
demo.launch()
|
|
|
|
| 79 |
if state is None:
|
| 80 |
state = (initialize_board(), -1, None, None)
|
| 81 |
board, player, last_user, last_ai = state
|
| 82 |
+
x, y = evt.index[0], evt.index[1]
|
| 83 |
+
cell = 360//8; off = 20
|
| 84 |
c = int((x-off)//cell); r = int((y-off)//cell)
|
| 85 |
if 0<=r<8 and 0<=c<8 and not is_game_over(board):
|
| 86 |
if apply_move(board, r, c, player):
|
|
|
|
| 105 |
new = gr.Button('New Game')
|
| 106 |
img.select(click_handler, inputs=[state], outputs=[img, state], show_progress=True)
|
| 107 |
new.click(reset_game, outputs=[img, state])
|
| 108 |
+
demo.launch()
|