Answers.Body: <p>The uci protocol does not maintain the stalemate state of the position. However the engine can send this information via the <code>info string</code> command.</p>
  <pre><code>info string This position is stalemate.
  </code></pre>
  <p>If this engine is run in the gui, the gui may display <code>This position is stalemate.</code> to the user.</p>
  <p>It is not safe to consider <code>&quot;info depth 0 score cp 0&quot;</code> as stalemate. It can be from 3-fold repetition, fifty-move draw rule or insufficient mating material.</p>
  <p>The <code>&quot;bestmove (none)&quot;</code> is not according to uci protocol. The correct message should be sent as:</p>
  <pre><code>bestmove 0000
  </code></pre>
  <p>I tried to <a href="https://github.com/fsmosca/UCIChessEngineProtocol" rel="nofollow noreferrer">maintain the uci protocol</a> in github repository, to improve and clarify it.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-01-09T09:11:10.837Z
Answers.Text: Thank you, Ferdy. The bestmove (none) is what I am getting from Stockfish, so it is up to them to possibly change it.
  
  Just for my understanding: 1) Can I request the info string command somehow or will the engine automatically provide it (as I understand it only in debug mode)?
  
  2) If I see stalemate, 3-fold repetition, fifty-move draw rule, it seems that these are all draws, correct? 
  
  3) Getting an equal position assessment at depth 0 strikes me as rather odd. When would a chess engine assess a none-draw position like this?
Answers.UserDisplayName: Mercutio1243
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-01-10T06:06:32.497Z
Answers.Text: On "bestmove (none)", it is up to them to change it. 1) The info string command depends on the engine authors. It has to be implemented in the engine. 2) Yes
Answers.UserDisplayName: ferdy
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-01-08T21:57:49.640Z
Answers.LastActivityDate: 2024-01-10T06:10:36.543Z
Answers.LastEditDate: 2024-01-10T06:10:36.543Z
Answers.UserDisplayName: ferdy
Body: <p>I am using Stockfish 15.1 via UCI to analyse chess positions.</p>
  <p>Unfortunately, the UCI documentation is a bit silent on how stalemates should be handled. As shown in the example below, it seems that stalemate results in the response &quot;info depth 0 score cp 0&quot;.</p>
  <p>Can I safely assume that this output only occurs in case the position is in stalemate? (E.g., my understanding is that positions that are mate will be answered by &quot;mate 0&quot;).</p>
  <p>Could a stalemate position provoke any other response from the engine than &quot;info depth 0 score cp 0&quot;?</p>
  <pre><code>Starting Stockfish analysis on fen 8/4R3/PB5k/6R1/7P/5B2/5PP1/7K b - - 0 45
  Stockfish output: info string NNUE evaluation using nn-ad9b42354671.nnue enabled
  Stockfish output: info depth 0 score cp 0
  Stockfish output: bestmove (none)
  </code></pre>
  <p>Bonus question: Is there any other case where the engine responds with &quot;bestmove (none)&quot;? When would this be the case?</p>
  
Tags: <engines><uci>
Title: Identifying stalemate in chess engine output (UCI)
ThreadText: # Identifying stalemate in chess engine output (UCI)
  
  (Asked by: username_0 on 2024-01-05)
  
  I am using Stockfish 15.1 via UCI to analyse chess positions.
  Unfortunately, the UCI documentation is a bit silent on how stalemates should be handled. As shown in the example below, it seems that stalemate results in the response "info depth 0 score cp 0".
  Can I safely assume that this output only occurs in case the position is in stalemate? (E.g., my understanding is that positions that are mate will be answered by "mate 0").
  Could a stalemate position provoke any other response from the engine than "info depth 0 score cp 0"?
  Starting Stockfish analysis on fen 8/4R3/PB5k/6R1/7P/5B2/5PP1/7K b - - 0 45
  Stockfish output: info string NNUE evaluation using nn-ad9b42354671.nnue enabled
  Stockfish output: info depth 0 score cp 0
  Stockfish output: bestmove (none)
  
  Bonus question: Is there any other case where the engine responds with "bestmove (none)"? When would this be the case?
  
  **Tags:** engines, uci
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2024-01-08. Score: 1 | Accepted answer
  
  The uci protocol does not maintain the stalemate state of the position. However the engine can send this information via the info string command.
  info string This position is stalemate.
  
  If this engine is run in the gui, the gui may display This position is stalemate. to the user.
  It is not safe to consider "info depth 0 score cp 0" as stalemate. It can be from 3-fold repetition, fifty-move draw rule or insufficient mating material.
  The "bestmove (none)" is not according to uci protocol. The correct message should be sent as:
  bestmove 0000
  
  I tried to maintain the uci protocol in github repository, to improve and clarify it.
  
  > **Comments:**
  > **username_0**: Thank you, Ferdy. The bestmove (none) is what I am getting from Stockfish, so it is up to them to possibly change it.  Just for my understanding: 1) Can I request the info string command somehow or will the engine automatically provide it (as I understand it only in debug mode)?  2) If I see stalemate, 3-fold repetition, fifty-move draw rule, it seems that these are all draws, correct?   3) Getting an equal position assessment at depth 0 strikes me as rather odd. When would a chess engine assess a none-draw position like this?  
  > **username_1**: On "bestmove (none)", it is up to them to change it. 1) The info string command depends on the engine authors. It has to be implemented in the engine. 2) Yes  
  
  ---
  
  