Closed daniloarcidiacono closed 3 years ago
the fen is illegal as both kings are in check, which can't happen in chess?
Woops... sorry... however by moving the white king one square to the left the position should become legal... I'll edit the post
Come to think of it, it's a slight inaccuracy in the pinners bitmask but, depending on how pinners are used in the
rest of the code, that inaccuracy may not (and probably does not) cause any problems. Adding complexity to handle this
scenario is probably not worth the loss in speed, since if I'm not mistaken slider_blockers()
is called a lot.
Hello, I think I've found a problem with the
slider_blockers()
routine. Consider the position 8/8/8/8/8/Q2r1R1k/8/2K5 b - - 0 1 (view on lichess).According to the following test code (I've just removed the
UCI::loop()
call inmain()
):Stockfish thinks that the black rook on D3 is pinned to the black king on H3 by the white queen on A3.
Of course, this is not true, since it's actually the white rook on F3 that is checking the king, so the black rook can freely move.
By looking at the code we have:
and
which, for our actual parameters, would "translate" to
_Position::sliderblockers() returns a bitboard of all the pieces (both colors) that are blocking attacks on the black king square from the white pieces. A piece blocks a slider if removing that piece from the board would result in a position where the black king square is attacked.
One could argue that if we remove the black rook the king is still attacked, but not by the queen! Is this the intended behaviour or indeed a problem? If so, I think it can be solved by doing another "round" when calculating the snipers:
What do you think?
Edit: forgot to add that I've tested this on the master branch a few hours ago. Edit 2: Fixed the FEN which was illegal