Answers.Body: <p>You have a bug in your script. Try it on Stockfish yourself:</p>
  
  <pre><code>position fen 1rbq1rk1/b4p2/p2p3p/3Bp3/P3P3/2P4P/R2Q1PP1/4K2R w - - 0 1
  go movetime 1000
  </code></pre>
  
  <blockquote>
    <p>bestmove d2h6 ponder c8e6</p>
  </blockquote>
  
  <p>How many nodes have you given Stockfish to think?</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-12-04T00:43:21.177Z
Answers.LastActivityDate: 2018-12-04T00:43:21.177Z
Answers.UserDisplayName: SmallChess
Answers.Body: <p>In addition, your made-up FEN may be a part of it. As it stands, you have described a position where castling kingside is not a legal move, so perhaps the program wants to develop the king's rook. </p>
  
  <p>Have a look at the <a href="https://en.wikipedia.org/w/index.php?title=Forsyth%E2%80%93Edwards_Notation&amp;oldid=954773673" rel="nofollow noreferrer">Wikipedia page on FEN</a> or similar resources to see how you can include castling.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-06-04T20:13:08.493Z
Answers.LastActivityDate: 2020-06-05T11:25:58.550Z
Answers.LastEditDate: 2020-06-05T11:25:58.550Z
Answers.UserDisplayName: sjb-2812
Answers.Body: <p>Difficult to answer, not seeing your python script.</p>
  
  <p>The best move in this position is Qxh6. Important, it comes with the idea of perpetual check via Qg6+ Qh6+, i.e. a draw. White is down a piece for nothing, so this perpetual/draw is the best white can hope to achieve here.</p>
  
  <p>Qxh6 is not particularly difficult to find for an engine or even a human, but stockfish might miss it, if it is severely crippled. </p>
  
  <p>The most obvious reply to Qxh6 is Rb1+ winning the rook on h1, which could scare engines and humans if they don't look ahead more than a move or two. So in order to find Qxh6, your stockfish would need to:</p>
  
  <ul>
  <li>look ahead at least 6 moves</li>
  <li>be aware of the possibility of perpetual check</li>
  </ul>
  
  <p>If any of these is not satisfied, it would try to find the second best move. In this sense, Ke2 avoids the skewer with Rb1+ and activates the rook on h1, so is a decent move (in an otherwise lost position).</p>
  
  <p>If in the initial position whie is alllowed to castle, your FEN is wrong. You would need to add a capital K after the "w" in order to indicate that white can castle kingside. Ignoring the perpetual with Qxh6, the best move would then be 0-0.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-06-06T13:06:26.673Z
Answers.LastActivityDate: 2020-06-06T13:06:26.673Z
Answers.UserDisplayName: user1583209
Answers.Body: <p>The made up part of the FEN (<code>-- - 0 30</code>) says, in order:</p>
  <ol>
  <li>Neither side has any castling rights. This is the only part relevant to this question and has been covered by <a href="https://chess.stackexchange.com/a/29889/25131">user1583209</a> and <a href="https://chess.stackexchange.com/a/29864/25131">sjb-2812</a>. Note that it should be a single hyphen.</li>
  <li>There are no en passant rights. The arrangement of the pieces already shows this, so it must be irrelevant.</li>
  <li>There have been 0 moves since the last capture or pawn move. This seems to be the normal value used for FEN, unless there is a specific reason to do otherwise. It is used for the 50 move rule. I can’t see how it would be relevant here.</li>
  <li>The current move is move 30. The normal value is 1, but, with no time control and no earlier moves to refer to, it is meaningless.</li>
  </ol>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-11-06T12:05:15.140Z
Answers.LastActivityDate: 2020-11-06T12:05:15.140Z
Answers.UserDisplayName: Brian Drake
Body: <p>When I ask for the best move for this FEN:</p>
  
  <blockquote>
    <p>1rbq1rk1/b4p2/p2p3p/3Bp3/P3P3/2P4P/R2Q1PP1/4K2R w -- - 0 30</p>
  </blockquote>
  
  <pre><code>[FEN "1rbq1rk1/b4p2/p2p3p/3Bp3/P3P3/2P4P/R2Q1PP1/4K2R w - - 0 30"]
  </code></pre>
  
  <p>Stockfish (via Python) replies</p>
  
  <blockquote>
    <p>e1e2</p>
  </blockquote>
  
  <p>which is a losing move, since there's a free pawn on the 6th rank that the white queen can take. Instead, Stockfish wants me to move the white king for some bizarre reason.</p>
  
  <p>Why does it do this? </p>
  
  <p>I suspect it may have something to do with the ending to the FEN, namely the part where it says</p>
  
  <blockquote>
    <p>-- - 0 30</p>
  </blockquote>
  
  <p>I wrote the first part of the FEN by hand, and it is correct, but I didn't know what move it was or how to describe castling, so I just made up the "-- - 0 30" part. Is that the reason Stockfish gives this confusing answer?</p>
  
Tags: <stockfish>
Title: Why is Stockfish giving me this weird move?
ThreadText: # Why is Stockfish giving me this weird move?
  
  (Asked by: username_0 on 2018-12-04)
  
  When I ask for the best move for this FEN:
  
  1rbq1rk1/b4p2/p2p3p/3Bp3/P3P3/2P4P/R2Q1PP1/4K2R w -- - 0 30
  
  [FEN "1rbq1rk1/b4p2/p2p3p/3Bp3/P3P3/2P4P/R2Q1PP1/4K2R w - - 0 30"]
  
  Stockfish (via Python) replies
  
  e1e2
  
  which is a losing move, since there's a free pawn on the 6th rank that the white queen can take. Instead, Stockfish wants me to move the white king for some bizarre reason.
  Why does it do this? 
  I suspect it may have something to do with the ending to the FEN, namely the part where it says
  
  -- - 0 30
  
  I wrote the first part of the FEN by hand, and it is correct, but I didn't know what move it was or how to describe castling, so I just made up the "-- - 0 30" part. Is that the reason Stockfish gives this confusing answer?
  
  **Tags:** stockfish
  
  
  ---
  
  ## 4 answers
  
  ### Answer by username_1 on 2018-12-04. Score: 7
  
  You have a bug in your script. Try it on Stockfish yourself:
  position fen 1rbq1rk1/b4p2/p2p3p/3Bp3/P3P3/2P4P/R2Q1PP1/4K2R w - - 0 1
  go movetime 1000
  
  
  bestmove d2h6 ponder c8e6
  
  How many nodes have you given Stockfish to think?
  
  
  ---
  
  ### Answer by username_2 on 2020-06-04. Score: 5
  
  In addition, your made-up FEN may be a part of it. As it stands, you have described a position where castling kingside is not a legal move, so perhaps the program wants to develop the king's rook.
  
  Have a look at the [Wikipedia page on FEN](https://en.wikipedia.org/w/index.php?title=Forsyth%E2%80%93Edwards_Notation&oldid=954773673) or similar resources to see how you can include castling.
  
  
  ---
  
  ### Answer by username_3 on 2020-06-06. Score: 4
  
  Difficult to answer, not seeing your python script.
  
  The best move in this position is Qxh6. Important, it comes with the idea of perpetual check via Qg6+ Qh6+, i.e. a draw. White is down a piece for nothing, so this perpetual/draw is the best white can hope to achieve here.
  
  Qxh6 is not particularly difficult to find for an engine or even a human, but stockfish might miss it, if it is severely crippled.
  
  The most obvious reply to Qxh6 is Rb1+ winning the rook on h1, which could scare engines and humans if they don't look ahead more than a move or two. So in order to find Qxh6, your stockfish would need to:
  
  * look ahead at least 6 moves
  * be aware of the possibility of perpetual check
  
  If any of these is not satisfied, it would try to find the second best move. In this sense, Ke2 avoids the skewer with Rb1+ and activates the rook on h1, so is a decent move (in an otherwise lost position).
  
  If in the initial position whie is alllowed to castle, your FEN is wrong. You would need to add a capital K after the "w" in order to indicate that white can castle kingside. Ignoring the perpetual with Qxh6, the best move would then be 0-0.
  
  
  ---
  
  ### Answer by username_4 on 2020-11-06. Score: 2
  
  The made up part of the FEN (`-- - 0 30`) says, in order:
  
  1. Neither side has any castling rights. This is the only part relevant to this question and has been covered by [username_3](https://chess.stackexchange.com/a/29889/25131) and [username_2](https://chess.stackexchange.com/a/29864/25131). Note that it should be a single hyphen.
  2. There are no en passant rights. The arrangement of the pieces already shows this, so it must be irrelevant.
  3. There have been 0 moves since the last capture or pawn move. This seems to be the normal value used for FEN, unless there is a specific reason to do otherwise. It is used for the 50 move rule. I can’t see how it would be relevant here.
  4. The current move is move 30. The normal value is 1, but, with no time control and no earlier moves to refer to, it is meaningless.
  
  
  ---
  
  