X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fpawns.cpp;h=42819e142e5e7b12e2f7ad2c4a6159ab71962cd3;hp=b4ff799da3e71731a13ebd718f49c680a631f7cf;hb=cad300cfab869a4e8dcc6b286f9b2e60d2827bed;hpb=67f5f54a29b5d5d2bd9e43bfcc3a95bcc142d664 diff --git a/src/pawns.cpp b/src/pawns.cpp index b4ff799d..42819e14 100644 --- a/src/pawns.cpp +++ b/src/pawns.cpp @@ -88,10 +88,8 @@ namespace { template Score evaluate(const Position& pos, Pawns::Entry* e) { - const Color Them = (Us == WHITE ? BLACK : WHITE); - const Direction Up = (Us == WHITE ? NORTH : SOUTH); - const Direction Right = (Us == WHITE ? NORTH_EAST : SOUTH_WEST); - const Direction Left = (Us == WHITE ? NORTH_WEST : SOUTH_EAST); + const Color Them = (Us == WHITE ? BLACK : WHITE); + const Direction Up = (Us == WHITE ? NORTH : SOUTH); Bitboard b, neighbours, stoppers, doubled, supported, phalanx; Bitboard lever, leverPush; @@ -106,7 +104,7 @@ namespace { e->passedPawns[Us] = e->pawnAttacksSpan[Us] = e->weakUnopposed[Us] = 0; e->semiopenFiles[Us] = 0xFF; e->kingSquares[Us] = SQ_NONE; - e->pawnAttacks[Us] = shift(ourPawns) | shift(ourPawns); + e->pawnAttacks[Us] = pawn_attacks_bb(ourPawns); e->pawnsOnSquares[Us][BLACK] = popcount(ourPawns & DarkSquares); e->pawnsOnSquares[Us][WHITE] = pos.count(Us) - e->pawnsOnSquares[Us][BLACK]; @@ -224,8 +222,9 @@ Entry* probe(const Position& pos) { e->key = key; e->scores[WHITE] = evaluate(pos, e); e->scores[BLACK] = evaluate(pos, e); - e->asymmetry = popcount(e->semiopenFiles[WHITE] ^ e->semiopenFiles[BLACK]); e->openFiles = popcount(e->semiopenFiles[WHITE] & e->semiopenFiles[BLACK]); + e->asymmetry = popcount( (e->passedPawns[WHITE] | e->passedPawns[BLACK]) + | (e->semiopenFiles[WHITE] ^ e->semiopenFiles[BLACK])); return e; } @@ -238,14 +237,20 @@ template Value Entry::shelter_storm(const Position& pos, Square ksq) { const Color Them = (Us == WHITE ? BLACK : WHITE); + const Bitboard ShelterMask = (Us == WHITE ? 1ULL << SQ_A2 | 1ULL << SQ_B3 | 1ULL << SQ_C2 | 1ULL << SQ_F2 | 1ULL << SQ_G3 | 1ULL << SQ_H2 + : 1ULL << SQ_A7 | 1ULL << SQ_B6 | 1ULL << SQ_C7 | 1ULL << SQ_F7 | 1ULL << SQ_G6 | 1ULL << SQ_H7); + const Bitboard StormMask = (Us == WHITE ? 1ULL << SQ_A3 | 1ULL << SQ_C3 | 1ULL << SQ_F3 | 1ULL << SQ_H3 + : 1ULL << SQ_A6 | 1ULL << SQ_C6 | 1ULL << SQ_F6 | 1ULL << SQ_H6); enum { BlockedByKing, Unopposed, BlockedByPawn, Unblocked }; - Bitboard b = pos.pieces(PAWN) & (forward_ranks_bb(Us, ksq) | rank_bb(ksq)); + File center = std::max(FILE_B, std::min(FILE_G, file_of(ksq))); + Bitboard b = pos.pieces(PAWN) + & (forward_ranks_bb(Us, ksq) | rank_bb(ksq)) + & (adjacent_files_bb(center) | file_bb(center)); Bitboard ourPawns = b & pos.pieces(Us); Bitboard theirPawns = b & pos.pieces(Them); Value safety = MaxSafetyBonus; - File center = std::max(FILE_B, std::min(FILE_G, file_of(ksq))); for (File f = File(center - 1); f <= File(center + 1); ++f) { @@ -264,6 +269,9 @@ Value Entry::shelter_storm(const Position& pos, Square ksq) { [d][rkThem]; } + if (popcount((ourPawns & ShelterMask) | (theirPawns & StormMask)) == 5) + safety += Value(300); + return safety; }