python-chess icon indicating copy to clipboard operation
python-chess copied to clipboard

How to communicate with a remote chess enigne?

Open flashdens opened this issue 1 year ago • 0 comments

hello,

I got a remotely running UCI chess engine (inside a docker container), however I have no idea how to communicate with it using the code snippet provided in the docs. I've read the documentation on asyncio, but I didn't manage to find out how to handle the connection, especially that engine.initalize() and engine.ping() are abstract.

how do I send, for example, 'uci', to the remote process?


import asyncio
import asyncssh
import chess
import chess.engine
import chess.variant


async def main() -> None:
    async with asyncssh.connect("bugdothouse_fairy-stockfish", username='root', password='password', known_hosts=None) as conn:
        channel, engine = await conn.create_subprocess(chess.engine.UciProtocol, "/stockfish/stockfish")
        await engine.initialize()
        await engine.ping()

    await engine.quit()


asyncio.run(main())

i'll be grateful for any help.

flashdens avatar May 14 '24 14:05 flashdens