official-stockfish / Stockfish

A free and strong UCI chess engine
https://stockfishchess.org/
GNU General Public License v3.0
11.7k stars 2.29k forks source link

Chess960 FEN parsing #356

Closed matthewlai closed 9 years ago

matthewlai commented 9 years ago

In position.cpp, void Position::set(const string& fenStr, bool isChess960, Thread* th):

There is no checking for colour of the rook when finding rsq for castling.

for (rsq = relative_square(c, SQ_A1); type_of(piece_on(rsq)) != ROOK; ++rsq) {}

In some positions, it may pick up an opponent rook: 4k3/pppppppp/8/8/8/8/PPPPPPPP/rR2K3 w Q - 0 1

mcostalba commented 9 years ago

Bug confirmed. Pull request open:

https://github.com/official-stockfish/Stockfish/pull/357

Thanks for reporting: very old and subtle bug, good catch!

matthewlai commented 9 years ago

Thanks!

mcostalba commented 9 years ago

Fix applied.