hey ojb and other fellow computer analyser amateurs, I did roll my own stockfish analyser in scala.
I'd like to get your advice on the best way to communicate with stockfish (or any UCI engine I suppose).
Actually for each move, I set the previous position and run the go command.
For instance, for a game like "1. h4 e5 2. d4 exd4 3. Qxd4 Nc6 4. ..."
I will have this output:
position startpos moves
go movetime 500
bestmove d2d4 ponder (none)
position startpos moves h2h4
go movetime 500
bestmove d7d5 ponder (none)
position startpos moves h2h4 e7e5
go movetime 500
info depth 1 seldepth 1 score cp 20 nodes 82 nps 166 time 493 multipv 1 pv b1c3
info depth 2 seldepth 2 score cp -32 nodes 293 nps 593 time 494 multipv 1 pv b1c3 b8c6
info depth 3 seldepth 3 score cp 20 nodes 468 nps 947 time 494 multipv 1 pv b1c3 b8c6 g1f3
info depth 4 seldepth 4 score cp -24 nodes 826 nps 1652 time 500 multipv 1 pv b1c3 b8c6 g1f3 d7d5
info depth 5 seldepth 5 score cp -4 nodes 1518 nps 2599 time 584 multipv 1 pv b1c3 b8c6 g1f3 g8f6 d2d4
bestmove b1c3 ponder b8c6
position startpos moves h2h4 e7e5 d2d4
go movetime 500
info depth 1 seldepth 1 score cp 64 nodes 53 nps 53000 time 1 multipv 1 pv e5d4 d1d4 b8c6
info depth 2 seldepth 2 score cp 52 nodes 208 nps 208000 time 1 multipv 1 pv e5d4 d1d4 b8c6 d4e4 g8e7
info depth 3 seldepth 4 score cp 32 nodes 717 nps 358500 time 2 multipv 1 pv e5d4 c2c3 d4c3 b1c3
info depth 4 seldepth 4 score cp 32 nodes 1079 nps 67437 time 16 multipv 1 pv e5d4 c2c3 d4c3 b1c3
info depth 5 seldepth 6 score cp 40 nodes 2281 nps 25344 time 90 multipv 1 pv e5d4 g1f3 c7c5 c2c3 d8a5
info depth 6 seldepth 7 score cp 20 nodes 6237 nps 24081 time 259 multipv 1 pv e5d4 g1f3 g8f6 c2c3 b8c6 c3d4
bestmove e5d4 ponder g1f3
For each move I get the engine "bestmove", so I can tell if there was a better move.
Also I gather the cp and mate scores from the *last info line*.
With the previous example, for the last move I will have {playermove: e5d4, bestmove: e5d4, cp: 20, mate: null}
I'm not sure that's the correct way to go. Especially I'm not sure whether the "cp" represents the state before or after the player moves e5d4.
And I'm also unsure how to get the score delta. I'd like to be able, for each move, to tell "Hey, that move sucks, you lose x cp" or something along this line.
What do you think, am I going the right way? Can you suggest improvements?
I'd like to get your advice on the best way to communicate with stockfish (or any UCI engine I suppose).
Actually for each move, I set the previous position and run the go command.
For instance, for a game like "1. h4 e5 2. d4 exd4 3. Qxd4 Nc6 4. ..."
I will have this output:
position startpos moves
go movetime 500
bestmove d2d4 ponder (none)
position startpos moves h2h4
go movetime 500
bestmove d7d5 ponder (none)
position startpos moves h2h4 e7e5
go movetime 500
info depth 1 seldepth 1 score cp 20 nodes 82 nps 166 time 493 multipv 1 pv b1c3
info depth 2 seldepth 2 score cp -32 nodes 293 nps 593 time 494 multipv 1 pv b1c3 b8c6
info depth 3 seldepth 3 score cp 20 nodes 468 nps 947 time 494 multipv 1 pv b1c3 b8c6 g1f3
info depth 4 seldepth 4 score cp -24 nodes 826 nps 1652 time 500 multipv 1 pv b1c3 b8c6 g1f3 d7d5
info depth 5 seldepth 5 score cp -4 nodes 1518 nps 2599 time 584 multipv 1 pv b1c3 b8c6 g1f3 g8f6 d2d4
bestmove b1c3 ponder b8c6
position startpos moves h2h4 e7e5 d2d4
go movetime 500
info depth 1 seldepth 1 score cp 64 nodes 53 nps 53000 time 1 multipv 1 pv e5d4 d1d4 b8c6
info depth 2 seldepth 2 score cp 52 nodes 208 nps 208000 time 1 multipv 1 pv e5d4 d1d4 b8c6 d4e4 g8e7
info depth 3 seldepth 4 score cp 32 nodes 717 nps 358500 time 2 multipv 1 pv e5d4 c2c3 d4c3 b1c3
info depth 4 seldepth 4 score cp 32 nodes 1079 nps 67437 time 16 multipv 1 pv e5d4 c2c3 d4c3 b1c3
info depth 5 seldepth 6 score cp 40 nodes 2281 nps 25344 time 90 multipv 1 pv e5d4 g1f3 c7c5 c2c3 d8a5
info depth 6 seldepth 7 score cp 20 nodes 6237 nps 24081 time 259 multipv 1 pv e5d4 g1f3 g8f6 c2c3 b8c6 c3d4
bestmove e5d4 ponder g1f3
For each move I get the engine "bestmove", so I can tell if there was a better move.
Also I gather the cp and mate scores from the *last info line*.
With the previous example, for the last move I will have {playermove: e5d4, bestmove: e5d4, cp: 20, mate: null}
I'm not sure that's the correct way to go. Especially I'm not sure whether the "cp" represents the state before or after the player moves e5d4.
And I'm also unsure how to get the score delta. I'd like to be able, for each move, to tell "Hey, that move sucks, you lose x cp" or something along this line.
What do you think, am I going the right way? Can you suggest improvements?