My naive program to test winboard command flow is as follows:
- Code: Select all
/////////////////////////
// file main.cpp //
// Main control structure //
// plus xboard() //
/////////////////////////
#include "stdafx.h"
using namespace std;
void xboard()
{
char user[64];
char moves[10][5];
strcpy(moves[0],"a7a5");
strcpy(moves[1],"b7b5");
strcpy(moves[2],"c7c5");
strcpy(moves[3],"d7d5");
strcpy(moves[4],"e7e5");
strcpy(moves[5],"f7f5");
strcpy(moves[6],"g7g5");
strcpy(moves[7],"h7h5");
strcpy(moves[8],"b8c6");
strcpy(moves[9],"g8f6");
printf("\n"); // winboard expects an empty line to initialize
fflush(stdout);
gets_s(user); // engine expects "new"
for(int k=0; k<10; k++) {
fflush(stdout);
gets_s(user); // get move from winboard
printf("move %s\n",moves[k]); // send move to winboard
}
}
void main()
{
char user[64];
printf("falcon> ");
fflush(stdout);
gets_s(user); // expecting "xboard"
xboard();
}
When I load this engine onto winboard I play any move with white and black responds with f7f5, I play another move and black responds with Nc6 and then crashes with a message that "engine terminated unexpectedly".
Can anybody explain this? First black move should be a7a5 to begin with, followed by b7b5 and so on.
Thanks in advance...