bugfix: bishop could pin pieces on a horizontal or vertical line
This commit is contained in:
1 parent
72b327c3ff
commit
8a18d45d4a
2 files changed
+14
-4
No files matched your search
+1
-1
@@ -9,7 +9,7 @@ int main() {
|
||||
initSliderAttacks();
|
||||
|
||||
Board board;
|
||||
board.SetByFen("r3k2r/p1ppqpb1/bn2pnp1/3PN3/1p2P3/2N2Q1p/PPPBBPPP/R3K2R w KQkq - 0 1");
|
||||
board.SetByFen("r4rk1/1pp1qppp/p1np1n2/2b1p1B1/2B1P1b1/P1NP1N2/1PP1QPPP/R4RK1 w - - 0 10");
|
||||
Perft(board, 1);
|
||||
|
||||
return 0;
|
||||
|
||||
+13
-3
@@ -372,9 +372,16 @@ static Bitboard GetPinningRay(Board &board, int square, int direction) {
|
||||
int attackerColor = board.GetPieceColor(square);
|
||||
|
||||
if (attackerColor != board.sideToMove) {
|
||||
if (attackerType == Rook|| attackerType == Bishop
|
||||
|| attackerType == Queen) {
|
||||
return ray;
|
||||
// Pinned by rook or queen
|
||||
if (abs(direction) == 1 || abs(direction) == 8) {
|
||||
if (attackerType == Rook || attackerType == Queen) {
|
||||
return ray;
|
||||
}
|
||||
// Pinned by bishop or queen
|
||||
} else if (direction % 2 != 0) {
|
||||
if (attackerType == Bishop || attackerType == Queen) {
|
||||
return ray;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -460,6 +467,9 @@ static void GenPawnMoves(Board &board, bool color) {
|
||||
|
||||
if (IsPinned(board, square)) {
|
||||
int kingSquare = (board.colors[color] & board.pieces[King]).getLS1BIndex();
|
||||
if (square == g2) {
|
||||
GetPinningRay(board, square, -GetDirection(square, kingSquare)).PrintBoard();
|
||||
}
|
||||
int directionToKing = GetDirection(square, kingSquare);
|
||||
|
||||
Bitboard pinningRay = GetPinningRay(board, square - directionToKing, -directionToKing);
|
||||
|
||||
Reference in new issue
Block a user