I've been developing my chess engine for a few weeks now, and it performs 60% as fast as Stockfish on perft tests (about 43 mn/s on my laptop). For a while I've noticed an opportunity to speed up my move generation by eliminating redundancies in calculating move info bitboards (mainly can/can't capture bitboards). I am currently doing the following:
Code: Select all
if (turn == WHITE) {
CANT_CAPTURE = bitboard[WP] | bitboard[WN] | bitboard[WB] | bitboard[WR] |
bitboard[WQ] | bitboard[WK] | bitboard[BK];
CAN_CAPTURE = bitboard[BP] | bitboard[BN] | bitboard[BB] | bitboard[BR] |
bitboard[BQ];
}
else {
CANT_CAPTURE = bitboard[BP] | bitboard[BN] | bitboard[BB] | bitboard[BR] |
bitboard[BQ] | bitboard[BK] | bitboard[WK];
CAN_CAPTURE = bitboard[WP] | bitboard[WN] | bitboard[WB] | bitboard[WR] |
bitboard[WQ];
}
1) calculate kings bitboard (bitboard[WK] | bitboard[BK]) and the moved bitboard ((1L << from) | (1L << to))
2) swap the current CAN_CAPTURE and CANT_CAPTURE bitboards
3) XOR the kings bitboard into both CAN_CAPTURE and CANT_CAPTURE
4) XOR the moved bitboard into CANT_CAPTURE
I've thought that perhaps this was failing only on special moves, but this approach doesn't work even when I use the original (long) way of calculating these bitboards only on special moves. What could be wrong?
Also - how good is 60% perft speed from SF and qperft?
Have a wonderful rest of your day!!
- Ori
