擅长:python、mysql、java
<p>您可能希望像python chess那样使用asyncio。
见</p>
<p><a href="https://github.com/niklasf/python-chess/blob/master/chess/engine.py" rel="nofollow noreferrer">engine.py</a></p>
<p>以及来自<a href="https://python-chess.readthedocs.io/en/latest/engine.html" rel="nofollow noreferrer">documentation</a>的示例</p>
<pre><code>import asyncio
import chess
import chess.engine
async def main():
transport, engine = await chess.engine.popen_uci("/usr/bin/stockfish")
board = chess.Board()
while not board.is_game_over():
result = await engine.play(board, chess.engine.Limit(time=0.1))
board.push(result.move)
await engine.quit()
asyncio.set_event_loop_policy(chess.engine.EventLoopPolicy())
asyncio.run(main())
</code></pre>