uci ponder protocol

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

elcabesa
Posts: 855
Joined: Sun May 23, 2010 1:32 pm

uci ponder protocol

Post by elcabesa »

hi, I'm having some trouble understanding the uci ponder protocol.
I understood the engine should send the ponder option in reply to to the uci command to inform the gui, but i didn't understood what to expect next.

is this a good command sequence?
>uci
<uciok
< option ponder ......
>position startpos
>go wtime 4000 btime 40000
<bestmove e2e4 ponder d7d5
>position startpos moves e2e4 d7d5

what now??

>go ponder wtime 3900 btime 4000

the engine start pondering/(infinite search)
now two options

>stop (the engine stop and wait for a new position)
>ponderhit ( the engine switch to a normal search and start to count the time

am i wrong?
User avatar
Steve Maughan
Posts: 1221
Joined: Wed Mar 08, 2006 8:28 pm
Location: Florida, USA

Re: uci ponder protocol

Post by Steve Maughan »

You're basically right.

Here's what Maverick does:

When it gets a command such as:

"go ponder wtime 3900 btime 4000"

Maverick calculates the time it would normally spend thinking if it wasn't pondering (TargetTime) and an abort time (i.e. time to interrupt the search). It then starts to "think". The only difference is with the Ponder flag set it ignores the time and continues searching. If it gets a "ponder hit" then it sets the ponder flag to false and (in the search) sees if it's past the abort time (in which case it moves) or continues searching (without the ponder flag set).

It works well

Steve
http://www.chessprogramming.net - Maverick Chess Engine
Sven
Posts: 4052
Joined: Thu May 15, 2008 9:57 pm
Location: Berlin, Germany
Full name: Sven Schüle

Re: uci ponder protocol

Post by Sven »

elcabesa wrote:hi, I'm having some trouble understanding the uci ponder protocol.
I understood the engine should send the ponder option in reply to to the uci command to inform the gui, but i didn't understood what to expect next.

is this a good command sequence?
>uci
<uciok
< option ponder ......
>position startpos
>go wtime 4000 btime 40000
<bestmove e2e4 ponder d7d5
>position startpos moves e2e4 d7d5

what now??

>go ponder wtime 3900 btime 4000

the engine start pondering/(infinite search)
now two options

>stop (the engine stop and wait for a new position)
>ponderhit ( the engine switch to a normal search and start to count the time

am i wrong?
According to the specs it looks as if you should send "option name Ponder ..." prior to sending "uciok".

Note that you need to reply to "stop" with "bestmove ...". One "bestmove" per "go".

Code: Select all

>uci
<id name MyEngine
<id author Marco Belli
<option name Ponder type check ...
<uciok
>ucinewgame
>isready
  &#91;engine initializes new game&#93;

<readyok
>position startpos
>go wtime 4000 btime 4000
  &#91;engine starts normal search&#93;

<bestmove e2e4 ponder d7d5
>position startpos moves e2e4 d7d5
  &#91;what now?? => engine sets up initial position and makes the given moves&#93;

>go ponder wtime 3900 btime 4000
  &#91;engine starts searching in ponder mode&#93;

>ponderhit
  &#91;opponent has played the ponder move, engine switches to normal search&#93;

<bestmove e4d5 ponder d8d5
>position startpos moves e2e4 d7d5 e4d5 d8d5
  &#91;what now?? => engine sets up initial position and makes the given moves&#93;

>go ponder wtime 3800 btime 3900
  &#91;engine starts searching in ponder mode&#93;

>stop
  &#91;opponent has played a different move, engine stops search and sends back some bestmove command just for the protocol&#93;

<bestmove b1c3
  &#91;GUI ignores the engine's response since it belongs to the ponder move which has not been played&#93;

>position startpos moves e2e4 d7d5 e4d5 g8f6
  &#91;what now?? => engine sets up initial position and makes the given moves&#93;

>go wtime 3700 btime 3800
  &#91;engine starts normal search&#93;

<bestmove b1c3 ponder f6d5
>... and so on
I think it might look like this, I hope I got everything right. I did not spend time to think about plausible wtime/btime values, though.

Sven
elcabesa
Posts: 855
Joined: Sun May 23, 2010 1:32 pm

Re: uci ponder protocol

Post by elcabesa »

thank you, simpler than I first tough.
I'll implement this asap :)
User avatar
hgm
Posts: 27808
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: uci ponder protocol

Post by hgm »

Note that in the strict interpretation of the protocol, a GUI should not set an engine pondering if it does not support the Ponder option (i.e. does not send 'option name Ponder type check ...' in response to 'uci'. Some engines sin against this (i.e. they would be able to ponder if requested to do so, but do not announce the Ponder option.) Polyglot has a work-around setting for this ('Polyglot CanPonder'), which forces the GUI (i.e. Polyglot) to emit ponder commands despite the absence of a Ponder option.

The idea of the Ponder option is that the engine can calculate the target time per move differently if it knows that it will be allowed to ponder, taking more generous time, because it can count on earning some time back by ponder hits during the rest of the game.
elcabesa
Posts: 855
Joined: Sun May 23, 2010 1:32 pm

Re: uci ponder protocol

Post by elcabesa »

I think I have implemented the code, but how to test it? i'm using cutechess-cli and it doesn't support ponder, any other free alternative?
Edoardo Manino
Posts: 70
Joined: Thu Jul 12, 2012 12:43 am
Location: Turin, Italy

Re: uci ponder protocol

Post by Edoardo Manino »

winboard, arena...