7

I am trying to get score about current position directly with UCI (I am using latest stockfish). After reading the protocol I see that these commands ask engine to analyse the position:

uci
ucinewgame
position fen r1k4r/p2nb1p1/2b4p/1p1n1p2/2PP4/3Q1NB1/1P3PPP/R5K1 b - c3 0 19
go infinite

I see some information from engine, like:

info depth 30 seldepth 55 score cp -482 nodes 380021712 nps 2059916 time 184484

Then I stop it with stop and get bestmove b5c4 ponder d3c4

So it tells me the best move, but what is the score of this position.

Based on my understanding cp - 482 means that black is better almost by 5. But how can I get this information explicitly?

Salvador Dali
  • 4,848
  • 6
  • 30
  • 48
  • Are you using a program to invoke the uci engine and read its values? If you are just using it to analyze positions or games, I suggest using a GUI like Arena or SCID or Tarrash-UI. It makes analysis much easier with nicely laid out UI. – Keshav Jul 30 '14 at 09:34
  • @Keshav I am looking for a way to make online service to analyse chess positions through a web interface. So I am looking for a way to analyse position through some python or node. For this reason I can not use GUI and need to interact with engine through UCI. – Salvador Dali Jul 30 '14 at 09:53
  • I don't understand this question. You have the score, it's cp -482. What else do you want? – Alan Jul 30 '14 at 13:25

2 Answers2

4

lines info depth with score have something begining with pv, whereis the move. cp is centipawn, so evaluation is -4.82

info depth 16 seldepth 3 score cp -529 nodes 3409 nps 10299 time 331 multipv 1 pv b5c4 d3c4 d5b4 a1e1 h8e8 g3d6 d7b6 c4b4 e7d6 b4d6 e8e1 f3e1 c8b7 d6e 7 b6d7 e1d3 a8c8 e7g7 c8c7 g7h6 c6b5 d3e1 c7c8 h6e6 c8c1 e6d5 b7b6 d5d6

uci protocol http://download.shredderchess.com/div/uci.zip

user2371
  • 91
  • 3
1

Before the engine gives a bestmove, the uci protocol specifies it must print a last info line. In that info line the score parameter is the one you want. It's either:

  • cp: score in centipawns
  • mate: moves until mate

I think that a minus score means that there's a disadvantage to the side which has to move.

user3557
  • 11
  • 2
  • 1
    I'm pretty sure a positive score indicates an advantage to white, and a negative score indicates an advantage to black. – Zaz Jul 16 '17 at 04:07
  • 5
    stockfish gives the cp score in terms of whose turn it is – john k Apr 03 '19 at 18:02