diff --git a/source/main.cpp b/source/main.cpp index d8fc1a0..7f338b9 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -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; diff --git a/source/movegen.cpp b/source/movegen.cpp index 33ae226..d6ba2cf 100644 --- a/source/movegen.cpp +++ b/source/movegen.cpp @@ -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);