jrahn commited on
Commit
0c203c2
1 Parent(s): 6948731

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -1
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.push(mv)
 
 
 
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)))