如何制作一个简单的Winboard协议
How to make a simple protocol to Winboard?
目前我想制作一个简单的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步,例如a7a5。这只是为了让我知道这个winboard协议的流程
谢谢。。
我一直在寻找使用Winboard协议的帮助,却偶然发现了这个线程。在cmd提示符下用gcc编译代码(Win8)(4个警告)后,我打开了Winboard 4.8启动对话框(与一个引擎或匹配两个引擎选项)。然后我加载了我的.exe作为第一个国际象棋引擎,Winboard暂停了"启动第一个国际棋程序"。过了一段时间,它加载并允许我移动(1.e4)。然后黑色引擎FairyMax没有回应,在5分钟后控制了我的引擎,因为White被宣布按时赢得了比赛!所以我不知道为什么FairyMax的第二个引擎不能输出它的动作?我会对此进行更多的研究和思考,但如果有人能告诉我,我将不胜感激。我希望你已经设法处理好了,因为你第一次发帖已经很长时间了,这是唯一的回复。快乐国际象棋编程:-)
相关文章:
- 在c++中用vector填充一个简单的动态数组
- (C++)分析树以计算返回错误值的简单算术表达式
- 我的简单if-else语句是如何无法访问的代码
- 使用简单类型列表实现的指数编译时间.为什么
- 如何在BST的这个简单递归实现中消除警告
- 一种在C++中读取TXT配置文件的简单方法
- 关于简单C++函数(is_palindrome)的逻辑的问题
- 显示错误输出的简单数组排序程序
- 当无法使用模板和宏时,生成类型变体C++代码的最简单方法是什么?
- 退出简单while循环时出现问题
- 为什么简单的算术减法在"if"条件下不起作用?
- C++-字符串是否包含一个带有简单循环的单词
- 关于 c++ 函数中指针赋值的简单问题
- 从函数返回任意简单类型的数据
- 如何在没有函数的情况下编写此代码并使C++更简单?
- 有没有办法简单地从 GPU 调用多个 cpp 输出文件?
- 在简单示例中,Python3 + ctypes 回调会导致内存泄漏
- 当简单捕获中的标识符显示为参数的声明符 ID 时,没有编译器诊断
- 如何使用 samtools C API 构建一个简单的主.cpp文件
- 如何制作一个简单的Winboard协议