Skip to content

Commit

Permalink
Assorted cleanup of latest commits
Browse files Browse the repository at this point in the history
No functional change.
  • Loading branch information
mcostalba committed Mar 14, 2016
1 parent a273b6e commit eacca9c
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 22 deletions.
8 changes: 4 additions & 4 deletions src/evaluate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Color Us, bool DoTrace>
Expand Down Expand Up @@ -679,12 +679,12 @@ namespace {
// 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
Expand Down
12 changes: 7 additions & 5 deletions src/movepick.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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);

Expand All @@ -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());

Expand Down Expand Up @@ -142,7 +144,7 @@ void MovePicker::score<QUIETS>() {

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)];
}

Expand Down
5 changes: 3 additions & 2 deletions src/movepick.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,10 @@ class MovePicker {
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();

Expand Down
2 changes: 1 addition & 1 deletion src/pawns.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ struct Entry {
}

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));
}
Expand Down
16 changes: 7 additions & 9 deletions src/search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -1429,8 +1427,8 @@ namespace {
}


// 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) {
Expand Down
2 changes: 1 addition & 1 deletion src/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit eacca9c

Please sign in to comment.