lichess-org / compression

Chess clock and move compression algorithms for lichess.org
GNU Affero General Public License v3.0
109 stars 16 forks source link

pin and skewer #5

Closed puspraj-india closed 5 years ago

puspraj-india commented 5 years ago

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

ddugovic commented 5 years ago

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

https://github.com/lichess-org/compression/blob/25516fb9bce0c0a39ca68cde2e6eaeebc12823d3/src/main/java/game/Board.java#L222-L237

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

ddugovic commented 5 years ago

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