From: Fabian Fichter Date: Sun, 13 Sep 2020 17:24:30 +0000 (+0200) Subject: Merge official-stockfish/master X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=2ae4b4f9d5900f6dfce23786eb2ae7b4907b794c;p=fairystockfish.git Merge official-stockfish/master No functional change. --- 2ae4b4f9d5900f6dfce23786eb2ae7b4907b794c diff --cc src/evaluate.cpp index 8f2a3ee,3b0891a..dc508ef --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@@ -895,9 -684,8 +893,10 @@@ namespace template template Score Evaluation::space() const { + bool pawnsOnly = !(pos.pieces(Us) ^ pos.pieces(Us, PAWN)); + + // Early exit if, for example, both queens or 6 minor pieces have been exchanged - if (pos.non_pawn_material() < SpaceThreshold) + if (pos.non_pawn_material() < SpaceThreshold && !pos.captures_to_hand() && !pawnsOnly && pos.double_step_enabled()) return SCORE_ZERO; constexpr Color Them = ~Us; diff --cc src/movepick.h index c1dc566,aaff388..d736cff --- a/src/movepick.h +++ b/src/movepick.h @@@ -86,13 -86,13 +86,13 @@@ enum StatsType { NoCaptures, Captures } /// unsuccessful during the current search, and is used for reduction and move /// ordering decisions. It uses 2 tables (one for each color) indexed by /// the move's from and to squares, see www.chessprogramming.org/Butterfly_Boards -typedef Stats ButterflyHistory; +typedef Stats ButterflyHistory; - /// LowPlyHistory at higher depths records successful quiet moves on plies 0 to 3 - /// and quiet moves which are/were in the PV (ttPv) - /// It get cleared with each new search and get filled during iterative deepening + /// At higher depths LowPlyHistory records successful quiet moves near the root and quiet + /// moves which are/were in the PV (ttPv) + /// It is cleared with each new search and filled during iterative deepening constexpr int MAX_LPH = 4; -typedef Stats LowPlyHistory; +typedef Stats LowPlyHistory; /// CounterMoveHistory stores counter moves indexed by [piece][to] of the previous /// move, see www.chessprogramming.org/Countermove_Heuristic diff --cc src/pawns.cpp index de61974,597dff2..76223f0 --- a/src/pawns.cpp +++ b/src/pawns.cpp @@@ -151,41 -148,21 +151,41 @@@ namespace if ( opposed && (ourPawns & forward_file_bb(Them, s)) && !(theirPawns & adjacent_files_bb(s))) - score -= Doubled; + score -= Doubled * (1 + 2 * pos.must_capture()); else - score -= Isolated * (1 + 2 * pos.must_capture()) - + WeakUnopposed * !opposed; - score -= Isolated ++ score -= Isolated * (1 + 2 * pos.must_capture()) + + WeakUnopposed * !opposed; } else if (backward) - score -= Backward - + WeakUnopposed * !opposed; + score -= Backward + + WeakUnopposed * !opposed; if (!support) - score -= Doubled * doubled - + WeakLever * more_than_one(lever); + score -= Doubled * doubled + + WeakLever * more_than_one(lever); } + // Double pawn evaluation if there are no non-pawn pieces + if (pos.count(Us) == pos.count(Us)) + score = score * 2; + + const Square* pl_shogi = pos.squares(Us); + + ourPawns = pos.pieces(Us, SHOGI_PAWN); + theirPawns = pos.pieces(Them, SHOGI_PAWN); + + // Loop through all shogi pawns of the current color and score each one + while ((s = *pl_shogi++) != SQ_NONE) + { + assert(pos.piece_on(s) == make_piece(Us, SHOGI_PAWN)); + + neighbours = ourPawns & adjacent_files_bb(s); + + if (!neighbours) + score -= Isolated / 2; + } + return score; } diff --cc src/syzygy/tbprobe.cpp index 0c6fdc6,95d5894..fd07cf9 --- a/src/syzygy/tbprobe.cpp +++ b/src/syzygy/tbprobe.cpp @@@ -1371,8 -1362,8 +1371,8 @@@ void Tablebases::init(const std::string LeadPawnsSize[leadPawnsCnt][f] = idx; } - // Add entries in TB tables if the corresponding ".rtbw" file exsists + // Add entries in TB tables if the corresponding ".rtbw" file exists - for (PieceType p1 = PAWN; p1 < KING; ++p1) { + for (PieceType p1 = PAWN; p1 <= QUEEN; ++p1) { TBTables.add({KING, p1, KING}); for (PieceType p2 = PAWN; p2 <= p1; ++p2) { diff --cc src/types.h index 9c8712b,969d4e6..8c5c28d --- a/src/types.h +++ b/src/types.h @@@ -568,21 -279,12 +566,21 @@@ inline Value mg_value(Score s) return Value(mg.s); } +#define ENABLE_BIT_OPERATORS_ON(T) \ +inline T operator~ (T d) { return (T)~(int)d; } \ +inline T operator| (T d1, T d2) { return (T)((int)d1 | (int)d2); } \ +inline T operator& (T d1, T d2) { return (T)((int)d1 & (int)d2); } \ +inline T operator^ (T d1, T d2) { return (T)((int)d1 ^ (int)d2); } \ +inline T& operator|= (T& d1, T d2) { return (T&)((int&)d1 |= (int)d2); } \ +inline T& operator&= (T& d1, T d2) { return (T&)((int&)d1 &= (int)d2); } \ +inline T& operator^= (T& d1, T d2) { return (T&)((int&)d1 ^= (int)d2); } + #define ENABLE_BASE_OPERATORS_ON(T) \ - constexpr T operator+(T d1, T d2) { return T(int(d1) + int(d2)); } \ - constexpr T operator-(T d1, T d2) { return T(int(d1) - int(d2)); } \ + constexpr T operator+(T d1, int d2) { return T(int(d1) + d2); } \ + constexpr T operator-(T d1, int d2) { return T(int(d1) - d2); } \ constexpr T operator-(T d) { return T(-int(d)); } \ - inline T& operator+=(T& d1, T d2) { return d1 = d1 + d2; } \ - inline T& operator-=(T& d1, T d2) { return d1 = d1 - d2; } + inline T& operator+=(T& d1, int d2) { return d1 = d1 + d2; } \ + inline T& operator-=(T& d1, int d2) { return d1 = d1 - d2; } #define ENABLE_INCR_OPERATORS_ON(T) \ inline T& operator++(T& d) { return d = T(int(d) + 1); } \ @@@ -614,14 -312,7 +611,8 @@@ ENABLE_BIT_OPERATORS_ON(RiderType #undef ENABLE_FULL_OPERATORS_ON #undef ENABLE_INCR_OPERATORS_ON #undef ENABLE_BASE_OPERATORS_ON +#undef ENABLE_BIT_OPERATORS_ON - /// Additional operators to add integers to a Value - constexpr Value operator+(Value v, int i) { return Value(int(v) + i); } - constexpr Value operator-(Value v, int i) { return Value(int(v) - i); } - inline Value& operator+=(Value& v, int i) { return v = v + i; } - inline Value& operator-=(Value& v, int i) { return v = v - i; } - /// Additional operators to add a Direction to a Square constexpr Square operator+(Square s, Direction d) { return Square(int(s) + int(d)); } constexpr Square operator-(Square s, Direction d) { return Square(int(s) - int(d)); } @@@ -787,25 -447,12 +778,25 @@@ constexpr Move reverse_move(Move m) } template -constexpr Move make(Square from, Square to, PieceType pt = KNIGHT) { - return Move(T + ((pt - KNIGHT) << 12) + (from << 6) + to); +constexpr Move make_gating(Square from, Square to, PieceType pt, Square gate) { + return Move((gate << (2 * SQUARE_BITS + MOVE_TYPE_BITS + PIECE_TYPE_BITS)) + (pt << (2 * SQUARE_BITS + MOVE_TYPE_BITS)) + T + (from << SQUARE_BITS) + to); +} + +constexpr PieceType dropped_piece_type(Move m) { + return PieceType((m >> (2 * SQUARE_BITS + MOVE_TYPE_BITS)) & (PIECE_TYPE_NB - 1)); +} + +constexpr PieceType in_hand_piece_type(Move m) { + return PieceType((m >> (2 * SQUARE_BITS + MOVE_TYPE_BITS + PIECE_TYPE_BITS)) & (PIECE_TYPE_NB - 1)); +} + +inline bool is_ok(Move m) { + return from_sq(m) != to_sq(m) || type_of(m) == PROMOTION || type_of(m) == SPECIAL; // Catch MOVE_NULL and MOVE_NONE } -constexpr bool is_ok(Move m) { - return from_sq(m) != to_sq(m); // Catch MOVE_NULL and MOVE_NONE +inline int dist(Direction d) { - return std::abs(d % NORTH) < NORTH / 2 ? std::max(std::abs(d / NORTH), std::abs(d % NORTH)) - : std::max(std::abs(d / NORTH) + 1, NORTH - std::abs(d % NORTH)); ++ return std::abs(d % NORTH) < NORTH / 2 ? std::max(std::abs(d / NORTH), int(std::abs(d % NORTH))) ++ : std::max(std::abs(d / NORTH) + 1, int(NORTH - std::abs(d % NORTH))); } #endif // #ifndef TYPES_H_INCLUDED