bugfix: GetPinningRay jumped through the board

This commit is contained in:
rektdie committed 2024-04-11 12:17:10 +02:00
1 parent 054129b67b
commit ae581e0f03
3 files changed
+11 -4

No files matched your search

+2 -2
View File
@@ -9,8 +9,8 @@ int main() {
initSliderAttacks();
Board board;
board.SetByFen("r4rk1/1pp1qppp/p1npBn2/2b1p1B1/4P1b1/P1NP1N2/1PP1QPPP/R4RK1 b - - 1 10");
Perft(board, 3);
board.SetByFen("rnbq1k1r/pp1Pbppp/2p5/8/2B5/8/PPP1NnPP/RNBQK2R w KQ - 1 8");
Perft(board, 2);
return 0;
}
+8 -1
View File
@@ -363,7 +363,14 @@ static Bitboard GetPinningRay(Board &board, int square, int direction) {
while (square < 64 && square >= 0) {
int currentRank = square / 8;
if (abs(currentRank - previousRank) > 1) break;
int difference = abs(currentRank - previousRank);
if ((abs(direction) == 7 || abs(direction) == 9)
&& difference != 1) {
break;
} else if (abs(direction) == 1 && difference) {
break;
}
previousRank = currentRank;
ray.SetBit(square);
+1 -1
View File
@@ -55,5 +55,5 @@ void Perft(Board &board, int depth) {
std::cout << "\nDepth: " << depth << '\n';
std::cout << "Total nodes: " << totalNodes << '\n';
std::cout << "Time took: " << elapsed_seconds << "s (";
std::cout << int(totalNodes / elapsed_seconds * 1000) << " nodes/sec)\n";
std::cout << int(totalNodes / elapsed_seconds) << " nodes/sec)\n";
}