3
我正在寻找一种使用matlab与uci协议进行通信的国际象棋引擎的方法。 国际象棋引擎是rybka和它的exe文件。当我运行rybka.exe时,我可以通过dos命令提示符进行通信,但是我想通过matlab来完成。 我想我必须使用streampipe和stdin和stdout,但我不知道如何使用它。如何与使用matlab的uci协议进行通信
我发现在Python这个代码,它工作正常,但我在寻找一个matlab版本:
import subprocess, time
engine = subprocess.Popen(
'a.exe',
universal_newlines=True,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
)
def put(command):
print('\nyou:\n\t'+command)
engine.stdin.write(command+'\n')
def get():
# using the 'isready' command (engine has to answer 'readyok')
# to indicate current last line of stdout
engine.stdin.write('isready\n')
print('\nengine:')
while True:
text = engine.stdout.readline().strip()
if text == 'readyok':
break
if text !='':
print('\t'+text)