Answers.Body: <p>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 (<a href="http://www.smallchess.com" rel="nofollow">http://www.smallchess.com</a>), 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:</p>
  
  <pre><code>stop
  </code></pre>
  
  <p>You will just need to create a timer yourself and send the stop signal to terminate the search immediately.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-07-25T12:58:13.083Z
Answers.Text: Seems like it's possible after all, or has become possible since your answer was posted. See my answer.
Answers.UserDisplayName: Marv
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-11-20T02:56:42.683Z
Answers.LastActivityDate: 2015-11-20T02:56:42.683Z
Answers.UserDisplayName: SmallChess
Answers.Body: <p>Yes, it is (now?) possible. If stockfish reaches the specified <code>movetime</code> before it reaches the specified <code>depth</code>, it will stop searching</p>
  <pre><code>PS C:\Users\Marvin\Desktop&gt; .\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
  </code></pre>
  <p>The opposite also works, of course. If stockfish reaches the specified <code>depth</code> before it reaches the specified <code>movetime</code>, it will stop searching:</p>
  <pre><code>PS C:\Users\Marvin\Desktop&gt; .\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
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-07-25T12:57:11.533Z
Answers.LastActivityDate: 2023-07-25T12:57:11.533Z
Answers.UserDisplayName: Marv
Body: <p>Is it possible to perform analysis with stockfish for a given depth, but stop in case it is taking longer than a specified time?</p>
  
  <p>Something like this:</p>
  
  <p><code>go depth 17 max movetime 10000</code></p>
  
  <p>or</p>
  
  <p><code>setoption name MaxMovetime value 10000</code><br>
  ...<br>
  <code>go depth 17</code></p>
  
Tags: <engines><stockfish><uci>
Title: UCI go with depth and movetime
ThreadText: # UCI go with depth and movetime
  
  (Asked by: username_0 on 2015-11-20)
  
  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`
  
  **Tags:** engines, stockfish, uci
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2015-11-20. Score: 3 | Accepted answer
  
  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.username_1.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.
  
  > **Comments:**
  > **username_2**: Seems like it's possible after all, or has become possible since your answer was posted. See my answer.  
  
  ---
  
  ### Answer by username_2 on 2023-07-25. Score: 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
  
  ```
  
  
  ---
  
  