@@ -138,7 +138,7 @@ namespace {
138138 {}, {},
139139 { S (0 , 0 ), S ( 7 , 39 ), S ( 0 , 0 ), S (24 , 49 ), S (41 ,100 ), S (41 ,100 ) }, // KNIGHT
140140 { S (0 , 0 ), S ( 7 , 39 ), S (24 , 49 ), S ( 0 , 0 ), S (41 ,100 ), S (41 ,100 ) }, // BISHOP
141- { S (0 , 0 ), S (- 1 , 29 ), S (15 , 49 ), S (15 , 49 ), S ( 0 , 0 ), S (24 , 49 ) }, // ROOK
141+ { S (0 , 0 ), S ( 0 , 22 ), S (15 , 49 ), S (15 , 49 ), S ( 0 , 0 ), S (24 , 49 ) }, // ROOK
142142 { S (0 , 0 ), S (15 , 39 ), S (15 , 39 ), S (15 , 39 ), S (15 , 39 ), S ( 0 , 0 ) } // QUEEN
143143 };
144144
@@ -153,12 +153,16 @@ namespace {
153153 // Bonus for having the side to move (modified by Joona Kiiski)
154154 const Score Tempo = make_score(24 , 11 );
155155
156- // Rooks and queens on the 7th rank (modified by Joona Kiiski)
157- const Score RookOn7thBonus = make_score(47 , 98 );
158- const Score QueenOn7thBonus = make_score(27 , 54 );
156+ // Rooks and queens on the 7th rank
157+ const Score RookOn7thBonus = make_score(3 , 20 );
158+ const Score QueenOn7thBonus = make_score(1 , 8 );
159+
160+ // Rooks and queens attacking pawns on the same rank
161+ const Score RookOnPawnBonus = make_score(3 , 48 );
162+ const Score QueenOnPawnBonus = make_score(1 , 40 );
159163
160164 // Rooks on open files (modified by Joona Kiiski)
161- const Score RookOpenFileBonus = make_score(43 , 21 );
165+ const Score RookOpenFileBonus = make_score(43 , 21 );
162166 const Score RookHalfOpenFileBonus = make_score(19 , 10 );
163167
164168 // Penalty for rooks trapped inside a friendly king which has lost the
@@ -595,12 +599,18 @@ Value do_evaluate(const Position& pos, Value& margin) {
595599 && !(pos.pieces (Them, PAWN ) & attack_span_mask (Us, s)))
596600 score += evaluate_outposts<Piece, Us>(pos, ei, s);
597601
598- // Queen or rook on 7th rank
599- if ( (Piece == ROOK || Piece == QUEEN )
600- && relative_rank (Us, s) == RANK_7
601- && relative_rank (Us, pos.king_square (Them)) == RANK_8 )
602+ if ((Piece == ROOK || Piece == QUEEN ) && relative_rank (Us, s) >= RANK_5 )
602603 {
603- score += (Piece == ROOK ? RookOn7thBonus : QueenOn7thBonus);
604+ // Major piece on 7th rank
605+ if ( relative_rank (Us, s) == RANK_7
606+ && relative_rank (Us, pos.king_square (Them)) == RANK_8 )
607+ score += (Piece == ROOK ? RookOn7thBonus : QueenOn7thBonus);
608+
609+ // Major piece attacking pawns on the same rank
610+ Bitboard pawns = pos.pieces (Them, PAWN ) & rank_bb (s);
611+ if (pawns)
612+ score += (Piece == ROOK ? RookOnPawnBonus
613+ : QueenOnPawnBonus) * popcount<Max15>(pawns);
604614 }
605615
606616 // Special extra evaluation for bishops
0 commit comments