No functional change.
Resolves #601
}
- // 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<Color Us, bool DoTrace>
// status of the players.
Score evaluate_initiative(const Position& pos, int asymmetry, Value eg) {
- int kingDistance = distance<File>(pos.square<KING>(WHITE), pos.square<KING>(BLACK))
- - distance<Rank>(pos.square<KING>(WHITE), pos.square<KING>(BLACK));
+ int kingDistance = distance<File>(pos.square<KING>(WHITE), pos.square<KING>(BLACK))
+ - distance<Rank>(pos.square<KING>(WHITE), pos.square<KING>(BLACK));
int pawns = pos.count<PAWN>(WHITE) + pos.count<PAWN>(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
/// 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);
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);
}
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());
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)];
}
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();
}
template<Color Us>
- 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<Us>(pos, ksq));
}
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)
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)
}
- // 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) {
return Piece((c << 3) | pt);
}
-inline PieceType type_of(Piece pc) {
+inline PieceType type_of(Piece pc) {
return PieceType(pc & 7);
}