The core algorithm for Obstruction Difference can be improved by more than 30% runtime!
I found new minimal form for the Obstruction Difference
- so the same input masks but faster:

The very core of the change is this equivalence found by AST sifting:
Code: Select all
uint64_t msb = (1ull << 63ull) >> std::countl_zero(lower | 1); //Extract Highest Set Isolated Bit
uint64_t lsb = upper & -upper; //Extract Lowest Set Isolated Bit
uint64_t oDif = lsb * 2 - msb;
return mask & oDif;
Code: Select all
const uint64_t msb = 0x8000000000000000ull >> std::countl_zero(lower | 1);
return (mask & (upper ^ (upper - msb))); //Skip LSB and LEA calculation
https://github.com/Gigantua/Chess_Moveg ... onDiff.hpp
It would be great to update the cpw with this information: https://www.chessprogramming.org/Obstruction_Difference
Now I can see that there are Bitboard native algorithms emerging. These are algorithms that would like the source square to be passed into them in the form of (1ull << sq) and not the commonly used [0..64] sq.
The great thing about Bitboard nativity would be that enumerating set bits could skip the source square resultion - and directly pass the current bitmask.
This will improve performance of any bitboard engine that currently works in 0..64 space.

