mirror of
https://github.com/sockspls/badfish
synced 2025-05-01 01:03:09 +00:00
Fix pos.count<ALL_PIECES>()
It was never updated ! Currently it only affects evaluate_passed_pawns() and in particularly the rule to increase the bonus if we have more non-pawn pieces. We could simply use popcount() instead and avoid the little slowdown in put_piece() and remove_piece(), but this would leave a very subtle and tricky hole where people are forced to remember that pos.count<ALL_PIECES>() does not work. This is not obvious and so dangerous. Thanks to Ronald de Man for spotting this. bench: 7931424
This commit is contained in:
parent
c08e7419a0
commit
f22a63ce67
1 changed files with 2 additions and 0 deletions
|
@ -405,6 +405,7 @@ inline void Position::put_piece(Square s, Color c, PieceType pt) {
|
|||
byTypeBB[ALL_PIECES] |= s;
|
||||
byTypeBB[pt] |= s;
|
||||
byColorBB[c] |= s;
|
||||
pieceCount[c][ALL_PIECES]++;
|
||||
index[s] = pieceCount[c][pt]++;
|
||||
pieceList[c][pt][index[s]] = s;
|
||||
}
|
||||
|
@ -433,6 +434,7 @@ inline void Position::remove_piece(Square s, Color c, PieceType pt) {
|
|||
byTypeBB[pt] ^= s;
|
||||
byColorBB[c] ^= s;
|
||||
/* board[s] = NO_PIECE; */ // Not needed, will be overwritten by capturing
|
||||
pieceCount[c][ALL_PIECES]--;
|
||||
Square lastSquare = pieceList[c][pt][--pieceCount[c][pt]];
|
||||
index[lastSquare] = index[s];
|
||||
pieceList[c][pt][index[lastSquare]] = lastSquare;
|
||||
|
|
Loading…
Add table
Reference in a new issue