lichess-org / compression

Chess clock and move compression algorithms for lichess.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

pin and skewer

puspraj-india opened this issue · comments

Flag of pin and skewer should be not checked if no bishops , no rooks and no Queen are present

Thanks for the suggestion. 95%+ of positions have a bishop, rook, or queen so I assume adding extra conditions would degrade performance:

private long sliderBlockers(int king) {
long snipers = them() & (
Bitboard.rookAttacks(king, 0) & (this.rooks ^ this.queens) |
Bitboard.bishopAttacks(king, 0) & (this.bishops ^ this.queens));
long blockers = 0;
while (snipers != 0) {
int sniper = Bitboard.lsb(snipers);
long between = Bitboard.BETWEEN[king][sniper] & this.occupied;
if (!Bitboard.moreThanOne(between)) blockers |= between;
snipers &= snipers - 1;
}
return blockers;
}

Perhaps short-circuit evaluation might improve performance, for example:

(this.rooks ^ this.queens) & Bitboard.rookAttacks(king, 0)

EDIT: Technically, short-circuit evaluation doesn't work, but maybe there's a more complex way to make this work: https://stackoverflow.com/a/8759917

On my PC, the proposed change is a negative 20% speedup.