Hi. I am trying to add my "dummy" SaitekOSA engine to HIARCS Chess Explorer. My program writes to a log file that tells me what UCI messages are received from HCE. When I try to add my engine in the preferences window I see that HCE sends "uci" message to my engine. My engine responds with (C program):
printf("id name SaitekOSA\n");
printf("id author DavePNZ\n");
printf("uciok\n");
HCE pauses for a few seconds and then tells me that my engine is not valid. I then get a "quit" message from HCE. My reading of the UCI protocol indicated to me that this was the minimum valid response to the "uci" message. Have I missed something?
I tried ticking the "log engine output to file" in the preferences>advanced tab, but I can only see a play.log file in the HIARCS Chess>Explorer folder (on a mac). The play.log file only shows "-->quit".
Thanks for any suggestions, Dave.
HIARCS says "not a valid UCI engine"
Moderators: Harvey Williamson, Watchman
- Mark Uniacke
- Hiarcs Author
- Posts: 1459
- Joined: Sun Jul 29, 2007 1:32 pm
- Location: United Kingdom
- Contact:
Re: HIARCS says "not a valid UCI engine"
Does your engine respond to "isready" sent by the GUI to check the engine is ready?
Re: HIARCS says "not a valid UCI engine"
It can reply with readyok if it receives isready, but it does not appear to have received an isready message. Thanks for your reply. Dave.
Re: HIARCS says "not a valid UCI engine"
I tried loading my "engine" into Banksia with the same problem. They both say its not a UCI engine and I get no further messages from the GUI except a "quit". They don't seem to like my response to "uci". I have stripped the code down to the bare essentials and post it here for others to hopefully tell me what I am doing wrong. The funny thing is that I have compared my code with that in other engines written in the C language and they appear to have the same response to the "uci" message, although they also add "option" lines, which I think are optional. All comments are welcome.
Here is the readout if I run the program from the command prompt:
(I have added the direction of message travel manually)
uci <--
id name SaitekOSA v. 1.0 -->
id author DavePNZ -->
uciok -->
isready <--
readyok -->
quit <--
when I try to load the program into a chess GUI I just get "uci", then "quit" after the GUI rejects my response to "uci".
Regards, Dave.
Code: Select all
// read a line from UCI on stdin
// write that line to a logfile UCImsgs.txt
// and respond on stdout
#include <stdio.h>
#include <string.h> // strcmp()
#include <stdlib.h> // exit()
#define fromUCIsize 255
char fromUCI[fromUCIsize]; // holds current UCI message
FILE *UCImsgs;
int main(){
// open log file UCImsgs.txt
UCImsgs = fopen("./UCImsgs.txt", "w");
if (UCImsgs == NULL) perror("Failed to open UCImsgs.txt\n");
do {
fgets(fromUCI, fromUCIsize, stdin); // get a message
fromUCI[strcspn(fromUCI, "\n")] = 0; //remove the \n
// write the message to log file
fprintf(UCImsgs, "UCI input = [%s]\n", fromUCI);
fflush(UCImsgs);
if (strcmp(fromUCI, "quit") == 0) {
fclose(UCImsgs);
exit(0);
}
// case 1: uci
if (strcmp(fromUCI, "uci") == 0) {
printf("id name SaitekOSA v 1.0\n");
printf("id author DavePNZ\n");
printf("uciok\n");
}
// case 2: isready
if (strcmp(fromUCI, "isready") == 0) {
printf("readyok\n");
}
} while(1);
} // end of main()
Here is the readout if I run the program from the command prompt:
(I have added the direction of message travel manually)
uci <--
id name SaitekOSA v. 1.0 -->
id author DavePNZ -->
uciok -->
isready <--
readyok -->
quit <--
when I try to load the program into a chess GUI I just get "uci", then "quit" after the GUI rejects my response to "uci".
Regards, Dave.
Re: HIARCS says "not a valid UCI engine"
I have now solved this problem by flushing stdout after I write messages to the GUI. I hope this might be of some use to others in the future who might encounter a similar difficulty. It is interesting that a flush is needed in this context but not when run from the command line. I don't know why. Thanks for your suggestions.