我试图通过一个php脚本与stockfish象棋引擎进行通信。为此,我使用
UCI protocol
,所以我需要逐行发送命令。例如,这是我通常在windows命令提示符下输入的内容:
Stockfish.exe
position startpos
go depth 16
stockfish.exe是
Stockfish chess engine
我没能用
exec()
. 以下是我的尝试:
exec("stockfish.exe\nposition startpos\ngo depth 16");
引擎运行,但命令未执行,因此我得到:
Stockfish 10 64 by T. Romstad, M. Costalba, J. Kiiski, G. Linscott
在那里我可以得到类似的东西:
info depth 1 seldepth 1 multipv 1 score cp 116 nodes 20 nps 10000 tbhits 0 time 2 pv e2e4
info depth 2 seldepth 2 multipv 1 score cp 112 nodes 54 nps 27000 tbhits 0 time 2 pv e2e4 b7b6
info depth 3 seldepth 3 multipv 1 score cp 148 nodes 136 nps 45333 tbhits 0 time 3 pv d2d4 d7d6 e2e4
info depth 4 seldepth 4 multipv 1 score cp 137 nodes 247 nps 61750 tbhits 0 time 4 pv d2d4 e7e6 e2e4 c7c6
bestmove d2d4 ponder e7e6
我读过
many
threads
但找不到解决办法。有什么办法可以做到这一点吗?