Update app.py
Browse files
app.py
CHANGED
@@ -59,7 +59,10 @@ def btn_play(inp_fen, inp_move, inp_notation, inp_k):
|
|
59 |
else:
|
60 |
mv = chess.Move.from_uci(predict_move(board.fen(), top_k=inp_k))
|
61 |
|
62 |
-
board.
|
|
|
|
|
|
|
63 |
|
64 |
with open('board.svg', 'w') as f:
|
65 |
f.write(str(chess.svg.board(board, lastmove=mv)))
|
|
|
59 |
else:
|
60 |
mv = chess.Move.from_uci(predict_move(board.fen(), top_k=inp_k))
|
61 |
|
62 |
+
if mv in board.legal_moves:
|
63 |
+
board.push(mv)
|
64 |
+
else:
|
65 |
+
raise ValueError(f'Illegal Move: {str(mv)} @ {board.fen()}')
|
66 |
|
67 |
with open('board.svg', 'w') as f:
|
68 |
f.write(str(chess.svg.board(board, lastmove=mv)))
|