Input problems with UCI Interface

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

mjlef
Posts: 1494
Joined: Thu Mar 30, 2006 2:08 pm

Input problems with UCI Interface

Post by mjlef »

OK, this is driving me nuts, so I hope some of you might have suggestions. I started a C version of my chess program NOW about a year ago. After about a month of programming, I went crazy trying to figure out why the program sometimes hangs. When operated manually from the command line, it never hangs. When using a GUI like Arena, it sometimes hangs as follows:

The GUI send two command rapidly one after the other. The first is a position command, like this:

position startpos moves e2e4 e7e5 d2d3

then next, sent right after that one is the go command, with the time parameters. As far as I can tell the GUI sends one right after the other with no pause or "isready" command to verify the engine is ready.

My program always reads the move command, but it sometimes seems to not get the go command. It just sits there and lest the clock run down. This appears to happen randomly, although perhaps a bit more if the engine is playing black. It is as if the go command is just throw out by the operating system

Suggestions? I can post some sample code or send it to a genius willing to help.

Mark
Tord Romstad
Posts: 1808
Joined: Wed Mar 08, 2006 9:19 pm
Location: Oslo, Norway

Re: Input problems with UCI Interface

Post by Tord Romstad »

Hello Mark,

Are you sure you have disabled IO buffering? Your initialization code should contain something similar to this:

Code: Select all

setbuf(stdout, NULL);
setbuf(stdin, NULL);
setvbuf(stdout, NULL, _IONBF, 0);
setvbuf(stdin, NULL, _IONBF, 0);
Tord
mjlef
Posts: 1494
Joined: Thu Mar 30, 2006 2:08 pm

Re: Input problems with UCI Interface

Post by mjlef »

Tord Romstad wrote:Hello Mark,

Are you sure you have disabled IO buffering? Your initialization code should contain something similar to this:

Code: Select all

setbuf(stdout, NULL);
setbuf(stdin, NULL);
setvbuf(stdout, NULL, _IONBF, 0);
setvbuf(stdin, NULL, _IONBF, 0);
Tord
I did have those in there, but for reasons I cannot explain, the setbuf() calls were put in after one of the reads. Thanks Tord! I owe you a beer (or do you have some exotic pickled fish liquor up there in Norway! :-)
Tord Romstad
Posts: 1808
Joined: Wed Mar 08, 2006 9:19 pm
Location: Oslo, Norway

Re: Input problems with UCI Interface

Post by Tord Romstad »

Hi Mark,

I'm glad you solved your problem!
mjlef wrote:I did have those in there, but for reasons I cannot explain, the setbuf() calls were put in after one of the reads. Thanks Tord! I owe you a beer (or do you have some exotic pickled fish liquor up there in Norway! :-)
We don't -- our local specialty in Norway is "hjemmebrent", home-distilled alcohol made from potatoes and sugar. It is illegal, but quite popular in some districts (especially in the middle and northern part of the country), mainly because of the high taxation for legally bought alcohol. The quality is invariably terrible.

I prefer the beer, please. :wink:

Tord