GUI/UCI engine communication

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

ChessC

GUI/UCI engine communication

Post by ChessC »

I have the UCI Protocol document for GUI/UCI engine communication, but some things are not clear.

Suppose so far we have

>uci
.....
<uciok
>isready
<readyok

I want to analyze the game fragment

1. e2e4 e7e5

with each move analyzed for 5 seconds.

How do I set things up to get (1) the best move the engine comes up with after 5 seconds for white's first move above and (2) its evaluation in centipawns for the move in the fragment for white. Similarly for black. Please provide your answer in terms of a sequence of inputs to the engine alternated with outputs from the engine. Thanks.
kranium
Posts: 2129
Joined: Thu May 29, 2008 10:43 am

Re: GUI/UCI engine communication

Post by kranium »

ChessC wrote:I have the UCI Protocol document for GUI/UCI engine communication, but some things are not clear.

Suppose so far we have

>uci
.....
<uciok
>isready
<readyok

I want to analyze the game fragment

1. e2e4 e7e5

with each move analyzed for 5 seconds.

How do I set things up to get (1) the best move the engine comes up with after 5 seconds for white's first move above and (2) its evaluation in centipawns for the move in the fragment for white. Similarly for black. Please provide your answer in terms of a sequence of inputs to the engine alternated with outputs from the engine. Thanks.
the gui would send this to the engine:

position startpos moves e2e4 e7e5
go movetime 5000

the engine should begin analyzing and regularly print lines of info:

info depth 1
info multipv 1 depth 1 score cp 28 time 0 nodes 2 pv g1f3
info multipv 1 depth 1 score cp 44 time 0 nodes 6 pv b1c3
info depth 1 time 0 nodes 216 nps 0
info depth 2
info multipv 1 depth 2 score cp 20 time 0 nodes 139 pv b1c3 b8c6
info depth 2 time 0 nodes 402 nps 0
info depth 3
info multipv 1 depth 3 score cp 28 time 0 nodes 276 pv b1c3 b8c6 g1f3
info depth 3 time 0 nodes 1944 nps 0
info depth 4
info multipv 1 depth 4 score cp 20 time 0 nodes 1153 pv b1c3 b8c6 g1f3 g8f6
info depth 4 time 0 nodes 4362 nps 0
info depth 5
info multipv 1 depth 5 score cp 21 time 0 nodes 2482 pv b1c3 b8c6 g1f3 g8f6 d2d4
info multipv 1 depth 5 score cp 23 time 0 nodes 3750 pv g1f3 b8c6 d2d4 e5d4 f3d4 g8f6
info depth 5 time 0 nodes 9252 nps 0
info depth 6
info multipv 1 depth 6 score cp 33 time 0 nodes 5879 pv g1f3 b8c6 b1c3 g8f6 d2d4 d7d5 d4e5 d5e4 d1d8 e8d8 e5f6 e4f3 f6g7 f8g7 g2f3
info depth 6 time 0 nodes 11814 nps 0
info depth 7
info multipv 1 depth 7 score cp 18 time 0 nodes 8273 pv g1f3 g8f6 d2d4 b8c6 d4e5 f6e4 b1c3 e4c3 b2c3
info multipv 1 depth 7 score cp 38 time 16 nodes 14665 pv b1c3 b8c6 g1f3 g8f6 f1c4 f8b4 e1g1 b4c3 d2c3 f6e4
info depth 7 time 16 nodes 29372 nps 0
info depth 8
info multipv 1 depth 8 score cp 25 time 16 nodes 20242 pv b1c3 b8c6 g1f3 g8f6 f1b5 f8c5 e1g1 e8g8 b5c6 d7c6 f3e5
info depth 8 time 31 nodes 65726 nps 0
etc.

(the PV is pretty important...for the GUI to display, most of the other info lines are optional, i.e. - some engines print lots of info, others little or none.)

after 5 seconds the engine should stop thinking and print it's move:
bestmove g1f3
ChessC

Re: GUI/UCI engine communication

Post by ChessC »

Let's go back to e2e4 as white' s first move of the game fragment to be analyzed. After readyok is returned, I can do

>go movetime 5000

to get the engine's recommended move for the beginning of a game. How though do I get the engine's evaluation of the board position after e2e4 as the first move of a game? If we do

>uci
<id name Rybka 2.2n2 mp 32-bit
.....
<uciok
>isready
<readyok
>position setpos moves e2e4
>go movetime 5000
.....
<info depth 11 score cp -5 hashfull 0 time 4985 nodes 237917 nps 48872 pv e7e5 b1c3 g8f6 g1f3 b8c6 f1c4 f8c5 e1g1
<info currmove e7e6 currmovenumber 13
<info currmove f7f5 currmovenumber 14
<info time 5001 nodes 237942 nps 237942
<bestmove e7e5 ponder b1c3

it seems that the board position is evaluated as -.05 in pawns after the move e7e5, but I want the evaluation after e2e4.
Teemu Pudas
Posts: 88
Joined: Wed Mar 25, 2009 12:49 pm

Re: GUI/UCI engine communication

Post by Teemu Pudas »

ChessC wrote:it seems that the board position is evaluated as -.05 in pawns after the move e7e5, but I want the evaluation after e2e4.
They're the same thing (modulo sign flip) because the engine happens to think e7e5 is the best move.