@@ -184,6 +184,7 @@ namespace {
184184 const Score Unstoppable = S( 0 , 20 );
185185 const Score Hanging = S(31 , 26 );
186186 const Score PawnAttackThreat = S(20 , 20 );
187+ const Score Checked = S(20 , 20 );
187188
188189 // Penalty for a bishop on a1/h1 (a8/h8 for black) which is trapped by
189190 // a friendly pawn on b2/g2 (b7/g7 for black). This can obviously only
@@ -440,22 +441,34 @@ namespace {
440441 // Enemy queen safe checks
441442 b = (b1 | b2) & ei.attackedBy [Them][QUEEN];
442443 if (b)
444+ {
443445 attackUnits += QueenCheck * popcount<Max15>(b);
446+ score -= Checked;
447+ }
444448
445449 // Enemy rooks safe checks
446450 b = b1 & ei.attackedBy [Them][ROOK];
447451 if (b)
452+ {
448453 attackUnits += RookCheck * popcount<Max15>(b);
454+ score -= Checked;
455+ }
449456
450457 // Enemy bishops safe checks
451458 b = b2 & ei.attackedBy [Them][BISHOP];
452459 if (b)
460+ {
453461 attackUnits += BishopCheck * popcount<Max15>(b);
462+ score -= Checked;
463+ }
454464
455465 // Enemy knights safe checks
456466 b = pos.attacks_from <KNIGHT>(ksq) & ei.attackedBy [Them][KNIGHT] & safe;
457467 if (b)
468+ {
458469 attackUnits += KnightCheck * popcount<Max15>(b);
470+ score -= Checked;
471+ }
459472
460473 // Finally, extract the king danger score from the KingDanger[]
461474 // array and subtract the score from evaluation.
0 commit comments