X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fevaluate.cpp;h=e4c2bbcb6365a9b5e5744960a4eaa689ade2312d;hp=85ac0dab77c2373c7c292f7c478c1681b2a23518;hb=4c9b42316112efc7383c27570102d5d528d6af0a;hpb=2416242c966bfccd5a779e037dfe0d2d4cd8f3fe diff --git a/src/evaluate.cpp b/src/evaluate.cpp index 85ac0dab..e4c2bbcb 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -635,10 +635,10 @@ namespace { // space evaluation is a simple bonus based on the number of safe squares // available for minor pieces on the central four files on ranks 2--4. Safe // squares one, two or three squares behind a friendly pawn are counted - // twice. Finally, the space bonus is scaled by a weight taken from the - // material hash table. The aim is to improve play on game opening. + // twice. Finally, the space bonus is multiplied by a weight. The aim is to + // improve play on game opening. template - Score evaluate_space(const Position& pos, const EvalInfo& ei, Score weight) { + Score evaluate_space(const Position& pos, const EvalInfo& ei) { const Color Them = (Us == WHITE ? BLACK : WHITE); @@ -659,7 +659,11 @@ namespace { assert(unsigned(safe >> (Us == WHITE ? 32 : 0)) == 0); // Count safe + (behind & safe) with a single popcount - return popcount((Us == WHITE ? safe << 32 : safe >> 32) | (behind & safe)) * weight; + int bonus = popcount((Us == WHITE ? safe << 32 : safe >> 32) | (behind & safe)); + int weight = pos.count(Us) + pos.count(Us) + + pos.count(Them) + pos.count(Them); + + return make_score(bonus * weight * weight, 0); } @@ -731,12 +735,10 @@ namespace { score -= int(relative_rank(BLACK, frontmost_sq(BLACK, b))) * Unstoppable; } - // Evaluate space for both sides, only in middlegame - if (ei.mi->space_weight()) + // Evaluate space for both sides, only during opening + if (pos.non_pawn_material(WHITE) + pos.non_pawn_material(BLACK) >= 2 * QueenValueMg + 4 * RookValueMg + 2 * KnightValueMg) { - Score s = evaluate_space(pos, ei, ei.mi->space_weight()) - - evaluate_space(pos, ei, ei.mi->space_weight()); - + Score s = evaluate_space(pos, ei) - evaluate_space(pos, ei); score += apply_weight(s, Weights[Space]); } @@ -784,9 +786,8 @@ namespace { Tracing::write(PAWN, ei.pi->pawns_score()); Tracing::write(Tracing::MOBILITY, apply_weight(mobility[WHITE], Weights[Mobility]) , apply_weight(mobility[BLACK], Weights[Mobility])); - Score w = evaluate_space(pos, ei, ei.mi->space_weight()); - Score b = evaluate_space(pos, ei, ei.mi->space_weight()); - Tracing::write(Tracing::SPACE, apply_weight(w, Weights[Space]), apply_weight(b, Weights[Space])); + Tracing::write(Tracing::SPACE, apply_weight(evaluate_space(pos, ei), Weights[Space]) + , apply_weight(evaluate_space(pos, ei), Weights[Space])); Tracing::write(Tracing::TOTAL, score); Tracing::ei = ei; Tracing::sf = sf;