mirror of
https://github.com/sockspls/badfish
synced 2025-04-30 00:33:09 +00:00
Simplify sliding_attacks()
Easy, almost trivial simplification, I don't understand how I missed this before !! No functional change. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
parent
e7413417ce
commit
fe26967ea0
2 changed files with 6 additions and 9 deletions
|
@ -252,7 +252,7 @@ void init_bitboards() {
|
|||
|
||||
namespace {
|
||||
|
||||
Bitboard sliding_attacks(Square sq, Bitboard occupied, Square delta[], Bitboard excluded) {
|
||||
Bitboard sliding_attacks(Square sq, Bitboard occupied, Square delta[]) {
|
||||
|
||||
Bitboard attacks = 0;
|
||||
|
||||
|
@ -260,9 +260,7 @@ namespace {
|
|||
{
|
||||
Square s = sq + delta[i];
|
||||
|
||||
while ( square_is_ok(s)
|
||||
&& square_distance(s, s - delta[i]) == 1
|
||||
&& !bit_is_set(excluded, s))
|
||||
while (square_is_ok(s) && square_distance(s, s - delta[i]) == 1)
|
||||
{
|
||||
set_bit(&attacks, s);
|
||||
|
||||
|
@ -302,22 +300,22 @@ namespace {
|
|||
const int MagicBoosters[][8] = { { 3191, 2184, 1310, 3618, 2091, 1308, 2452, 3996 },
|
||||
{ 1059, 3608, 605, 3234, 3326, 38, 2029, 3043 } };
|
||||
RKISS rk;
|
||||
Bitboard occupancy[4096], reference[4096], excluded, b;
|
||||
Bitboard occupancy[4096], reference[4096], edges, b;
|
||||
int key, maxKey, index, booster, offset = 0;
|
||||
|
||||
for (Square s = SQ_A1; s <= SQ_H8; s++)
|
||||
{
|
||||
excluded = ((Rank1BB | Rank8BB) & ~rank_bb(s)) | ((FileABB | FileHBB) & ~file_bb(s));
|
||||
edges = ((Rank1BB | Rank8BB) & ~rank_bb(s)) | ((FileABB | FileHBB) & ~file_bb(s));
|
||||
|
||||
attack[s] = &attTable[offset];
|
||||
mask[s] = sliding_attacks(s, EmptyBoardBB, delta, excluded);
|
||||
mask[s] = sliding_attacks(s, EmptyBoardBB, delta) & ~edges;
|
||||
shift[s] = (CpuIs64Bit ? 64 : 32) - count_1s<CNT32_MAX15>(mask[s]);
|
||||
|
||||
// Use Carry-Rippler trick to enumerate all subsets of mask[s]
|
||||
b = maxKey = 0;
|
||||
do {
|
||||
occupancy[maxKey] = b;
|
||||
reference[maxKey++] = sliding_attacks(s, b, delta, EmptyBoardBB);
|
||||
reference[maxKey++] = sliding_attacks(s, b, delta);
|
||||
b = (b - mask[s]) & mask[s];
|
||||
} while (b);
|
||||
|
||||
|
|
|
@ -1649,7 +1649,6 @@ split_point_start: // At split points actual search starts from here
|
|||
|
||||
assert(move_is_ok(m));
|
||||
assert(threat && move_is_ok(threat));
|
||||
assert(!pos.move_gives_check(m));
|
||||
assert(!pos.move_is_capture(m) && !move_is_promotion(m));
|
||||
assert(!pos.move_is_passed_pawn_push(m));
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue