xboard chess gui 不发送第二个用户移动

xboard chess gui doesn't send second user move

我正在尝试为 xboard 制作国际象棋引擎。在用户迈出第一步后,我的国际象棋引擎回复,然后 xboard 不发送用户迈出的下一步。

我记录了 xboard 发送到我的引擎的任何内容。这是我的引擎用 move e7e6:

回复 e2e4 的代码示例
#include <iostream>
#include <fstream>
#include <unistd.h>

std::ofstream f("xboardtoeng.txt");
std::ofstream f2("engtoxboard.txt");

int main(int argc, char** argv){  

    while (true){
        std::string s;
        std::cin>>s;
        f<<s<<std::endl;
        if (s=="protover"){
            std::cout<<"feature done=1"<<std::endl;
            f2<<"feature done=1"<<std::endl;
        }else if (s=="e2e4"){
            usleep(100000);
            std::cout<<"move e7e6"<<std::endl;
            f2<<"move e7e6"<<std::endl;
        }
    }
    f.close();
}

编译后,我运行xboard -fcp $PWD/a.out。然后,我在 GUI 中以用户身份移动 e2e4。在我的引擎给出回复后,我又走了一步(比如,e4e5)。这是我在 xboardtoeng.txt:

中得到的
xboard
protover 2
accepted usermove
accepted myname
accepted done
new
random
level 40 5 0
post
hard
time 30000
otim 30000
usermove e2e4

在这里,xboard 确实向我的引擎发送了第一步。但是,不会发送下一个用户移动。知道我哪里做错了吗?

我使用xboard 4.8.0版本

我有同样的问题,这是因为Xboard发送了SIGINT和SIGTERM信号。添加代码 signal(SIGINT, SIG_IGN) 解决了我的问题。

source 1 source 2