Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception in callback Protocol._line_received('') #1071

Open
IceboxDev opened this issue Mar 13, 2024 · 1 comment
Open

Exception in callback Protocol._line_received('') #1071

IceboxDev opened this issue Mar 13, 2024 · 1 comment
Labels
bug engine Chess engine integration

Comments

@IceboxDev
Copy link

IceboxDev commented Mar 13, 2024

I'm experiencing an AssertionError when trying to analyze a chess board using Chessify UCI chess engine. The error occurs after the analysis is completed and seems to be related to the internal state management of engine communication.


Minimal code to reproduce:

import chess.engine
import constants

engine = chess.engine.SimpleEngine.popen_uci(constants.ENGINE_PATH)

board = chess.Board()
result = engine.analyse(board, chess.engine.Limit(depth=30))
print(result)

Stacktrace:

Exception in callback Protocol._line_received('')
handle: <Handle Protocol._line_received('')>
Traceback (most recent call last):
  File "C:\Users\Manta\AppData\Local\Programs\Python\Python310\lib\asyncio\events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "E:\Projects\UniversalChessTool\.venv\lib\site-packages\chess\engine.py", line 1093, in _line_received
    self.command._line_received(self, line)
  File "E:\Projects\UniversalChessTool\.venv\lib\site-packages\chess\engine.py", line 1385, in _line_received
    assert self.state in [CommandState.ACTIVE, CommandState.CANCELLING]
AssertionError
  • self.state has value CommandState.DONE

result:

result = {
    'string': 'NNUE evaluation using nn-b1a57edbea57.nnue',
    'depth': 30,
    'seldepth': 48,
    'multipv': 1,
    'score': 'PovScore(Cp(+32), WHITE)',
    'nodes': 123673136,
    'nps': 9619876,
    'hashfull': 140,
    'tbhits': 0,
    'time': 12.856,
    'pv': [
        'Move.from_uci(e2e4)', 'Move.from_uci(e7e5)', 'Move.from_uci(g1f3)', 'Move.from_uci(b8c6)',
        'Move.from_uci(f1b5)', 'Move.from_uci(g8f6)', 'Move.from_uci(e1g1)', 'Move.from_uci(f6e4)',
        'Move.from_uci(f1e1)', 'Move.from_uci(e4d6)', 'Move.from_uci(f3e5)', 'Move.from_uci(f8e7)',
        'Move.from_uci(b5f1)', 'Move.from_uci(c6e5)', 'Move.from_uci(e1e5)', 'Move.from_uci(e8g8)',
        'Move.from_uci(d2d4)', 'Move.from_uci(e7f6)', 'Move.from_uci(e5e1)', 'Move.from_uci(d6f5)',
        'Move.from_uci(c2c3)', 'Move.from_uci(d7d5)', 'Move.from_uci(b1d2)', 'Move.from_uci(f5d6)',
        'Move.from_uci(a2a4)', 'Move.from_uci(a7a5)', 'Move.from_uci(d2f3)', 'Move.from_uci(c8f5)',
        'Move.from_uci(h2h3)', 'Move.from_uci(f5e4)', 'Move.from_uci(c1f4)', 'Move.from_uci(c7c6)',
        'Move.from_uci(f3e5)', 'Move.from_uci(f8e8)', 'Move.from_uci(f4h2)', 'Move.from_uci(e4f5)',
        'Move.from_uci(d1b3)', 'Move.from_uci(h7h5)', 'Move.from_uci(e1e2)', 'Move.from_uci(g7g6)',
        'Move.from_uci(a1e1)', 'Move.from_uci(h5h4)', 'Move.from_uci(e5g4)', 'Move.from_uci(f5g4)',
        'Move.from_uci(e2e8)', 'Move.from_uci(d6e8)', 'Move.from_uci(h3g4)'
    ],
    'currmove': 'Move.from_uci(h2h4)',
    'currmovenumber': 20
}

Expected Behavior:
The analysis should complete without any errors, and the engine should return the analysis results.


Environment:
Python version: 3.10
python-chess version: 1.10
Operating System: Windows 10
Chess Engine Used: ChessifyClientStockfish

Additional Context:
The issue occurs consistently with the above setup.
The analysis result is correct; the issue seems to be purely related to internal state handling in the python-chess library.

@niklasf niklasf added bug engine Chess engine integration labels Mar 13, 2024
@niklasf
Copy link
Owner

niklasf commented Mar 13, 2024

Thanks for the detailed report. Can you please also enable debug logging and include the output?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug engine Chess engine integration
Projects
None yet
Development

No branches or pull requests

2 participants