Merge official-stockfish/master
authorFabian Fichter <ianfab@users.noreply.github.com>
Fri, 14 Aug 2020 13:55:48 +0000 (15:55 +0200)
committerFabian Fichter <ianfab@users.noreply.github.com>
Fri, 14 Aug 2020 13:55:48 +0000 (15:55 +0200)
bench: 5082623

1  2 
src/evaluate.cpp
src/pawns.cpp

@@@ -318,40 -285,15 +319,42 @@@ namespace 
          if (b & kingRing[Them])
          {
              kingAttackersCount[Us]++;
 -            kingAttackersWeight[Us] += KingAttackWeights[Pt];
 +            kingAttackersWeight[Us] += KingAttackWeights[std::min(int(Pt), QUEEN + 1)];
              kingAttacksCount[Us] += popcount(b & attackedBy[Them][KING]);
          }
+         else if (Pt == ROOK && (file_bb(s) & kingRing[Them]))
+             score += RookOnKingRing;
  
 +        if (Pt > QUEEN)
 +             b = (b & pos.pieces()) | (pos.moves_from(Us, Pt, s) & ~pos.pieces() & pos.board_bb());
 +
          int mob = popcount(b & mobilityArea[Us]);
  
 -        mobility[Us] += MobilityBonus[Pt - 2][mob];
 +        if (Pt <= QUEEN)
 +            mobility[Us] += MobilityBonus[Pt - 2][mob];
 +        else
 +            mobility[Us] += MaxMobility * (mob - 2) / (8 + mob);
 +
 +        // Piece promotion bonus
 +        if (pos.promoted_piece_type(Pt) != NO_PIECE_TYPE)
 +        {
 +            if (promotion_zone_bb(Us, pos.promotion_rank(), pos.max_rank()) & (b | s))
 +                score += make_score(PieceValue[MG][pos.promoted_piece_type(Pt)] - PieceValue[MG][Pt],
 +                                    PieceValue[EG][pos.promoted_piece_type(Pt)] - PieceValue[EG][Pt]) / 10;
 +        }
 +        else if (pos.piece_demotion() && pos.unpromoted_piece_on(s))
 +            score -= make_score(PieceValue[MG][Pt] - PieceValue[MG][pos.unpromoted_piece_on(s)],
 +                                PieceValue[EG][Pt] - PieceValue[EG][pos.unpromoted_piece_on(s)]) / 4;
 +        else if (pos.captures_to_hand() && pos.unpromoted_piece_on(s))
 +            score += make_score(PieceValue[MG][Pt] - PieceValue[MG][pos.unpromoted_piece_on(s)],
 +                                PieceValue[EG][Pt] - PieceValue[EG][pos.unpromoted_piece_on(s)]) / 8;
 +
 +        // Penalty if the piece is far from the kings in drop variants
 +        if ((pos.captures_to_hand() || pos.two_boards()) && pos.count<KING>(Them) && pos.count<KING>(Us))
 +            score -= KingProximity * distance(s, pos.square<KING>(Us)) * distance(s, pos.square<KING>(Them));
 +
 +        else if (pos.count<KING>(Us) && (Pt == FERS || Pt == SILVER))
 +            score -= EndgameKingProximity * (distance(s, pos.square<KING>(Us)) - 2);
  
          if (Pt == BISHOP || Pt == KNIGHT)
          {
diff --cc src/pawns.cpp
@@@ -154,7 -151,7 +154,7 @@@ namespace 
              if (   (ourPawns & forward_file_bb(Them, s))
                  && popcount(opposed) == 1
                  && !(theirPawns & adjacent_files_bb(s)))
-                 score -= DoubledIsolated * (1 + 2 * pos.must_capture());
 -                score -= Doubled;
++                score -= Doubled * (1 + 2 * pos.must_capture());
          }
  
          else if (backward)
@@@ -223,8 -200,8 +223,8 @@@ Score Entry::evaluate_shelter(const Pos
  
    constexpr Color Them = ~Us;
  
 -  Bitboard b = pos.pieces(PAWN) & ~forward_ranks_bb(Them, ksq);
 +  Bitboard b = pos.pieces(PAWN, SHOGI_PAWN) & ~forward_ranks_bb(Them, ksq);
-   Bitboard ourPawns = b & pos.pieces(Us);
+   Bitboard ourPawns = b & pos.pieces(Us) & ~pawnAttacks[Them];
    Bitboard theirPawns = b & pos.pieces(Them);
  
    Score bonus = make_score(5, 5);
    for (File f = File(center - 1); f <= File(center + 1); ++f)
    {
        b = ourPawns & file_bb(f);
 -      int ourRank = b ? relative_rank(Us, frontmost_sq(Them, b)) : 0;
 +      int ourRank = b ? relative_rank(Us, frontmost_sq(Them, b), pos.max_rank()) : 0;
  
        b = theirPawns & file_bb(f);
 -      int theirRank = b ? relative_rank(Us, frontmost_sq(Them, b)) : 0;
 +      int theirRank = b ? relative_rank(Us, frontmost_sq(Them, b), pos.max_rank()) : 0;
  
 -      int d = edge_distance(f);
 -      bonus += make_score(ShelterStrength[d][ourRank], 0);
 +      int d = std::min(File(edge_distance(f, pos.max_file())), FILE_D);
 +      bonus += make_score(ShelterStrength[d][ourRank], 0) * (1 + (pos.captures_to_hand() && ourRank <= RANK_2)
 +                                                               + (pos.check_counting() && d == 0 && ourRank == RANK_2));
  
        if (ourRank && (ourRank == theirRank - 1))
-           bonus -= BlockedStorm * int(theirRank == RANK_3);
+           bonus -= BlockedStorm[theirRank];
        else
            bonus -= make_score(UnblockedStorm[d][theirRank], 0);
    }