How to Communicate with a Chess engine in Python?

后端 未结 2 1902
清酒与你
清酒与你 2020-12-14 04:36

on win 7 i can communicate with a chess engine via commandline. Small Example Session with Stockfish on Win 7:

C:\\run\\Stockfish>stockfish-x64.exe
Stockfi         


        
2条回答
  •  萌比男神i
    2020-12-14 05:11

    You've got a deadlock: the subprocess is waiting for input, while your program is waiting for it to output more lines in

    for line in engine.stdout:
        print(line.strip())
    

    This loop only stops when the subprocess closes its stdout.

提交回复
热议问题