0

Currently i want to make a simple winboard protocol driver, but i don't know where to start. I have read this page (H.G. Muller Winboard Protocol Driver), but it is too complicated for me :(

So i search how to make a very simple code to communicate to the winboard and found this page (Communicating with XBoard (chess engine) (C++/C) Stackoverflow). I understand the main idea is to get some input from winboard and print something to give winboard a command. I also tried the code made by Eric Thoma in that page, with a few changes.

#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
        }

    }
}

but nothing have change, when i run it by making a shortcut to the winboard and the simple protocol's exe file, my code is not moving any chess piece.

C:\WinBoard-4.7.3\WinBoard\winboard.exe -cp -fcp C:\WinBoard-4.7.3\WinBoard\testdriver.exe -scp "GNUChess"

My Question is:

  1. sorry if i looked like ridiculous here :( am i code it right?
  2. how can i just make a simple move without making the entire engine (without pondering and analyzing the user moves)? whatever the user will move the chess piece, i will just make 1 move, for example a7a5. it is just to make me know the flow of this winboard protocol.

Thanks before..

Community
  • 1
  • 1

1 Answers1

0

I have just been searching for help to use Winboard Protocol and stumbled onto this thread. After I compiled the code with gcc in cmd prompt (Win8) (4 warnings) I opened Winboard 4.8 start dialog (play against an engine or match 2 engines options). I then loaded my .exe as first chess engine and Winboard paused with "starting first chess program". After a while it loaded and allowed me to play a move (1.e4).There then was no response from the black engine FairyMax and after the 5 minute time control my engine as White was declared to have won the game on time! So I'm not sure why the FairyMax second engine couldn't output it's moves? I will look and think more into this but if anyone can tell me I'd be grateful to have an explanation. I hope you have managed to move on yourself with this as it has been a long time since you first posted and this is the only reply. Happy chess programming :-)

rpd
  • 1,135
  • 4
  • 15
  • 24