X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fevaluate.cpp;h=acda65fb45ab7002bda6bb36cb1f1599abe8dff5;hp=a0e22516002acbd0b2aebf8eb66e50918f6dec25;hb=907f912463693683f785b5171c84740640d4b120;hpb=766fb9c67da48c696e9444a3a46c531786172256 diff --git a/src/evaluate.cpp b/src/evaluate.cpp index a0e22516..acda65fb 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -151,8 +151,8 @@ namespace { }; // Assorted bonuses and penalties used by evaluation - const Score KingOnPawnOne = S(0 , 64); - const Score KingOnPawnMany = S(0 ,128); + const Score KingOnOne = S(2 , 58); + const Score KingOnMany = S(6 ,125); const Score RookOnPawn = S(10, 28); const Score RookOpenFile = S(43, 21); const Score RookSemiOpenFile = S(19, 10); @@ -221,7 +221,7 @@ namespace { ei.attackedBy[Us][ALL_PIECES] = ei.attackedBy[Us][PAWN] = ei.pi->pawn_attacks(Us); // Init king safety tables only if we are going to use them - if (pos.count(Us) && pos.non_pawn_material(Us) > QueenValueMg + PawnValueMg) + if (pos.non_pawn_material(Us) > QueenValueMg + PawnValueMg) { ei.kingRing[Them] = b | shift_bb(b); b &= ei.attackedBy[Us][PAWN]; @@ -414,7 +414,8 @@ namespace { attackUnits = std::min(20, (ei.kingAttackersCount[Them] * ei.kingAttackersWeight[Them]) / 2) + 3 * (ei.kingAdjacentZoneAttacksCount[Them] + popcount(undefended)) + 2 * (ei.pinnedPieces[Us] != 0) - - mg_value(score) / 32; + - mg_value(score) / 32 + - !pos.count(Them) * 15; // Analyse the enemy's safe queen contact checks. Firstly, find the // undefended squares around the king that are attacked by the enemy's @@ -506,7 +507,7 @@ namespace { & ei.attackedBy[Them][PAWN] & (ei.attackedBy[Us][KNIGHT] | ei.attackedBy[Us][BISHOP]); - if(protectedEnemies) + if (protectedEnemies) score += Threat[Minor][type_of(pos.piece_on(lsb(protectedEnemies)))]; // Enemies not defended by a pawn and under our attack @@ -529,9 +530,9 @@ namespace { if (b) score += more_than_one(b) ? Hanging * popcount(b) : Hanging; - b = weakEnemies & pos.pieces(Them, PAWN) & ei.attackedBy[Us][KING]; + b = weakEnemies & ei.attackedBy[Us][KING]; if (b) - score += more_than_one(b) ? KingOnPawnMany : KingOnPawnOne; + score += more_than_one(b) ? KingOnMany : KingOnOne; } if (Trace) @@ -607,7 +608,7 @@ namespace { mbonus += k * rr, ebonus += k * rr; } - else if(pos.pieces(Us) & blockSq) + else if (pos.pieces(Us) & blockSq) mbonus += rr * 3 + r * 2 + 3, ebonus += rr + r * 2; } // rr != 0 @@ -625,13 +626,13 @@ namespace { } - // evaluate_unstoppable_pawns() scores the most advanced among the passed and - // candidate pawns. In case both players have no pieces but pawns, this is - // somewhat related to the possibility that pawns are unstoppable. + // evaluate_unstoppable_pawns() scores the most advanced passed pawn. In case + // both players have no pieces but pawns, this is somewhat related to the + // possibility that pawns are unstoppable. Score evaluate_unstoppable_pawns(Color us, const EvalInfo& ei) { - Bitboard b = ei.pi->passed_pawns(us) | ei.pi->candidate_pawns(us); + Bitboard b = ei.pi->passed_pawns(us); return b ? Unstoppable * int(relative_rank(us, frontmost_sq(us, b))) : SCORE_ZERO; } @@ -692,7 +693,7 @@ namespace { // If we have a specialized evaluation function for the current material // configuration, call it and return. if (ei.mi->specialized_eval_exists()) - return ei.mi->evaluate(pos); + return ei.mi->evaluate(pos) + Eval::Tempo; // Probe the pawn hash table ei.pi = Pawns::probe(pos, thisThread->pawnsTable); @@ -792,7 +793,7 @@ namespace { Tracing::sf = sf; } - return pos.side_to_move() == WHITE ? v : -v; + return (pos.side_to_move() == WHITE ? v : -v) + Eval::Tempo; } @@ -871,7 +872,7 @@ namespace Eval { /// of the position always from the point of view of the side to move. Value evaluate(const Position& pos) { - return do_evaluate(pos) + Tempo; + return do_evaluate(pos); }