Skip to content

Commit 0b81420

Browse files
mstemberaIIvec
authored andcommitted
Simplify Safe Checks
STC: LLR: 2.96 (-2.94,2.94) [-3.00,1.00] Total: 11796 W: 2211 L: 2074 D: 7511 LTC: LLR: 2.96 (-2.94,2.94) [-3.00,1.00] Total: 14324 W: 1935 L: 1806 D: 10583 Bench: 8075202 Resolves #600
1 parent cf1f00e commit 0b81420

File tree

1 file changed

+8
-24
lines changed

1 file changed

+8
-24
lines changed

src/evaluate.cpp

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -424,36 +424,20 @@ namespace {
424424
b2 = pos.attacks_from<BISHOP>(ksq) & safe;
425425

426426
// Enemy queen safe checks
427-
b = (b1 | b2) & ei.attackedBy[Them][QUEEN];
428-
if (b)
429-
{
430-
attackUnits += QueenCheck * popcount<Max15>(b);
431-
score -= Checked;
432-
}
427+
if ((b1 | b2) & ei.attackedBy[Them][QUEEN])
428+
attackUnits += QueenCheck, score -= Checked;
433429

434430
// Enemy rooks safe checks
435-
b = b1 & ei.attackedBy[Them][ROOK];
436-
if (b)
437-
{
438-
attackUnits += RookCheck * popcount<Max15>(b);
439-
score -= Checked;
440-
}
431+
if (b1 & ei.attackedBy[Them][ROOK])
432+
attackUnits += RookCheck, score -= Checked;
441433

442434
// Enemy bishops safe checks
443-
b = b2 & ei.attackedBy[Them][BISHOP];
444-
if (b)
445-
{
446-
attackUnits += BishopCheck * popcount<Max15>(b);
447-
score -= Checked;
448-
}
435+
if (b2 & ei.attackedBy[Them][BISHOP])
436+
attackUnits += BishopCheck, score -= Checked;
449437

450438
// Enemy knights safe checks
451-
b = pos.attacks_from<KNIGHT>(ksq) & ei.attackedBy[Them][KNIGHT] & safe;
452-
if (b)
453-
{
454-
attackUnits += KnightCheck * popcount<Max15>(b);
455-
score -= Checked;
456-
}
439+
if (pos.attacks_from<KNIGHT>(ksq) & ei.attackedBy[Them][KNIGHT] & safe)
440+
attackUnits += KnightCheck, score -= Checked;
457441

458442
// Finally, extract the king danger score from the KingDanger[]
459443
// array and subtract the score from the evaluation.

0 commit comments

Comments
 (0)