Small improve for Blockers and Beyond Bitboard

Discussion of chess software programming and technical issues.

Moderators: hgm, Harvey Williamson, bob

Forum rules
This textbox is used to restore diagrams posted with the [d] tag before the upgrade.
Post Reply
tomitank
Posts: 184
Joined: Sat Mar 04, 2017 11:24 am
Location: Hungary

Small improve for Blockers and Beyond Bitboard

Post by tomitank » Sun Jun 10, 2018 3:23 pm

Hi all!

The origional code in Senpai:

Code: Select all

static Bit piece_attacks(Square from, Bit tos, Bit pieces) {

   for (Bit b = tos & Blocker[from] & pieces; b != 0; b = rest(b)) {
      Square to = first(b);
      tos &= ~Beyond[from][to];
   }

   return tos;
}
If all the attacks disappear (eg.: after first nearest blocker), you are still search!

My idea (Check always the rest attacks):

Code: Select all

static Bit piece_attacks(Square from, Bit tos, Bit pieces) {

   for (Bit b = tos & Blocker[from] & pieces; b != 0; b = rest(b) & tos) {
      Square to = first(b);
      tos &= ~Beyond[from][to];
   }

   return tos;
}
It does not always help but more than never. Depends on the direction of the search.

- Tamás

Post Reply