如何制作一个简单的Winboard协议

How to make a simple protocol to Winboard?

本文关键字:简单 Winboard 协议 一个 何制作      更新时间:2023-10-16

目前我想制作一个简单的winboard协议驱动程序,但我不知道从哪里开始。我读过这个页面(H.G.Muller Winboard协议驱动程序),但它对我来说太复杂了:(

因此,我搜索了如何制作一个非常简单的代码来与winboard通信,并找到了这个页面(与XBoard(国际象棋引擎)通信(C++/C)堆栈溢出)。我知道主要的想法是从winboard获得一些输入,并打印一些东西来给winboard一个命令。我还尝试了Eric Thoma在该页面中编写的代码,并做了一些更改。

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
// four different constants, with values for WHITE and BLACK that suit your engine
#define WHITE   1
#define BLACK   2
#define NONE    0
#define ANALYZE  3
#define DEFAULT_FEN "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"
int main(int argc, const char * argv[]){
int stm;                                 // side to move
int engineSide=NONE;                     // side played by engine
int i, score;
char inBuf[80], command[80];
while(1){
fflush(stdout);
if (stm == engineSide){
printf("move %sn", "a7a5");
// change the stm?
continue;
}
fflush(stdout);
if (!fgets(inBuf, 80, stdin)) continue;
sscanf(inBuf, "%s", command);
if(!strcmp(command, "quit")){
break; // breaks out of infinite loop
} 
if(!strcmp(command, "force")){
engineSide = NONE;
continue;
}
if(!strcmp(command, "go")){
engineSide = stm; 
continue;
}
if(!strcmp(command, "exit")){
engineSide = NONE;
continue;
}
if(!strcmp(command, "new")){
engineSide = BLACK;
// change the stm?
continue;
}
if(!strcmp(command, "setboard")){
engineSide = NONE;
// change the stm?
continue;
}
if(!strcmp(command, "protover")){
printf("feature ping=1 setboard=1 colors=0 usermove=1 debug=1");
printf("feature done=1");
continue;
}
if(!strcmp(command, "ping")){
printf("pong%s", inBuf+4);
continue;
}
if(!strcmp(command, "usermove")){
//whatever
//i just want to try to move the chess piece
}
}
}

但是什么都没有改变,当我通过创建winboard和简单协议的exe文件的快捷方式来运行它时,我的代码不会移动任何棋子。

C:WinBoard-4.7.3WinBoardwinboard.exe -cp -fcp C:WinBoard-4.7.3WinBoardtestdriver.exe -scp "GNUChess"

我的问题是:

  1. 如果我在这里看起来很可笑,对不起:(我编码对吗?)
  2. 我怎么能只做一个简单的动作而不做整个引擎(不思考和分析用户的动作)?无论用户移动棋子,我都只移动1步,例如a7a5。这只是为了让我知道这个winboard协议的流程

谢谢。。

我一直在寻找使用Winboard协议的帮助,却偶然发现了这个线程。在cmd提示符下用gcc编译代码(Win8)(4个警告)后,我打开了Winboard 4.8启动对话框(与一个引擎或匹配两个引擎选项)。然后我加载了我的.exe作为第一个国际象棋引擎,Winboard暂停了"启动第一个国际棋程序"。过了一段时间,它加载并允许我移动(1.e4)。然后黑色引擎FairyMax没有回应,在5分钟后控制了我的引擎,因为White被宣布按时赢得了比赛!所以我不知道为什么FairyMax的第二个引擎不能输出它的动作?我会对此进行更多的研究和思考,但如果有人能告诉我,我将不胜感激。我希望你已经设法处理好了,因为你第一次发帖已经很长时间了,这是唯一的回复。快乐国际象棋编程:-)