Small improve for Blockers and Beyond Bitboard

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

tomitank
Posts: 276
Joined: Sat Mar 04, 2017 12:24 pm
Location: Hungary

Small improve for Blockers and Beyond Bitboard

Post 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