2

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?

4 Answers 4

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?

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

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.

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 user1583209 and sjb-2812. 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.

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.