Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve UCI compliance: remove extra newline after 'bestmove' (TerjeK…
…ir#674) Before this patch, Weiss adds an extra newline after 'bestmove'. For example: $ ./weiss > go depth 1 < info depth 1 seldepth 1 multipv 1 score cp 68 time 0 nodes 49 nps 49000 tbhits 0 hashfull 0 pv b1c3 < bestmove b1c3 < where: > input to engine < output from engine However, the additional empty line after bestmove makes python-chess unhappy. With this simple repro: $ python3 import chess.engine engine = chess.engine.SimpleEngine.popen_uci('./weiss') board = chess.Board() result = engine.analyse(board, chess.engine.Limit(time=1)) # triggers the assert result['score'] engine.quit() I get: Exception in callback Protocol._line_received('') handle: <Handle Protocol._line_received('')> Traceback (most recent call last): File "/usr/lib/python3.11/asyncio/events.py", line 80, in _run self._context.run(self._callback, *self._args) File "/home/skiminki/.local/lib/python3.11/site-packages/chess/engine.py", line 1040, in _line_received self.command._line_received(self, line) File "/home/skiminki/.local/lib/python3.11/site-packages/chess/engine.py", line 1289, in _line_received assert self.state in [CommandState.ACTIVE, CommandState.CANCELLING] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AssertionError PovScore(Cp(+77), WHITE) Technically, the UCI protocol does not list the empty output line from the engine as an option. So, remove it to improve conformance. This also makes the python-chess assert spam go away. No functional change. Bench: 19891416
- Loading branch information