Well, of course all of this is dead simple. Even providing an existing engine that has a non-standard command-line interface with enough CECP understanding to play automated games with it under XBoard should be at most a 10-min jub of someone who already knows the engine. So basically all we say here is nitpicking.
But parsing FEN is more complex than parsing drop moves. In the end a FEN will still do multiple calls to a routine PutPiece(type, square), which would also be the back-end for the drop-move. The recognition of the latter is really trivial:
Code: Select all
if(line[1] == '@') PutPiece(line[0], N_FILES*(line[3]-'1') + (line[2]-'a'));
To play automated games under WinBoard at the default TC only requires:
Code: Select all
while(1) {
static int myColor = 1, stm=0; // 0 = white, 1 = black
if(stm == myColor) {
ThinkAndPlayMove(); // the engine is supposed to have that function
printf("move %s\n", moveText); // this would usually just be an adaptation of the format ThinkAndPlayMove() prints the move in
stm ^= 1;
}
fflush(stdout);
line = ReadLine(); // the engine is supposed to have that function
if(!strcmp(line, "go")) myColor = stm;
else if(!strcmp(line, "force")) myColor = 2; // neither color
else if(isdigit(line[1])) stm ^= 1, ParseAndPlayMove(line); // the engine is supposed to have that function
}
To prevent some annoying pauses (while waiting for timeouts) at the start and end of a game you could add
Code: Select all
else if(!strcmp(line, "quit")) exit(0);
else if(!strcmp(line, "protover 2")) printf("feature done=1\n");