-
- /// Fisher Random Chess: correction for cornered bishops, to fix chess960 play with NNUE
-
- Value fix_FRC(const Position& pos) {
-
- constexpr Bitboard Corners = 1ULL << SQ_A1 | 1ULL << SQ_H1 | 1ULL << SQ_A8 | 1ULL << SQ_H8;
-
- if (!(pos.pieces(BISHOP) & Corners))
- return VALUE_ZERO;
-
- int correction = 0;
-
- if ( pos.piece_on(SQ_A1) == W_BISHOP
- && pos.piece_on(SQ_B2) == W_PAWN)
- correction += !pos.empty(SQ_B3) ? -CorneredBishop * 4
- : -CorneredBishop * 3;
-
- if ( pos.piece_on(SQ_H1) == W_BISHOP
- && pos.piece_on(SQ_G2) == W_PAWN)
- correction += !pos.empty(SQ_G3) ? -CorneredBishop * 4
- : -CorneredBishop * 3;
-
- if ( pos.piece_on(SQ_A8) == B_BISHOP
- && pos.piece_on(SQ_B7) == B_PAWN)
- correction += !pos.empty(SQ_B6) ? CorneredBishop * 4
- : CorneredBishop * 3;
-
- if ( pos.piece_on(SQ_H8) == B_BISHOP
- && pos.piece_on(SQ_G7) == B_PAWN)
- correction += !pos.empty(SQ_G6) ? CorneredBishop * 4
- : CorneredBishop * 3;
-
- return pos.side_to_move() == WHITE ? Value(correction)
- : -Value(correction);
- }
-