What the heck has this to do with CECP ('XBoard protocol')? It is just advice for how to do I/O in a chess engine. An elaborate description of how you can implement non-blocking input from pipes, which would be exactly the same whether you implement CECP, UCI or any other protocol.
The UCI protocol specs do not tutor prospective engine developers about tis at all, but leave them completely in the dark about it.
Well, last months soemone sent me the source code of a stand-alone chess program with an ascii interface, and because I wanted to test it against other engines, I hacked the input loop for parsing some CECP commands. Took me about 5 minutes to make it play under XBoard. (With the aid of the 'new', 'force' and 'go' command.)
Problem is that arguing is no substitute for fact... There are people that argue the Earth is flat.
Code: Select all
int cecp = 0, myColor = 0, stm = 1;
if(cecp) {
if(!strcmp(line, "quit\n")) return;
else if(!strcmp(line, "protover 2\n")) prf("\nfeature sigint=0 reuse=0 done=1\n");
else if(!strcmp(line, "force\n")) myColor = 0;
else if(!strcmp(line, "go\n")) myColor = stm;
else if(!strcmp(line, "new\n")) myColor = 2, stm = 1;
else if(line[1] < '1' || line[1] > '8') continue; // ignore all other commands that are not moves
else { // input move
cecp = 2; if(line[4] != '\n') line[4] &= ~32; // convert promo suffix to upper case
}
if(myColor == stm) goto GO2; // original interface jumped here when it had to think
if(cecp != 2) continue;
cecp = 1;
}