X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fevaluate.cpp;h=fbe768bbbd4d72983fd1abd312ec7c31ba881c58;hb=eb07775583c39893bc6eb65a40b5f62a7799deee;hp=deb8211ab7d5d86d3f214f0b9e5f11231d786ee6;hpb=c8589903777b6e0289640b43fae966ded442af48;p=stockfish diff --git a/src/evaluate.cpp b/src/evaluate.cpp index deb8211a..fbe768bb 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -228,6 +228,8 @@ namespace { const Square ksq = pos.square(Us); + Bitboard dblAttackByPawn = pawn_double_attacks_bb(pos.pieces(Us, PAWN)); + // Find our pawns that are blocked or on the first two ranks Bitboard b = pos.pieces(Us, PAWN) & (shift(pos.pieces()) | LowRanks); @@ -239,7 +241,8 @@ namespace { attackedBy[Us][KING] = pos.attacks_from(ksq); attackedBy[Us][PAWN] = pe->pawn_attacks(Us); attackedBy[Us][ALL_PIECES] = attackedBy[Us][KING] | attackedBy[Us][PAWN]; - attackedBy2[Us] = attackedBy[Us][KING] & attackedBy[Us][PAWN]; + attackedBy2[Us] = (attackedBy[Us][KING] & attackedBy[Us][PAWN]) + | dblAttackByPawn; // Init our king safety tables kingRing[Us] = attackedBy[Us][KING]; @@ -256,7 +259,7 @@ namespace { kingAttacksCount[Them] = kingAttackersWeight[Them] = 0; // Remove from kingRing[] the squares defended by two pawns - kingRing[Us] &= ~pawn_double_attacks_bb(pos.pieces(Us, PAWN)); + kingRing[Us] &= ~dblAttackByPawn; } @@ -355,8 +358,8 @@ namespace { score += RookOnPawn * popcount(pos.pieces(Them, PAWN) & PseudoAttacks[ROOK][s]); // Bonus for rook on an open or semi-open file - if (pe->semiopen_file(Us, file_of(s))) - score += RookOnFile[bool(pe->semiopen_file(Them, file_of(s)))]; + if (pos.semiopen_file(Us, file_of(s))) + score += RookOnFile[bool(pos.semiopen_file(Them, file_of(s)))]; // Penalty when trapped by the king, even more if the king cannot castle else if (mob <= 3) @@ -469,10 +472,10 @@ namespace { - 6 * mg_value(score) / 8 + mg_value(mobility[Them] - mobility[Us]) + 5 * kingFlankAttacks * kingFlankAttacks / 16 - - 25; + - 15; // Transform the kingDanger units into a Score, and subtract it from the evaluation - if (kingDanger > 0) + if (kingDanger > 100) score -= make_score(kingDanger * kingDanger / 4096, kingDanger / 16); // Penalty when our king is on a pawnless flank @@ -717,7 +720,7 @@ namespace { int bonus = popcount(safe) + popcount(behind & safe); int weight = pos.count(Us) - - 2 * popcount(pe->semiopenFiles[WHITE] & pe->semiopenFiles[BLACK]); + - (16 - pos.count()) / 4; Score score = make_score(bonus * weight * weight / 16, 0);