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)