4

Is it possible to perform analysis with stockfish for a given depth, but stop in case it is taking longer than a specified time?

Something like this:

go depth 17 max movetime 10000

or

setoption name MaxMovetime value 10000
...
go depth 17

2 Answers 2

3

I don't think it's possible to do it in the UCI protocol. Fortunately, it's really easy to do it yourself. For example, in my SmallFish app (http://www.smallchess.com), to save the phone's battery the app would send the "stop" signal to the engine after a minute of analysis. The command is very simple:

stop

You will just need to create a timer yourself and send the stop signal to terminate the search immediately.

1
  • Seems like it's possible after all, or has become possible since your answer was posted. See my answer.
    – Marv
    Jul 25, 2023 at 12:58
2

Yes, it is (now?) possible. If stockfish reaches the specified movetime before it reaches the specified depth, it will stop searching

PS C:\Users\Marvin\Desktop> .\stockfish-windows-x86-64.exe
Stockfish 16 by the Stockfish developers (see AUTHORS file)
go depth 100 movetime 10
             ^^^^^^^^^^^
info string NNUE evaluation using nn-5af11540bbfe.nnue enabled
info depth 1 seldepth 1 multipv 1 score cp 2 nodes 20 nps 10000 hashfull 0 tbhits 0 time 2 pv g1f3
info depth 2 seldepth 2 multipv 1 score cp 2 nodes 40 nps 20000 hashfull 0 tbhits 0 time 2 pv g1f3
info depth 3 seldepth 2 multipv 1 score cp 16 nodes 70 nps 35000 hashfull 0 tbhits 0 time 2 pv c2c3
info depth 4 seldepth 2 multipv 1 score cp 29 nodes 101 nps 50500 hashfull 0 tbhits 0 time 2 pv e2e4
info depth 5 seldepth 3 multipv 1 score cp 42 nodes 131 nps 65500 hashfull 0 tbhits 0 time 2 pv e2e4 g8f6
info depth 6 seldepth 4 multipv 1 score cp 59 nodes 489 nps 163000 hashfull 0 tbhits 0 time 3 pv g1f3 d7d5 d2d4
info depth 7 seldepth 6 multipv 1 score cp 31 nodes 1560 nps 312000 hashfull 1 tbhits 0 time 5 pv e2e4 d7d5 e4d5 d8d5 g1f3
info depth 8 seldepth 6 multipv 1 score cp 40 nodes 2105 nps 350833 hashfull 1 tbhits 0 time 6 pv e2e4 d7d5 e4d5 d8d5
info depth 9 seldepth 8 multipv 1 score cp 48 nodes 4500 nps 409090 hashfull 1 tbhits 0 time 11 pv e2e4 e7e5 g1f3 g8f6 f3e5 f6e4 d2d4 b8c6
info depth 10 seldepth 8 multipv 1 score cp 48 nodes 5254 nps 437833 hashfull 1 tbhits 0 time 12 pv e2e4 e7e5 g1f3 g8f6 f3e5 f6e4 d2d4 b8c6
                                                                                         ^^^^^^^
bestmove e2e4 ponder e7e5

The opposite also works, of course. If stockfish reaches the specified depth before it reaches the specified movetime, it will stop searching:

PS C:\Users\Marvin\Desktop> .\stockfish-windows-x86-64.exe
Stockfish 16 by the Stockfish developers (see AUTHORS file)
go depth 1 movetime 1000000
   ^^^^^^^
info string NNUE evaluation using nn-5af11540bbfe.nnue enabled
info depth 1 seldepth 1 multipv 1 score cp 2 nodes 20 nps 20000 hashfull 0 tbhits 0 time 1 pv g1f3
     ^^^^^^^
bestmove g1f3

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.