Skip to content

Commit

Permalink
Return to game if engine makes bad move (#1057)
Browse files Browse the repository at this point in the history
If an engine picks a bad move (i.e., illegal or invalid), then the game
is aborted or the engine resigns. In either case, the program should
return to the play_game() function to await the next message from
lichess.
  • Loading branch information
MarkZH authored Dec 19, 2024
1 parent a0d46e9 commit d51e5a4
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/engine_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,12 @@ def play_move(self,
BadMove = (chess.IllegalMoveError, chess.InvalidMoveError)
if any(isinstance(e, BadMove) for e in error.args):
logger.error("Ending game due to bot attempting an illegal move.")
logger.error(error)
game_ender = li.abort if game.is_abortable() else li.resign
game_ender(game.id)
raise
return
else:
raise

# Heed min_time
elapsed = setup_timer.time_since_reset()
Expand Down

0 comments on commit d51e5a4

Please sign in to comment.