You are exagerating. Zillions of UCI engines work without any problems with xboard (which uses PG internally). The problem in this case is likely a minor one which should be quickly resolved by inspecting the PG logfile.which seems like a much simpler setup than polyglot+xboard
UCI code
Moderator: Ras
-
- Posts: 2292
- Joined: Mon Sep 29, 2008 1:50 am
Re: UCI code
-
- Posts: 28394
- Joined: Fri Mar 10, 2006 10:06 am
- Location: Amsterdam
- Full name: H G Muller
Re: UCI code
That it says uciok does not necessarily mean thet the GUI receives it. Are you sure you flush stdout after uciok?lucasart wrote:you are right, my engine doesn't send any options. it just says it's name (id name and id author) and then it says uciok.
The only way to get the behavior you describe is when Polyglot does not receive the uciok, and isstill waiting for it (or for options). As soon as it gets uciok it would send its own options and feature done=1 to XBoard, and the Engine Settings dialog would be full of Polyglot options...
At least, if you are not using an extremely obsolete Polyglot.
Btw, the easiest way to test if your engine works properly is to run UCI2WB from the command line with the engine. E.g.
./UCI2WB ENGINEBINARY
Then type protover, and you will see in real time what the engine responds to that, as UCI2WB prints everything it receives from the engine as a WB debug line. That is much easier than post-mortem interpretation of log files. E.g. for Fruit:
Code: Select all
$ ./UCI2WB C:/WinBoard-4.5-TM/Fruit/fruit_21.exe
# engine said: Fruit 2.1 UCI by Fabien Letouzey
protover
feature variants="normal,xiangqi" setboard=1 usermove=1 debug=1 reuse=0 done=0
# engine said: id name Fruit 2.1
feature myname="Fruit (UCI2WB)"
# engine said: id author Fabien Letouzey
# engine said: option name Hash type spin default 16 min 4 max 1024
# engine said: option name Ponder type check default false
feature option="Ponder -check 0"
# engine said: option name OwnBook type check default true
feature option="OwnBook -check 1"
# engine said: option name BookFile type string default book_small.bin
feature option="BookFile -string book_small.bin"
# engine said: option name NullMove Pruning type combo default Fail High var Alw
ays var Fail High var Never
feature option="NullMove Pruning -combo Always /// Fail /// Never"
# engine said: option name NullMove Reduction type spin default 3 min 1 max 3
feature option="NullMove Reduction -spin 3 1 3"
# engine said: option name Verification Search type combo default Endgame var Al
ways var Endgame var Never
feature option="Verification Search -combo Always /// Endgame /// Never"
# engine said: option name Verification Reduction type spin default 5 min 1 max
6
feature option="Verification Reduction -spin 5 1 6"
# engine said: option name History Pruning type check default true
feature option="History Pruning -check 1"
# engine said: option name History Threshold type spin default 60 min 0 max 100
feature option="History Threshold -spin 60 0 100"
# engine said: option name Futility Pruning type check default false
feature option="Futility Pruning -check 0"
# engine said: option name Futility Margin type spin default 100 min 0 max 500
feature option="Futility Margin -spin 100 0 500"
# engine said: option name Delta Pruning type check default false
feature option="Delta Pruning -check 0"
# engine said: option name Delta Margin type spin default 50 min 0 max 500
feature option="Delta Margin -spin 50 0 500"
# engine said: option name Quiescence Check Plies type spin default 1 min 0 max
2
feature option="Quiescence Check Plies -spin 1 0 2"
# engine said: option name Material type spin default 100 min 0 max 400
feature option="Material -spin 100 0 400"
# engine said: option name Piece Activity type spin default 100 min 0 max 400
feature option="Piece Activity -spin 100 0 400"
# engine said: option name King Safety type spin default 100 min 0 max 400
feature option="King Safety -spin 100 0 400"
# engine said: option name Pawn Structure type spin default 100 min 0 max 400
feature option="Pawn Structure -spin 100 0 400"
# engine said: option name Passed Pawns type spin default 100 min 0 max 400
feature option="Passed Pawns -spin 100 0 400"
# engine said: uciok
feature smp=1 memory=1 done=1
-
- Posts: 4052
- Joined: Thu May 15, 2008 9:57 pm
- Location: Berlin, Germany
- Full name: Sven Schüle
Re: UCI code
Due to turning off output buffering with that line:hgm wrote:Are you sure you flush stdout after uciok?
Code: Select all
setvbuf(stdout,NULL,_IONBF,0);
@Lucas: could you post your polyglot.ini file?
Sven
-
- Posts: 3241
- Joined: Mon May 31, 2010 1:29 pm
- Full name: lucasart
Re: UCI code
I don't even know where the polyglot.ini file would be. Nor how to build one. I am now using cutechess-cli, and it confirms the problemn:Sven Schüle wrote:Due to turning off output buffering with that line:hgm wrote:Are you sure you flush stdout after uciok?in function main_loop() it is quite unlikely (i.e. almost impossible) that lines written to stdout by his engine are not flushed. He also uses puts() which implicitly adds a newline character at the end. So his C code looks quite plausible for me.Code: Select all
setvbuf(stdout,NULL,_IONBF,0);
@Lucas: could you post your polyglot.ini file?
Sven
Code: Select all
lucas@lucas-desktop:~$ cutechess-cli -both proto=uci cmd=./DoubleCheck tc=1+0.1
Started game 1 of 1
Warning: Cannot start engine "./DoubleCheck"
Finished match
Code: Select all
uci
id name BibiChess
id author Lucas Braesch
uciok
isready
readyok
ucinewgame
position startpos moves e2e4
isready
readyok
go btime 10 binc 10
(...a lot of info lines, for each depth * nb of root moves searched...)
info bestmove g8f6
the -debug command in cutechess-cli produces nothing, since it fails immediately before loading the engine

-
- Posts: 3241
- Joined: Mon May 31, 2010 1:29 pm
- Full name: lucasart
Re: UCI code
EUREKA !!
I looked at Fruit, and did exactly the same as Fabien:
* the setvbuf just in case
* use fprintf(stdout,...) instead of puts
It is *not logical at all*, but that actually works !
I looked at Fruit, and did exactly the same as Fabien:
* the setvbuf just in case
* use fprintf(stdout,...) instead of puts
It is *not logical at all*, but that actually works !
-
- Posts: 3241
- Joined: Mon May 31, 2010 1:29 pm
- Full name: lucasart
Re: UCI code
by the way cutechess-cli is simply awesome. with the debug command and pgnout command i can see straight away what is happenninglucasart wrote:EUREKA !!
I looked at Fruit, and did exactly the same as Fabien:
* the setvbuf just in case
* use fprintf(stdout,...) instead of puts
It is *not logical at all*, but that actually works !

-
- Posts: 3241
- Joined: Mon May 31, 2010 1:29 pm
- Full name: lucasart
Re: UCI code
I'm going to test it a little and see some pathetic games of my engine playing itself nowlucasart wrote:by the way cutechess-cli is simply awesome. with the debug command and pgnout command i can see straight away what is happenninglucasart wrote:EUREKA !!
I looked at Fruit, and did exactly the same as Fabien:
* the setvbuf just in case
* use fprintf(stdout,...) instead of puts
It is *not logical at all*, but that actually works !

-
- Posts: 3241
- Joined: Mon May 31, 2010 1:29 pm
- Full name: lucasart
Re: UCI code
So, yes, you are right. It does send uciok but Polyglot does not recieve it. This is very strange, but "puts" seems to flush (append a \n) when using in normal console mode and typing the comande, but not when it's being used by Polyglot or cutechess-cli (the two i've tested). Incredibly, fprintf(stdout,...) works but not puts.hgm wrote:That it says uciok does not necessarily mean thet the GUI receives it. Are you sure you flush stdout after uciok?lucasart wrote:you are right, my engine doesn't send any options. it just says it's name (id name and id author) and then it says uciok.
The only way to get the behavior you describe is when Polyglot does not receive the uciok, and isstill waiting for it (or for options). As soon as it gets uciok it would send its own options and feature done=1 to XBoard, and the Engine Settings dialog would be full of Polyglot options...
At least, if you are not using an extremely obsolete Polyglot.
Btw, the easiest way to test if your engine works properly is to run UCI2WB from the command line with the engine. E.g.
./UCI2WB ENGINEBINARY
Then type protover, and you will see in real time what the engine responds to that, as UCI2WB prints everything it receives from the engine as a WB debug line. That is much easier than post-mortem interpretation of log files. E.g. for Fruit:
Code: Select all
$ ./UCI2WB C:/WinBoard-4.5-TM/Fruit/fruit_21.exe # engine said: Fruit 2.1 UCI by Fabien Letouzey protover feature variants="normal,xiangqi" setboard=1 usermove=1 debug=1 reuse=0 done=0 # engine said: id name Fruit 2.1 feature myname="Fruit (UCI2WB)" # engine said: id author Fabien Letouzey # engine said: option name Hash type spin default 16 min 4 max 1024 # engine said: option name Ponder type check default false feature option="Ponder -check 0" # engine said: option name OwnBook type check default true feature option="OwnBook -check 1" # engine said: option name BookFile type string default book_small.bin feature option="BookFile -string book_small.bin" # engine said: option name NullMove Pruning type combo default Fail High var Alw ays var Fail High var Never feature option="NullMove Pruning -combo Always /// Fail /// Never" # engine said: option name NullMove Reduction type spin default 3 min 1 max 3 feature option="NullMove Reduction -spin 3 1 3" # engine said: option name Verification Search type combo default Endgame var Al ways var Endgame var Never feature option="Verification Search -combo Always /// Endgame /// Never" # engine said: option name Verification Reduction type spin default 5 min 1 max 6 feature option="Verification Reduction -spin 5 1 6" # engine said: option name History Pruning type check default true feature option="History Pruning -check 1" # engine said: option name History Threshold type spin default 60 min 0 max 100 feature option="History Threshold -spin 60 0 100" # engine said: option name Futility Pruning type check default false feature option="Futility Pruning -check 0" # engine said: option name Futility Margin type spin default 100 min 0 max 500 feature option="Futility Margin -spin 100 0 500" # engine said: option name Delta Pruning type check default false feature option="Delta Pruning -check 0" # engine said: option name Delta Margin type spin default 50 min 0 max 500 feature option="Delta Margin -spin 50 0 500" # engine said: option name Quiescence Check Plies type spin default 1 min 0 max 2 feature option="Quiescence Check Plies -spin 1 0 2" # engine said: option name Material type spin default 100 min 0 max 400 feature option="Material -spin 100 0 400" # engine said: option name Piece Activity type spin default 100 min 0 max 400 feature option="Piece Activity -spin 100 0 400" # engine said: option name King Safety type spin default 100 min 0 max 400 feature option="King Safety -spin 100 0 400" # engine said: option name Pawn Structure type spin default 100 min 0 max 400 feature option="Pawn Structure -spin 100 0 400" # engine said: option name Passed Pawns type spin default 100 min 0 max 400 feature option="Passed Pawns -spin 100 0 400" # engine said: uciok feature smp=1 memory=1 done=1
If anyone has a clue why, I would be interested (out of curiosity)
-
- Posts: 2292
- Joined: Mon Sep 29, 2008 1:50 am
Re: UCI code
Actually I thought puts was suspicious.
According to MSDN puts adds \n to the string.
However on windows the line terminator is \r\n
Polyglot (and presumable cutechess-cli) do line input (fgets).
So they never get to see a string terminated with only \n.
According to MSDN puts adds \n to the string.
However on windows the line terminator is \r\n
Polyglot (and presumable cutechess-cli) do line input (fgets).
So they never get to see a string terminated with only \n.
-
- Posts: 28394
- Joined: Fri Mar 10, 2006 10:06 am
- Location: Amsterdam
- Full name: H G Muller
Re: UCI code
Well, as I said, UCI2WB already shows you that without giving it any commands. And when debugging, seeing what happens in practice is infinitely more important than what you think should happen in theory...lucasart wrote:by the way cutechess-cli is simply awesome. with the debug command and pgnout command i can see straight away what is happenning
But none of it was actually needed, as xboard+polyglot already revealed from the very start that your engine did not flush the uciok.