X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fpawns.cpp;h=aa3139e27a7b65fe7af7b986437134d93e0ca5de;hp=64c8e4b6182f2133108e69d1e3bf6bdb87ee1a82;hb=73ca93f3c07867d16318d469b1054c45ddca79bf;hpb=7bce8831d361317e0cf5156a888ca2d3e568a2ff diff --git a/src/pawns.cpp b/src/pawns.cpp index 64c8e4b6..aa3139e2 100644 --- a/src/pawns.cpp +++ b/src/pawns.cpp @@ -57,6 +57,11 @@ namespace { S( 0, 0), S( 6, 13), S(6,13), S(14,29), S(34,68), S(83,166), S(0, 0), S( 0, 0) }; + // Levers bonus by rank + const Score Lever[RANK_NB] = { + S( 0, 0), S( 0, 0), S(0, 0), S(0, 0), + S(20,20), S(40,40), S(0, 0), S(0, 0) }; + // Bonus for file distance of the two outermost pawns const Score PawnsFileSpan = S(0, 15); @@ -72,7 +77,7 @@ namespace { const Value StormDanger[3][RANK_NB] = { { V( 0), V(64), V(128), V(51), V(26) }, { V(26), V(32), V( 96), V(38), V(20) }, - { V( 0), V( 0), V( 64), V(25), V(13) } }; + { V( 0), V( 0), V(160), V(25), V(13) } }; // Max bonus for king safety. Corresponds to start position with all the pawns // in front of the king and no enemy pawn on the horizon. @@ -92,9 +97,10 @@ namespace { Bitboard b, p, doubled; Square s; File f; - bool passed, isolated, opposed, connected, backward, candidate, unsupported; + bool passed, isolated, opposed, connected, backward, candidate, unsupported, lever; Score value = SCORE_ZERO; const Square* pl = pos.list(Us); + const Bitboard* pawnAttacksBB = StepAttacksBB[make_piece(Us, PAWN)]; Bitboard ourPawns = pos.pieces(Us, PAWN); Bitboard theirPawns = pos.pieces(Them, PAWN); @@ -130,6 +136,7 @@ namespace { doubled = ourPawns & forward_bb(Us, s); opposed = theirPawns & forward_bb(Us, s); passed = !(theirPawns & passed_pawn_mask(Us, s)); + lever = theirPawns & pawnAttacksBB[s]; // Test for backward pawn. // If the pawn is passed, isolated, or connected it cannot be @@ -185,6 +192,9 @@ namespace { if (connected) value += Connected[f][relative_rank(Us, s)]; + if (lever) + value += Lever[relative_rank(Us, s)]; + if (candidate) { value += CandidatePassed[relative_rank(Us, s)]; @@ -270,7 +280,7 @@ Value Entry::shelter_storm(const Position& pos, Square ksq) { if ( (MiddleEdges & make_square(f, rkThem)) && file_of(ksq) == f && relative_rank(Us, ksq) == rkThem - 1) - safety += Value(200); + safety += 200; else safety -= ShelterWeakness[rkUs] + StormDanger[rkUs == RANK_1 ? 0 : rkThem == rkUs + 1 ? 2 : 1][rkThem];