Saturday, 28 May 2016

Integrating with the Python Chess Module

My next step was to integrate my rudimentary Novag Citrine interface with python-chess:

https://python-chess.readthedocs.io/en/v0.14.0/

The main 'glue' that was needed was code to convert moves from the Universal Chess Interface (UCI) format to the Novag format and vice versa. This module makes it easy to keep track of the position from within Python, and connect to external chess engines.

As noted previously, I found it necessary to send engine moves to the Citrine twice. A 0.1 second delay after each command worked well for non-captures. In this case, the piece to be moved was clearly indicated, as was the destination square when the piece was lifted. I found that this did not work well when the engine's move was a capture. In this case, the destination square flashed very briefly, and the piece to be moved was again indicated clearly, but the destination square was not indicated at all when the piece was lifted. I added another 3 second delay after sending the first capture, which gave more time to see which piece was being captured.

I can now play against the Stockfish engine on my Novag Citrine board.

4 comments:

  1. Does this mean your Novag Citrine works with all UCI compliant applications? Are you sharing or selling the uci to Novag adapter?

    ReplyDelete
  2. My Python code will work with any UCI engine. You are welcome to use the code free of charge.

    ReplyDelete