From: Fabian Fichter Date: Fri, 14 Aug 2020 13:55:48 +0000 (+0200) Subject: Merge official-stockfish/master X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=ccfcf6736cc509aca33f1c22c5c74a9e9ec326e0;p=fairystockfish.git Merge official-stockfish/master bench: 5082623 --- ccfcf6736cc509aca33f1c22c5c74a9e9ec326e0 diff --cc src/evaluate.cpp index 30e6944,8e8cc09..f5fda1a --- a/src/evaluate.cpp +++ b/src/evaluate.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(Them) && pos.count(Us)) + score -= KingProximity * distance(s, pos.square(Us)) * distance(s, pos.square(Them)); + + else if (pos.count(Us) && (Pt == FERS || Pt == SILVER)) + score -= EndgameKingProximity * (distance(s, pos.square(Us)) - 2); if (Pt == BISHOP || Pt == KNIGHT) { diff --cc src/pawns.cpp index eacf62b,3ce8963..a40f393 --- a/src/pawns.cpp +++ b/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); @@@ -233,17 -210,16 +233,17 @@@ 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); }