mirror of
https://github.com/official-stockfish/Stockfish.git
synced 2026-07-22 12:47:08 +00:00
Optimize attacks
STC: https://tests.stockfishchess.org/tests/view/6a57f12c5529b8472df80e2a LLR: 2.95 (-2.94,2.94) <0.00,2.00> Total: 85856 W: 22400 L: 22037 D: 41419 Ptnml(0-2): 153, 8999, 24290, 9304, 182 closes https://github.com/official-stockfish/Stockfish/pull/6983 No functional change
This commit is contained in:
committed by
Joost VandeVondele
parent
b4ea9205a6
commit
d70dec7d6f
+30
-4
@@ -22,6 +22,7 @@
|
||||
#include <cassert>
|
||||
#include <array>
|
||||
#include <initializer_list>
|
||||
#include <utility>
|
||||
|
||||
#include "types.h"
|
||||
#include "bitboard.h"
|
||||
@@ -135,7 +136,9 @@ struct alignas(32) DualMagic {
|
||||
}
|
||||
};
|
||||
|
||||
const DualMagic& dual_magic(Square s);
|
||||
extern DualMagic DualMagics[SQUARE_NB];
|
||||
|
||||
inline const DualMagic& dual_magic(Square s) { return DualMagics[s]; }
|
||||
|
||||
#else
|
||||
// Magic holds all magic bitboards relevant data for a single square
|
||||
@@ -164,9 +167,24 @@ const Magic& magic(Square s, PieceType pt);
|
||||
|
||||
#endif
|
||||
|
||||
Bitboard line_bb(Square s1, Square s2);
|
||||
Bitboard between_bb(Square s1, Square s2);
|
||||
Bitboard ray_pass_bb(Square s1, Square s2);
|
||||
extern Bitboard LineBB[SQUARE_NB][SQUARE_NB];
|
||||
extern Bitboard BetweenBB[SQUARE_NB][SQUARE_NB];
|
||||
extern Bitboard RayPassBB[SQUARE_NB][SQUARE_NB];
|
||||
|
||||
inline Bitboard line_bb(Square s1, Square s2) {
|
||||
assert(is_ok(s1) && is_ok(s2));
|
||||
return LineBB[s1][s2];
|
||||
}
|
||||
|
||||
inline Bitboard between_bb(Square s1, Square s2) {
|
||||
assert(is_ok(s1) && is_ok(s2));
|
||||
return BetweenBB[s1][s2];
|
||||
}
|
||||
|
||||
inline Bitboard ray_pass_bb(Square s1, Square s2) {
|
||||
assert(is_ok(s1) && is_ok(s2));
|
||||
return RayPassBB[s1][s2];
|
||||
}
|
||||
|
||||
// Returns the bitboard of target square for the given step
|
||||
// from the given square. If the step is off the board, returns empty bitboard.
|
||||
@@ -304,6 +322,14 @@ inline Bitboard attacks_bb(Square s, Bitboard occupied) {
|
||||
#endif
|
||||
}
|
||||
|
||||
inline std::pair<Bitboard, Bitboard> both_attacks_bb(Square s, Bitboard occupied) {
|
||||
#ifdef USE_DUAL_HYPERBOLA_QUINT
|
||||
return dual_magic(s).both_attacks_bb(occupied);
|
||||
#else
|
||||
return {attacks_bb<BISHOP>(s, occupied), attacks_bb<ROOK>(s, occupied)};
|
||||
#endif
|
||||
}
|
||||
|
||||
// Returns the attacks by the given piece
|
||||
// assuming the board is occupied according to the passed Bitboard.
|
||||
// Sliding piece attacks do not continue past an occupied square.
|
||||
|
||||
Reference in New Issue
Block a user