Page 1 of 1

Small improve for Blockers and Beyond Bitboard

Posted: Sun Jun 10, 2018 5:23 pm
by tomitank
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