Pawn attacks by Strelka

Discussion of chess software programming and technical issues.

Moderator: Ras

Gerd Isenberg
Posts: 2251
Joined: Wed Mar 08, 2006 8:47 pm
Location: Hattingen, Germany

Pawn attacks by Strelka

Post by Gerd Isenberg »

In Strelka's eval.c following line appears twice:

Code: Select all

  mob_w = (((mob_w & 0xFFFF7F7F7F7F7F7F) << 2) | (mob_w & 0x00FEFEFEFEFEFEFE)) << 7;
I first thought about a typo - 2 instead of 9. It took me some seconds to get the parenthesis right. The constants look like disassembled from "optimized" 32-bit code ;-)

I prefer it with one dependency less:

Code: Select all

  mob_w = ((mob_w & 0x7F7F7F7F7F7F7F7F) << 9) | ((mob_w & 0xFEFEFEFEFEFEFEFE) << 7);
or to eventually share the 64-bit constant notA:

Code: Select all

  const U64 notA = C64(0xFEFEFEFEFEFEFEFE);
  mob_w = ((mob_w << 9) & notA) | ((mob_w & notA) << 7);
But likely compilers have their own opinions about pre- and post-shift masks.