- Color Us = pos.side_to_move();
- if ( (pos.pieces(Us, BISHOP) & relative_square(Us, SQ_A1))
- && (pos.pieces(Us, PAWN) & relative_square(Us, SQ_B2)))
- {
- bAdjust -= !pos.empty(relative_square(Us,SQ_B3)) ? p1
- : pos.piece_on(relative_square(Us,SQ_C3)) == make_piece(Us, PAWN) ? p2
- : p3;
- }
- if ( (pos.pieces(Us, BISHOP) & relative_square(Us, SQ_H1))
- && (pos.pieces(Us, PAWN) & relative_square(Us, SQ_G2)))
- {
- bAdjust -= !pos.empty(relative_square(Us,SQ_G3)) ? p1
- : pos.piece_on(relative_square(Us,SQ_F3)) == make_piece(Us, PAWN) ? p2
- : p3;
- }
- if ( (pos.pieces(~Us, BISHOP) & relative_square(Us, SQ_A8))
- && (pos.pieces(~Us, PAWN) & relative_square(Us, SQ_B7)))
- {
- bAdjust += !pos.empty(relative_square(Us,SQ_B6)) ? p1
- : pos.piece_on(relative_square(Us,SQ_C6)) == make_piece(~Us, PAWN) ? p2
- : p3;
- }
- if ( (pos.pieces(~Us, BISHOP) & relative_square(Us, SQ_H8))
- && (pos.pieces(~Us, PAWN) & relative_square(Us, SQ_G7)))
- {
- bAdjust += !pos.empty(relative_square(Us,SQ_G6)) ? p1
- : pos.piece_on(relative_square(Us,SQ_F6)) == make_piece(~Us, PAWN) ? p2
- : p3;
- }
- return bAdjust;
+ int correction = 0;
+
+ if ( pos.piece_on(SQ_A1) == W_BISHOP
+ && pos.piece_on(SQ_B2) == W_PAWN)
+ correction -= CorneredBishop;
+
+ if ( pos.piece_on(SQ_H1) == W_BISHOP
+ && pos.piece_on(SQ_G2) == W_PAWN)
+ correction -= CorneredBishop;
+
+ if ( pos.piece_on(SQ_A8) == B_BISHOP
+ && pos.piece_on(SQ_B7) == B_PAWN)
+ correction += CorneredBishop;
+
+ if ( pos.piece_on(SQ_H8) == B_BISHOP
+ && pos.piece_on(SQ_G7) == B_PAWN)
+ correction += CorneredBishop;
+
+ return pos.side_to_move() == WHITE ? Value(3 * correction)
+ : -Value(3 * correction);