@@ -73,17 +73,6 @@ using namespace Trace;
7373
7474namespace {
7575
76- constexpr Bitboard QueenSide = FileABB | FileBBB | FileCBB | FileDBB;
77- constexpr Bitboard CenterFiles = FileCBB | FileDBB | FileEBB | FileFBB;
78- constexpr Bitboard KingSide = FileEBB | FileFBB | FileGBB | FileHBB;
79- constexpr Bitboard Center = (FileDBB | FileEBB) & (Rank4BB | Rank5BB);
80-
81- constexpr Bitboard KingFlank[FILE_NB] = {
82- QueenSide ^ FileDBB, QueenSide, QueenSide,
83- CenterFiles, CenterFiles,
84- KingSide, KingSide, KingSide ^ FileEBB
85- };
86-
8776 // Threshold for lazy and space evaluation
8877 constexpr Value LazyThreshold = Value(1500 );
8978 constexpr Value SpaceThreshold = Value(12222 );
@@ -152,6 +141,7 @@ namespace {
152141 constexpr Score KnightOnQueen = S( 16 , 12 );
153142 constexpr Score LongDiagonalBishop = S( 45 , 0 );
154143 constexpr Score MinorBehindPawn = S( 18 , 3 );
144+ constexpr Score Outpost = S( 9 , 3 );
155145 constexpr Score PawnlessFlank = S( 17 , 95 );
156146 constexpr Score RestrictedPiece = S( 7 , 7 );
157147 constexpr Score RookOnPawn = S( 10 , 32 );
@@ -163,7 +153,6 @@ namespace {
163153 constexpr Score TrappedRook = S( 47 , 4 );
164154 constexpr Score WeakQueen = S( 49 , 15 );
165155 constexpr Score WeakUnopposedPawn = S( 12 , 23 );
166- constexpr Score Outpost = S( 9 , 3 );
167156
168157#undef S
169158
@@ -402,7 +391,8 @@ namespace {
402391 constexpr Bitboard Camp = (Us == WHITE ? AllSquares ^ Rank6BB ^ Rank7BB ^ Rank8BB
403392 : AllSquares ^ Rank1BB ^ Rank2BB ^ Rank3BB);
404393
405- Bitboard weak, b, b1, b2, safe, unsafeChecks = 0 ;
394+ Bitboard weak, b1, b2, safe, unsafeChecks = 0 ;
395+ Bitboard rookChecks, queenChecks, bishopChecks, knightChecks;
406396 int kingDanger = 0 ;
407397 const Square ksq = pos.square <KING>(Us);
408398
@@ -422,45 +412,43 @@ namespace {
422412 b2 = attacks_bb<BISHOP>(ksq, pos.pieces () ^ pos.pieces (Us, QUEEN));
423413
424414 // Enemy rooks checks
425- Bitboard RookCheck = b1
426- & safe
427- & attackedBy[Them][ROOK];
415+ rookChecks = b1 & safe & attackedBy[Them][ROOK];
428416
429- if (RookCheck )
417+ if (rookChecks )
430418 kingDanger += RookSafeCheck;
431419 else
432420 unsafeChecks |= b1 & attackedBy[Them][ROOK];
433421
434422 // Enemy queen safe checks: we count them only if they are from squares from
435423 // which we can't give a rook check, because rook checks are more valuable.
436- Bitboard QueenCheck = (b1 | b2)
437- & attackedBy[Them][QUEEN]
438- & safe
439- & ~attackedBy[Us][QUEEN]
440- & ~RookCheck ;
424+ queenChecks = (b1 | b2)
425+ & attackedBy[Them][QUEEN]
426+ & safe
427+ & ~attackedBy[Us][QUEEN]
428+ & ~rookChecks ;
441429
442- if (QueenCheck )
430+ if (queenChecks )
443431 kingDanger += QueenSafeCheck;
444432
445433 // Enemy bishops checks: we count them only if they are from squares from
446434 // which we can't give a queen check, because queen checks are more valuable.
447- Bitboard BishopCheck = b2
448- & attackedBy[Them][BISHOP]
449- & safe
450- & ~QueenCheck ;
435+ bishopChecks = b2
436+ & attackedBy[Them][BISHOP]
437+ & safe
438+ & ~queenChecks ;
451439
452- if (BishopCheck )
440+ if (bishopChecks )
453441 kingDanger += BishopSafeCheck;
454442 else
455443 unsafeChecks |= b2 & attackedBy[Them][BISHOP];
456444
457445 // Enemy knights checks
458- b = pos.attacks_from <KNIGHT>(ksq) & attackedBy[Them][KNIGHT];
446+ knightChecks = pos.attacks_from <KNIGHT>(ksq) & attackedBy[Them][KNIGHT];
459447
460- if (b & safe)
448+ if (knightChecks & safe)
461449 kingDanger += KnightSafeCheck;
462450 else
463- unsafeChecks |= b ;
451+ unsafeChecks |= knightChecks ;
464452
465453 // Unsafe or occupied checking squares will also be considered, as long as
466454 // the square is in the attacker's mobility area.
@@ -511,7 +499,7 @@ namespace {
511499 constexpr Direction Up = (Us == WHITE ? NORTH : SOUTH);
512500 constexpr Bitboard TRank3BB = (Us == WHITE ? Rank3BB : Rank6BB);
513501
514- Bitboard b, weak, defended, nonPawnEnemies, stronglyProtected, safe, restricted ;
502+ Bitboard b, weak, defended, nonPawnEnemies, stronglyProtected, safe;
515503 Score score = SCORE_ZERO;
516504
517505 // Non-pawn enemies
@@ -561,10 +549,11 @@ namespace {
561549 }
562550
563551 // Bonus for restricting their piece moves
564- restricted = attackedBy[Them][ALL_PIECES]
565- & ~stronglyProtected
566- & attackedBy[Us][ALL_PIECES];
567- score += RestrictedPiece * popcount (restricted);
552+ b = attackedBy[Them][ALL_PIECES]
553+ & ~stronglyProtected
554+ & attackedBy[Us][ALL_PIECES];
555+
556+ score += RestrictedPiece * popcount (b);
568557
569558 // Bonus for enemy unopposed weak pawns
570559 if (pos.pieces (Us, ROOK, QUEEN))
@@ -901,7 +890,6 @@ std::string Eval::trace(const Position& pos) {
901890 << " ------------+-------------+-------------+------------\n "
902891 << " Material | " << Term (MATERIAL)
903892 << " Imbalance | " << Term (IMBALANCE)
904- << " Initiative | " << Term (INITIATIVE)
905893 << " Pawns | " << Term (PAWN)
906894 << " Knights | " << Term (KNIGHT)
907895 << " Bishops | " << Term (BISHOP)
@@ -912,6 +900,7 @@ std::string Eval::trace(const Position& pos) {
912900 << " Threats | " << Term (THREAT)
913901 << " Passed | " << Term (PASSED)
914902 << " Space | " << Term (SPACE)
903+ << " Initiative | " << Term (INITIATIVE)
915904 << " ------------+-------------+-------------+------------\n "
916905 << " Total | " << Term (TOTAL);
917906
0 commit comments