X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fevaluate.cpp;h=3d2248a53c042ac4e8a1de0cb5f72c4faeb29154;hp=b469050a1cd59b3d9d44e5fd0d6f7ec9aa5db572;hb=b05fbb3733df535a3fdf99e8d832001e57929699;hpb=0a6532a39d2e2cfd92ba0a2c4fa8c6ad6c29b581 diff --git a/src/evaluate.cpp b/src/evaluate.cpp index b469050a..3d2248a5 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -1,7 +1,7 @@ /* Stockfish, a UCI chess playing engine derived from Glaurung 2.1 Copyright (C) 2004-2008 Tord Romstad (Glaurung author) - Copyright (C) 2008-2010 Marco Costalba, Joona Kiiski, Tord Romstad + Copyright (C) 2008-2012 Marco Costalba, Joona Kiiski, Tord Romstad Stockfish is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -422,7 +422,6 @@ namespace { template void init_eval_info(const Position& pos, EvalInfo& ei) { - const BitCountType Max15 = HasPopCnt ? CNT_POPCNT : Is64Bit ? CNT64_MAX15 : CNT32_MAX15; const Color Them = (Us == WHITE ? BLACK : WHITE); Bitboard b = ei.attackedBy[Them][KING] = pos.attacks_from(pos.king_square(Them)); @@ -434,7 +433,7 @@ namespace { { ei.kingRing[Them] = (b | (Us == WHITE ? b >> 8 : b << 8)); b &= ei.attackedBy[Us][PAWN]; - ei.kingAttackersCount[Us] = b ? count_1s(b) / 2 : 0; + ei.kingAttackersCount[Us] = b ? popcount(b) / 2 : 0; ei.kingAdjacentZoneAttacksCount[Us] = ei.kingAttackersWeight[Us] = 0; } else ei.kingRing[Them] = ei.kingAttackersCount[Us] = 0; @@ -478,8 +477,6 @@ namespace { File f; Score score = SCORE_ZERO; - const BitCountType Full = HasPopCnt ? CNT_POPCNT : Is64Bit ? CNT64 : CNT32; - const BitCountType Max15 = HasPopCnt ? CNT_POPCNT : Is64Bit ? CNT64_MAX15 : CNT32_MAX15; const Color Them = (Us == WHITE ? BLACK : WHITE); const Square* pl = pos.piece_list(Us, Piece); @@ -507,12 +504,12 @@ namespace { ei.kingAttackersWeight[Us] += KingAttackWeights[Piece]; Bitboard bb = (b & ei.attackedBy[Them][KING]); if (bb) - ei.kingAdjacentZoneAttacksCount[Us] += count_1s(bb); + ei.kingAdjacentZoneAttacksCount[Us] += popcount(bb); } // Mobility - mob = (Piece != QUEEN ? count_1s(b & mobilityArea) - : count_1s(b & mobilityArea)); + mob = (Piece != QUEEN ? popcount(b & mobilityArea) + : popcount(b & mobilityArea)); mobility += MobilityBonus[Piece][mob]; @@ -667,7 +664,6 @@ namespace { template Score evaluate_king(const Position& pos, EvalInfo& ei, Value margins[]) { - const BitCountType Max15 = HasPopCnt ? CNT_POPCNT : Is64Bit ? CNT64_MAX15 : CNT32_MAX15; const Color Them = (Us == WHITE ? BLACK : WHITE); Bitboard undefended, b, b1, b2, safe; @@ -695,7 +691,7 @@ namespace { // attacked and undefended squares around our king, the square of the // king, and the quality of the pawn shelter. attackUnits = std::min(25, (ei.kingAttackersCount[Them] * ei.kingAttackersWeight[Them]) / 2) - + 3 * (ei.kingAdjacentZoneAttacksCount[Them] + count_1s(undefended)) + + 3 * (ei.kingAdjacentZoneAttacksCount[Them] + popcount(undefended)) + InitKingDanger[relative_square(Us, ksq)] - mg_value(ei.pi->king_shelter(pos, ksq)) / 32; @@ -709,7 +705,7 @@ namespace { | ei.attackedBy[Them][BISHOP] | ei.attackedBy[Them][ROOK]); if (b) attackUnits += QueenContactCheckBonus - * count_1s(b) + * popcount(b) * (Them == pos.side_to_move() ? 2 : 1); } @@ -718,7 +714,7 @@ namespace { b = undefended & ei.attackedBy[Them][ROOK] & ~pos.pieces(Them); // Consider only squares where the enemy rook gives check - b &= RookPseudoAttacks[ksq]; + b &= PseudoAttacks[ROOK][ksq]; if (b) { @@ -727,7 +723,7 @@ namespace { | ei.attackedBy[Them][BISHOP] | ei.attackedBy[Them][QUEEN]); if (b) attackUnits += RookContactCheckBonus - * count_1s(b) + * popcount(b) * (Them == pos.side_to_move() ? 2 : 1); } @@ -740,22 +736,22 @@ namespace { // Enemy queen safe checks b = (b1 | b2) & ei.attackedBy[Them][QUEEN]; if (b) - attackUnits += QueenCheckBonus * count_1s(b); + attackUnits += QueenCheckBonus * popcount(b); // Enemy rooks safe checks b = b1 & ei.attackedBy[Them][ROOK]; if (b) - attackUnits += RookCheckBonus * count_1s(b); + attackUnits += RookCheckBonus * popcount(b); // Enemy bishops safe checks b = b2 & ei.attackedBy[Them][BISHOP]; if (b) - attackUnits += BishopCheckBonus * count_1s(b); + attackUnits += BishopCheckBonus * popcount(b); // Enemy knights safe checks b = pos.attacks_from(ksq) & ei.attackedBy[Them][KNIGHT] & safe; if (b) - attackUnits += KnightCheckBonus * count_1s(b); + attackUnits += KnightCheckBonus * popcount(b); // To index KingDangerTable[] attackUnits must be in [0, 99] range attackUnits = std::min(99, std::max(0, attackUnits)); @@ -879,8 +875,6 @@ namespace { Score evaluate_unstoppable_pawns(const Position& pos, EvalInfo& ei) { - const BitCountType Max15 = HasPopCnt ? CNT_POPCNT : Is64Bit ? CNT64_MAX15 : CNT32_MAX15; - Bitboard b, b2, blockers, supporters, queeningPath, candidates; Square s, blockSq, queeningSquare; Color c, winnerSide, loserSide; @@ -918,7 +912,7 @@ namespace { assert((queeningPath & pos.occupied_squares()) == (queeningPath & pos.pieces(c))); // Add moves needed to free the path from friendly pieces and retest condition - movesToGo += count_1s(queeningPath & pos.pieces(c)); + movesToGo += popcount(queeningPath & pos.pieces(c)); if (movesToGo >= oppMovesToGo && !pathDefended) continue; @@ -1046,7 +1040,6 @@ namespace { template int evaluate_space(const Position& pos, EvalInfo& ei) { - const BitCountType Max15 = HasPopCnt ? CNT_POPCNT : Is64Bit ? CNT64_MAX15 : CNT32_MAX15; const Color Them = (Us == WHITE ? BLACK : WHITE); // Find the safe squares for our pieces inside the area defined by @@ -1062,7 +1055,7 @@ namespace { behind |= (Us == WHITE ? behind >> 8 : behind << 8); behind |= (Us == WHITE ? behind >> 16 : behind << 16); - return count_1s(safe) + count_1s(behind & safe); + return popcount(safe) + popcount(behind & safe); }