1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-04-30 08:43:09 +00:00

Assorted cleanup of latest commits

No functional change.

Resolves #601
This commit is contained in:
Marco Costalba 2016-03-13 09:35:03 +01:00 committed by Joona Kiiski
parent a273b6ef8c
commit 647402ff79
6 changed files with 23 additions and 22 deletions

View file

@ -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. // and the attacked pieces.
template<Color Us, bool DoTrace> template<Color Us, bool DoTrace>
@ -679,12 +679,12 @@ namespace {
// status of the players. // status of the players.
Score evaluate_initiative(const Position& pos, int asymmetry, Value eg) { Score evaluate_initiative(const Position& pos, int asymmetry, Value eg) {
int kingDistance = distance<File>(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)); - distance<Rank>(pos.square<KING>(WHITE), pos.square<KING>(BLACK));
int pawns = pos.count<PAWN>(WHITE) + pos.count<PAWN>(BLACK); int pawns = pos.count<PAWN>(WHITE) + pos.count<PAWN>(BLACK);
// Compute the initiative bonus for the attacking side // 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 // 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 // the sign of the endgame value, and that we carefully cap the bonus so

View file

@ -68,8 +68,10 @@ namespace {
/// ordering is at the current node. /// ordering is at the current node.
MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const HistoryStats& h, MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const HistoryStats& h,
const CounterMoveStats& cmh, const CounterMoveStats& fmh, Move cm, Search::Stack* s) const CounterMoveStats& cmh, const CounterMoveStats& fmh,
: pos(p), history(h), counterMoveHistory(&cmh), followupMoveHistory(&fmh), ss(s), countermove(cm), depth(d) { Move cm, Search::Stack* s)
: pos(p), history(h), counterMoveHistory(&cmh),
followupMoveHistory(&fmh), ss(s), countermove(cm), depth(d) {
assert(d > DEPTH_ZERO); 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, MovePicker::MovePicker(const Position& p, Move ttm, Depth d,
const HistoryStats& h, Square s) const HistoryStats& h, Square s)
: pos(p), history(h), counterMoveHistory(nullptr), followupMoveHistory(nullptr) { : pos(p), history(h) {
assert(d <= DEPTH_ZERO); 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) 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()); assert(!pos.checkers());
@ -142,7 +144,7 @@ void MovePicker::score<QUIETS>() {
for (auto& m : *this) for (auto& m : *this)
m.value = history[pos.moved_piece(m)][to_sq(m)] 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)]; + (*followupMoveHistory)[pos.moved_piece(m)][to_sq(m)];
} }

View file

@ -83,9 +83,10 @@ public:
MovePicker(const MovePicker&) = delete; MovePicker(const MovePicker&) = delete;
MovePicker& operator=(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, 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(); Move next_move();

View file

@ -53,7 +53,7 @@ struct Entry {
} }
template<Color Us> 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) return kingSquares[Us] == ksq && castlingRights[Us] == pos.can_castle(Us)
? kingSafety[Us] : (kingSafety[Us] = do_king_safety<Us>(pos, ksq)); ? kingSafety[Us] : (kingSafety[Us] = do_king_safety<Us>(pos, ksq));
} }

View file

@ -179,8 +179,6 @@ namespace {
void Search::init() { void Search::init() {
const bool PV=true;
for (int imp = 0; imp <= 1; ++imp) for (int imp = 0; imp <= 1; ++imp)
for (int d = 1; d < 64; ++d) for (int d = 1; d < 64; ++d)
for (int mc = 1; mc < 64; ++mc) for (int mc = 1; mc < 64; ++mc)
@ -189,12 +187,12 @@ void Search::init() {
if (r < 0.80) if (r < 0.80)
continue; continue;
Reductions[!PV][imp][d][mc] = int(std::round(r)) * ONE_PLY; Reductions[NonPV][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[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 // Increase reduction for non-PV nodes when eval is not improving
if (!imp && Reductions[!PV][imp][d][mc] >= 2 * ONE_PLY) if (!imp && Reductions[NonPV][imp][d][mc] >= 2 * ONE_PLY)
Reductions[!PV][imp][d][mc] += ONE_PLY; Reductions[NonPV][imp][d][mc] += ONE_PLY;
} }
for (int d = 0; d < 16; ++d) 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 // update_stats() updates killers, history, countermove and countermove plus
// history when a new quiet best move is found. // follow-up move history when a new quiet best move is found.
void update_stats(const Position& pos, Stack* ss, Move move, void update_stats(const Position& pos, Stack* ss, Move move,
Depth depth, Move* quiets, int quietsCnt) { Depth depth, Move* quiets, int quietsCnt) {

View file

@ -355,7 +355,7 @@ inline Piece make_piece(Color c, PieceType pt) {
return Piece((c << 3) | pt); return Piece((c << 3) | pt);
} }
inline PieceType type_of(Piece pc) { inline PieceType type_of(Piece pc) {
return PieceType(pc & 7); return PieceType(pc & 7);
} }