1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-07-11 19:49:14 +00:00

Small cleanups

closes https://github.com/official-stockfish/Stockfish/pull/2546

No functional change.
This commit is contained in:
Joost VandeVondele 2020-03-01 09:31:17 +01:00
parent f27339d35b
commit c6839a2615
8 changed files with 37 additions and 41 deletions

View file

@ -409,7 +409,7 @@ help:
@echo "" @echo ""
.PHONY: help build profile-build strip install clean objclean profileclean help \ .PHONY: help build profile-build strip install clean objclean profileclean \
config-sanity icc-profile-use icc-profile-make gcc-profile-use gcc-profile-make \ config-sanity icc-profile-use icc-profile-make gcc-profile-use gcc-profile-make \
clang-profile-use clang-profile-make clang-profile-use clang-profile-make

View file

@ -154,7 +154,7 @@ inline Bitboard file_bb(Square s) {
} }
/// shift() moves a bitboard one step along direction D /// shift() moves a bitboard one or two steps as specified by the direction D
template<Direction D> template<Direction D>
constexpr Bitboard shift(Bitboard b) { constexpr Bitboard shift(Bitboard b) {

View file

@ -281,7 +281,7 @@ Value Endgame<KQKP>::operator()(const Position& pos) const {
if ( relative_rank(weakSide, pawnSq) != RANK_7 if ( relative_rank(weakSide, pawnSq) != RANK_7
|| distance(loserKSq, pawnSq) != 1 || distance(loserKSq, pawnSq) != 1
|| !((FileABB | FileCBB | FileFBB | FileHBB) & pawnSq)) || ((FileBBB | FileDBB | FileEBB | FileGBB) & pawnSq))
result += QueenValueEg - PawnValueEg; result += QueenValueEg - PawnValueEg;
return strongSide == pos.side_to_move() ? result : -result; return strongSide == pos.side_to_move() ? result : -result;

View file

@ -146,6 +146,7 @@ namespace {
constexpr Score ThreatBySafePawn = S(173, 94); constexpr Score ThreatBySafePawn = S(173, 94);
constexpr Score TrappedRook = S( 52, 10); constexpr Score TrappedRook = S( 52, 10);
constexpr Score WeakQueen = S( 49, 15); constexpr Score WeakQueen = S( 49, 15);
constexpr Score WeakQueenProtection = S( 14, 0);
#undef S #undef S
@ -518,7 +519,7 @@ namespace {
score += Hanging * popcount(weak & b); score += Hanging * popcount(weak & b);
// Additional bonus if weak piece is only protected by a queen // Additional bonus if weak piece is only protected by a queen
score += make_score(14, 0) * popcount(weak & attackedBy[Them][QUEEN]); score += WeakQueenProtection * popcount(weak & attackedBy[Them][QUEEN]);
} }
// Bonus for restricting their piece moves // Bonus for restricting their piece moves
@ -830,8 +831,7 @@ namespace {
Trace::add(TOTAL, score); Trace::add(TOTAL, score);
} }
return (pos.side_to_move() == WHITE ? v : -v) // Side to move point of view return (pos.side_to_move() == WHITE ? v : -v) + Tempo; // Side to move point of view
+ Eval::Tempo;
} }
} // namespace } // namespace

View file

@ -29,8 +29,6 @@ class Position;
namespace Eval { namespace Eval {
constexpr Value Tempo = Value(28); // Must be visible to search
std::string trace(const Position& pos); std::string trace(const Position& pos);
Value evaluate(const Position& pos); Value evaluate(const Position& pos);

View file

@ -22,11 +22,6 @@
#include "types.h" #include "types.h"
Value PieceValue[PHASE_NB][PIECE_NB] = {
{ VALUE_ZERO, PawnValueMg, KnightValueMg, BishopValueMg, RookValueMg, QueenValueMg },
{ VALUE_ZERO, PawnValueEg, KnightValueEg, BishopValueEg, RookValueEg, QueenValueEg }
};
namespace PSQT { namespace PSQT {
#define S(mg, eg) make_score(mg, eg) #define S(mg, eg) make_score(mg, eg)
@ -112,9 +107,6 @@ void init() {
for (Piece pc = W_PAWN; pc <= W_KING; ++pc) for (Piece pc = W_PAWN; pc <= W_KING; ++pc)
{ {
PieceValue[MG][~pc] = PieceValue[MG][pc];
PieceValue[EG][~pc] = PieceValue[EG][pc];
Score score = make_score(PieceValue[MG][pc], PieceValue[EG][pc]); Score score = make_score(PieceValue[MG][pc], PieceValue[EG][pc]);
for (Square s = SQ_A1; s <= SQ_H8; ++s) for (Square s = SQ_A1; s <= SQ_H8; ++s)

View file

@ -819,14 +819,14 @@ namespace {
ss->staticEval = eval = evaluate(pos) + bonus; ss->staticEval = eval = evaluate(pos) + bonus;
} }
else else
ss->staticEval = eval = -(ss-1)->staticEval + 2 * Eval::Tempo; ss->staticEval = eval = -(ss-1)->staticEval + 2 * Tempo;
tte->save(posKey, VALUE_NONE, ttPv, BOUND_NONE, DEPTH_NONE, MOVE_NONE, eval); tte->save(posKey, VALUE_NONE, ttPv, BOUND_NONE, DEPTH_NONE, MOVE_NONE, eval);
} }
// Step 7. Razoring (~1 Elo) // Step 7. Razoring (~1 Elo)
if ( !rootNode // The required rootNode PV handling is not available in qsearch if ( !rootNode // The required rootNode PV handling is not available in qsearch
&& depth < 2 && depth == 1
&& eval <= alpha - RazorMargin) && eval <= alpha - RazorMargin)
return qsearch<NT>(pos, ss, alpha, beta); return qsearch<NT>(pos, ss, alpha, beta);
@ -1434,13 +1434,13 @@ moves_loop: // When in check, search starts from here
else else
ss->staticEval = bestValue = ss->staticEval = bestValue =
(ss-1)->currentMove != MOVE_NULL ? evaluate(pos) (ss-1)->currentMove != MOVE_NULL ? evaluate(pos)
: -(ss-1)->staticEval + 2 * Eval::Tempo; : -(ss-1)->staticEval + 2 * Tempo;
// Stand pat. Return immediately if static value is at least beta // Stand pat. Return immediately if static value is at least beta
if (bestValue >= beta) if (bestValue >= beta)
{ {
if (!ttHit) if (!ttHit)
tte->save(posKey, value_to_tt(bestValue, ss->ply), pvHit, BOUND_LOWER, tte->save(posKey, value_to_tt(bestValue, ss->ply), false, BOUND_LOWER,
DEPTH_NONE, MOVE_NONE, ss->staticEval); DEPTH_NONE, MOVE_NONE, ss->staticEval);
return bestValue; return bestValue;
@ -1667,7 +1667,7 @@ moves_loop: // When in check, search starts from here
// update_continuation_histories() updates histories of the move pairs formed // update_continuation_histories() updates histories of the move pairs formed
// by moves at ply -1, -2, and -4 with current move. // by moves at ply -1, -2, -4, and -6 with current move.
void update_continuation_histories(Stack* ss, Piece pc, Square to, int bonus) { void update_continuation_histories(Stack* ss, Piece pc, Square to, int bonus) {

View file

@ -186,6 +186,7 @@ enum Value : int {
BishopValueMg = 825, BishopValueEg = 915, BishopValueMg = 825, BishopValueEg = 915,
RookValueMg = 1276, RookValueEg = 1380, RookValueMg = 1276, RookValueEg = 1380,
QueenValueMg = 2538, QueenValueEg = 2682, QueenValueMg = 2538, QueenValueEg = 2682,
Tempo = 28,
MidgameLimit = 15258, EndgameLimit = 3915 MidgameLimit = 15258, EndgameLimit = 3915
}; };
@ -203,7 +204,12 @@ enum Piece {
PIECE_NB = 16 PIECE_NB = 16
}; };
extern Value PieceValue[PHASE_NB][PIECE_NB]; constexpr Value PieceValue[PHASE_NB][PIECE_NB] = {
{ VALUE_ZERO, PawnValueMg, KnightValueMg, BishopValueMg, RookValueMg, QueenValueMg, VALUE_ZERO, VALUE_ZERO,
VALUE_ZERO, PawnValueMg, KnightValueMg, BishopValueMg, RookValueMg, QueenValueMg, VALUE_ZERO, VALUE_ZERO },
{ VALUE_ZERO, PawnValueEg, KnightValueEg, BishopValueEg, RookValueEg, QueenValueEg, VALUE_ZERO, VALUE_ZERO,
VALUE_ZERO, PawnValueEg, KnightValueEg, BishopValueEg, RookValueEg, QueenValueEg, VALUE_ZERO, VALUE_ZERO }
};
typedef int Depth; typedef int Depth;