From 92fe6b6f4cf081c12d00ad4feba2868af491baf1 Mon Sep 17 00:00:00 2001 From: dav1312 <63931154+dav1312@users.noreply.github.com> Date: Sat, 6 Jun 2026 10:13:46 +0200 Subject: [PATCH] Simplify RankAttacks initialization Simplify by replacing the manual ray-casting loop with a single call to the canonical sliding_attack() helper. closes https://github.com/official-stockfish/Stockfish/pull/6869 No functional change --- src/attacks.cpp | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/src/attacks.cpp b/src/attacks.cpp index 6a35dc548..df0f81aa0 100644 --- a/src/attacks.cpp +++ b/src/attacks.cpp @@ -80,22 +80,7 @@ constexpr auto RankAttacks = []() { std::array, FILE_NB> table{}; for (int file = 0; file < 8; ++file) for (int occ = 0; occ < 256; ++occ) - { - uint8_t attacks = 0; - for (int f = file + 1; f <= 7; ++f) - { - attacks |= uint8_t(1 << f); - if (occ & (1 << f)) - break; - } - for (int f = file - 1; f >= 0; --f) - { - attacks |= uint8_t(1 << f); - if (occ & (1 << f)) - break; - } - table[file][occ] = attacks; - } + table[file][occ] = uint8_t(sliding_attack(ROOK, Square(file), occ)); return table; }();