I've been trying to make a simple UCI compliant chess engine. I have written a simple UCI loop to print "bestmove e2e4" when it receives the command "go" from the GUI. However, this does not seem to work (I tried on both Arena and PyChess). Is there something wrong I am doing?
Below is the code for my UCI Loop: (I've just modified the Vice engine's code a bit)
Code: Select all
setbuf(stdin, NULL);
setbuf(stdout, NULL);
char line[INPUTBUFFER];
printf("id name %s\n",NAME);
printf("uciok\n");
int MB = 64;
while (1) {
memset(&line[0], 0, sizeof(line));
fflush(stdout);
if (!fgets(line, INPUTBUFFER, stdin))
continue;
if (line[0] == '\n')
continue;
if (!strncmp(line, "isready", 7)) {
printf("readyok\n");
continue;
} else if (!strncmp(line, "position", 8)) {
} else if (!strncmp(line, "ucinewgame", 10)) {
} else if (!strncmp(line, "go", 2)) {
printf("bestmove e2e4\n");
} else if (!strncmp(line, "quit", 4)) {
break;
} else if (!strncmp(line, "uci", 3)) {
printf("id name %s\n",NAME);
printf("uciok\n");
}
}
Thanks