@@ -90,9 +90,9 @@ namespace {
9090 }
9191
9292 // Evaluation weights, indexed by evaluation term
93- enum { Mobility, PawnStructure, PassedPawns, Space, KingDangerUs, KingDangerThem };
93+ enum { Mobility, PawnStructure, PassedPawns, Space, KingSafety };
9494 const struct Weight { int mg, eg; } Weights[] = {
95- {289 , 344 }, {233 , 201 }, {221 , 273 }, {46 , 0 }, {271 , 0 }, { 307 , 0 }
95+ {289 , 344 }, {233 , 201 }, {221 , 273 }, {46 , 0 }, {318 , 0 }
9696 };
9797
9898 typedef Value V;
@@ -150,12 +150,11 @@ namespace {
150150 S (0 , 0 ), S (0 , 0 ), S (56 , 70 ), S (56 , 70 ), S (76 , 99 ), S (86 , 118 )
151151 };
152152
153- // Hanging[side to move] contains a bonus for each enemy hanging piece
154- const Score Hanging[ 2 ] = { S (23 , 20 ) , S ( 35 , 45 ) } ;
153+ // Hanging contains a bonus for each enemy hanging piece
154+ const Score Hanging = S(23 , 20 );
155155
156156 #undef S
157157
158- const Score Tempo = make_score(24 , 11 );
159158 const Score RookOnPawn = make_score(10 , 28 );
160159 const Score RookOpenFile = make_score(43 , 21 );
161160 const Score RookSemiopenFile = make_score(19 , 10 );
@@ -194,9 +193,9 @@ namespace {
194193 const int BishopCheck = 2 ;
195194 const int KnightCheck = 3 ;
196195
197- // KingDanger[Color][ attackUnits] contains the actual king danger weighted
198- // scores, indexed by color and by a calculated integer number.
199- Score KingDanger[COLOR_NB][ 128 ];
196+ // KingDanger[attackUnits] contains the actual king danger weighted
197+ // scores, indexed by a calculated integer number.
198+ Score KingDanger[128 ];
200199
201200
202201 // apply_weight() weighs score 'v' by weight 'w' trying to prevent overflow
@@ -426,9 +425,7 @@ namespace {
426425 | ei.attackedBy [Them][BISHOP] | ei.attackedBy [Them][ROOK]);
427426
428427 if (b)
429- attackUnits += QueenContactCheck
430- * popcount<Max15>(b)
431- * (Them == pos.side_to_move () ? 2 : 1 );
428+ attackUnits += QueenContactCheck * popcount<Max15>(b);
432429 }
433430
434431 // Analyse the enemy's safe rook contact checks. Firstly, find the
@@ -446,9 +443,7 @@ namespace {
446443 | ei.attackedBy [Them][BISHOP] | ei.attackedBy [Them][QUEEN]);
447444
448445 if (b)
449- attackUnits += RookContactCheck
450- * popcount<Max15>(b)
451- * (Them == pos.side_to_move () ? 2 : 1 );
446+ attackUnits += RookContactCheck * popcount<Max15>(b);
452447 }
453448
454449 // Analyse the enemy's safe distance checks for sliders and knights
@@ -482,7 +477,7 @@ namespace {
482477
483478 // Finally, extract the king danger score from the KingDanger[]
484479 // array and subtract the score from evaluation.
485- score -= KingDanger[Us == Search::RootColor][ attackUnits];
480+ score -= KingDanger[attackUnits];
486481 }
487482
488483 if (Trace)
@@ -521,8 +516,7 @@ namespace {
521516
522517 b = weakEnemies & ~ei.attackedBy [Them][ALL_PIECES];
523518 if (b)
524- score += more_than_one (b) ? Hanging[Us != pos.side_to_move ()] * popcount<Max15>(b)
525- : Hanging[Us == pos.side_to_move ()];
519+ score += more_than_one (b) ? Hanging * popcount<Max15>(b) : Hanging;
526520 }
527521
528522 if (Trace)
@@ -677,9 +671,9 @@ namespace {
677671 Thread* thisThread = pos.this_thread ();
678672
679673 // Initialize score by reading the incrementally updated scores included
680- // in the position object (material + piece square tables) and adding a
681- // Tempo bonus. Score is computed from the point of view of white.
682- score = pos.psq_score () + (pos. side_to_move () == WHITE ? Tempo : -Tempo) ;
674+ // in the position object (material + piece square tables).
675+ // Score is computed from the point of view of white.
676+ score = pos.psq_score ();
683677
684678 // Probe the material hash table
685679 ei.mi = Material::probe (pos, thisThread->materialTable , thisThread->endgames );
@@ -831,7 +825,7 @@ namespace {
831825 << " | MG EG | MG EG | MG EG \n "
832826 << " ---------------------+-------------+-------------+-------------\n " ;
833827
834- format_row (ss, " Material, PST, Tempo " , PST);
828+ format_row (ss, " Material, PST" , PST);
835829 format_row (ss, " Material imbalance" , IMBALANCE);
836830 format_row (ss, " Pawns" , PAWN);
837831 format_row (ss, " Knights" , KNIGHT);
@@ -885,9 +879,7 @@ namespace Eval {
885879 for (int t = 0 , i = 1 ; i < 100 ; ++i)
886880 {
887881 t = int (std::min (Peak, std::min (0.4 * i * i, t + MaxSlope)));
888-
889- KingDanger[1 ][i] = apply_weight (make_score (t, 0 ), Weights[KingDangerUs]);
890- KingDanger[0 ][i] = apply_weight (make_score (t, 0 ), Weights[KingDangerThem]);
882+ KingDanger[i] = apply_weight (make_score (t, 0 ), Weights[KingSafety]);
891883 }
892884 }
893885
0 commit comments