7

Is vanilla Stockfish perfectly capable of understanding Chess960 games (including the way castling works), or do you need to use something like Fairy-Stockfish to get the best results?

It seems like normal Stockfish should work, but I want to be sure.

3
  • 1
    normal stockfish knows understand Chess960 but those engine don't know about castling. They don't castle in Chess960. IIRC Dec 29, 2022 at 14:31
  • There is a lot of important discussion in the comments to Allure's answer. Jan 3 at 2:28
  • TLDR is as follows: There are some edge cases and this means that Stockfish may not evaluate a position correctly. Feb 13 at 7:05

2 Answers 2

4

Normal Stockfish can handle FRC positions. You just need to tell it that it is a FRC game - which shouldn't be a problem since it should be apparent from the FEN you give it.

As can be seen from the code, normal Stockfish has a "isChess960" boolean which, as its name implies, tells the engine if the position is a Chess960 position and calls the relevant functions if true.

12
  • How can it tell it is chess960 from the FEN?
    – qwr
    Dec 29, 2022 at 13:34
  • 1
    @qwr the FEN gives castling rights. If you tell Stockfish it can castle kingside, it will know O-O is legal even if the king and rook aren't currently on e1 and h1.
    – Allure
    Dec 29, 2022 at 13:35
  • 1
    I see, so Stockfish knows how to castle chess960 style by default? That would be good to add to you answer.
    – qwr
    Dec 29, 2022 at 13:54
  • Do you have further code links showing how Stockfish uses that flag to successfully castle when the king and rook are on non-standard squares? Because I set up positions where I had told Stockfish via the fen that both sides had full castling rights and where the best move was clearly castling (only way to avoid material loss) and Stockfish resolutely refused to even consider the move. Presence of the flag indicates intent but not actual implementation.
    – Brian Towers
    Dec 29, 2022 at 16:01
  • 1
    @BrianTowers are you sure your FEN is right? Try this one, White has only one winning move, and Stockfish finds the mate in 1. 2qqq3/2qqq3/8/8/8/1Q6/PPPPPPP1/1k3K1R w K - 0 1
    – Allure
    Dec 29, 2022 at 16:13
6

Vanilla Stockfish uses the castling rule given in article 3.8.2 of the FIDE Laws of Chess. In that rule the king is always on the e file and the rook either on the a file or h file.

In Chess960 the files the rooks and kings can be on are different. If they are on the "correct" files then castling will work. If not then castling will not work.

3
  • 3
    Oh, I get it. Because Stockfish doesn't know castling is possible. Dec 28, 2022 at 23:04
  • It seems that just checking the position of king and rooks would not be sufficient even in vanilla chess, as the pieces could have been moved and then moved back to their starting positions, which should rule out castling, but if you're only checking based on current position and not looking at all the previous moves, you might miss that. Dec 29, 2022 at 14:46
  • See Allure's answer and its comments. It would appear that vanilla Stockfish can do Chess960 so long as the castling rights are included in the FEN. Dec 30, 2022 at 18:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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