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


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?


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?

| improve this answer | |

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 or similar resources to see how you can include castling.

| improve this answer | |

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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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