目前我想製作一個簡單的winboard協議驅動程序,但我不知道從哪裏開始。我已閱讀此頁(H.G. Muller Winboard Protocol Driver),但它太複雜,我:(如何製作一個簡單的協議到Winboard?
所以我搜索瞭如何做一個非常簡單的代碼傳達給WINBOARD,發現這個網頁(Communicating with XBoard (chess engine) (C++/C) Stackoverflow)。我理解的主要思想是擺脫WINBOARD和打印的東西一些輸入給WINBOARD的命令。我也試圖通過埃裏克·托馬在頁面所做的代碼,有幾個變化。
#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 %s\n", "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.3\WinBoard\winboard.exe -cp -fcp C:\WinBoard-4.7.3\WinBoard\testdriver.exe -scp "GNUChess"
我的問題是:
- 對不起,如果我看上去像可笑這裏:(我是正確的代碼呢?
- 我怎樣才能做出一個簡單的舉動,而不是整個引擎(沒有考慮和分析用戶的動作)?無論用戶如何移動棋子,我都會進行1次移動,例如a7a5。這只是讓我知道這個winboard協議的流程。前
謝謝..