From 647402ff7910ff26f5d6b967812d85f5f4259fee Mon Sep 17 00:00:00 2001 From: Marco Costalba Date: Sun, 13 Mar 2016 09:35:03 +0100 Subject: [PATCH] Assorted cleanup of latest commits No functional change. Resolves #601 --- src/evaluate.cpp | 8 ++++---- src/movepick.cpp | 12 +++++++----- src/movepick.h | 5 +++-- src/pawns.h | 2 +- src/search.cpp | 16 +++++++--------- src/types.h | 2 +- 6 files changed, 23 insertions(+), 22 deletions(-) diff --git a/src/evaluate.cpp b/src/evaluate.cpp index c0e94cda..d0401432 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -467,7 +467,7 @@ namespace { } - // evaluate_threats() assigns bonuses according to the types of the attacking + // evaluate_threats() assigns bonuses according to the types of the attacking // and the attacked pieces. template @@ -679,12 +679,12 @@ namespace { // status of the players. Score evaluate_initiative(const Position& pos, int asymmetry, Value eg) { - int kingDistance = distance(pos.square(WHITE), pos.square(BLACK)) - - distance(pos.square(WHITE), pos.square(BLACK)); + int kingDistance = distance(pos.square(WHITE), pos.square(BLACK)) + - distance(pos.square(WHITE), pos.square(BLACK)); int pawns = pos.count(WHITE) + pos.count(BLACK); // Compute the initiative bonus for the attacking side - int initiative = 8 * (asymmetry + kingDistance) + 12 * pawns - 120; + int initiative = 8 * (asymmetry + kingDistance - 15) + 12 * pawns; // Now apply the bonus: note that we find the attacking side by extracting // the sign of the endgame value, and that we carefully cap the bonus so diff --git a/src/movepick.cpp b/src/movepick.cpp index 0859d772..c5238494 100644 --- a/src/movepick.cpp +++ b/src/movepick.cpp @@ -68,8 +68,10 @@ namespace { /// ordering is at the current node. MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const HistoryStats& h, - const CounterMoveStats& cmh, const CounterMoveStats& fmh, Move cm, Search::Stack* s) - : pos(p), history(h), counterMoveHistory(&cmh), followupMoveHistory(&fmh), ss(s), countermove(cm), depth(d) { + const CounterMoveStats& cmh, const CounterMoveStats& fmh, + Move cm, Search::Stack* s) + : pos(p), history(h), counterMoveHistory(&cmh), + followupMoveHistory(&fmh), ss(s), countermove(cm), depth(d) { assert(d > DEPTH_ZERO); @@ -80,7 +82,7 @@ MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const HistoryStats& MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const HistoryStats& h, Square s) - : pos(p), history(h), counterMoveHistory(nullptr), followupMoveHistory(nullptr) { + : pos(p), history(h) { assert(d <= DEPTH_ZERO); @@ -105,7 +107,7 @@ MovePicker::MovePicker(const Position& p, Move ttm, Depth d, } MovePicker::MovePicker(const Position& p, Move ttm, const HistoryStats& h, Value th) - : pos(p), history(h), counterMoveHistory(nullptr), followupMoveHistory(nullptr), threshold(th) { + : pos(p), history(h), threshold(th) { assert(!pos.checkers()); @@ -142,7 +144,7 @@ void MovePicker::score() { for (auto& m : *this) m.value = history[pos.moved_piece(m)][to_sq(m)] - + (*counterMoveHistory)[pos.moved_piece(m)][to_sq(m)] + + (*counterMoveHistory )[pos.moved_piece(m)][to_sq(m)] + (*followupMoveHistory)[pos.moved_piece(m)][to_sq(m)]; } diff --git a/src/movepick.h b/src/movepick.h index a7140846..73fbbddb 100644 --- a/src/movepick.h +++ b/src/movepick.h @@ -83,9 +83,10 @@ public: MovePicker(const MovePicker&) = delete; MovePicker& operator=(const MovePicker&) = delete; - MovePicker(const Position&, Move, Depth, const HistoryStats&, Square); MovePicker(const Position&, Move, const HistoryStats&, Value); - MovePicker(const Position&, Move, Depth, const HistoryStats&, const CounterMoveStats&, const CounterMoveStats&, Move, Search::Stack*); + MovePicker(const Position&, Move, Depth, const HistoryStats&, Square); + MovePicker(const Position&, Move, Depth, const HistoryStats&, + const CounterMoveStats&, const CounterMoveStats&, Move, Search::Stack*); Move next_move(); diff --git a/src/pawns.h b/src/pawns.h index d46ff4cd..c2f5fc0d 100644 --- a/src/pawns.h +++ b/src/pawns.h @@ -53,7 +53,7 @@ struct Entry { } template - Score king_safety(const Position& pos, Square ksq) { + Score king_safety(const Position& pos, Square ksq) { return kingSquares[Us] == ksq && castlingRights[Us] == pos.can_castle(Us) ? kingSafety[Us] : (kingSafety[Us] = do_king_safety(pos, ksq)); } diff --git a/src/search.cpp b/src/search.cpp index 39131bd5..dc488c2b 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -179,8 +179,6 @@ namespace { void Search::init() { - const bool PV=true; - for (int imp = 0; imp <= 1; ++imp) for (int d = 1; d < 64; ++d) for (int mc = 1; mc < 64; ++mc) @@ -189,12 +187,12 @@ void Search::init() { if (r < 0.80) continue; - Reductions[!PV][imp][d][mc] = int(std::round(r)) * ONE_PLY; - Reductions[PV][imp][d][mc] = std::max(Reductions[!PV][imp][d][mc] - ONE_PLY, DEPTH_ZERO); - + Reductions[NonPV][imp][d][mc] = int(std::round(r)) * ONE_PLY; + Reductions[PV][imp][d][mc] = std::max(Reductions[NonPV][imp][d][mc] - ONE_PLY, DEPTH_ZERO); + // Increase reduction for non-PV nodes when eval is not improving - if (!imp && Reductions[!PV][imp][d][mc] >= 2 * ONE_PLY) - Reductions[!PV][imp][d][mc] += ONE_PLY; + if (!imp && Reductions[NonPV][imp][d][mc] >= 2 * ONE_PLY) + Reductions[NonPV][imp][d][mc] += ONE_PLY; } for (int d = 0; d < 16; ++d) @@ -1429,8 +1427,8 @@ moves_loop: // When in check search starts from here } - // update_stats() updates killers, history, countermove and countermove - // history when a new quiet best move is found. + // update_stats() updates killers, history, countermove and countermove plus + // follow-up move history when a new quiet best move is found. void update_stats(const Position& pos, Stack* ss, Move move, Depth depth, Move* quiets, int quietsCnt) { diff --git a/src/types.h b/src/types.h index 9b7e538d..aa015ce5 100644 --- a/src/types.h +++ b/src/types.h @@ -355,7 +355,7 @@ inline Piece make_piece(Color c, PieceType pt) { return Piece((c << 3) | pt); } -inline PieceType type_of(Piece pc) { +inline PieceType type_of(Piece pc) { return PieceType(pc & 7); } -- 2.39.2