mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-21 09:37:16 +08:00
Changes identified in RENAME/REFORMATTING thread (#1861)
I've gone through the RENAME/REFORMATTING thread and changed everything I could find, plus a few more. With this, let's close the previous issue and open another. No functional change.
This commit is contained in:
committed by
Marco Costalba
parent
e8ffca3eb4
commit
e917bd59b1
2
AUTHORS
2
AUTHORS
@@ -88,7 +88,7 @@ Michael Chaly (Vizvezdenec)
|
|||||||
Michel Van den Bergh (vdbergh)
|
Michel Van den Bergh (vdbergh)
|
||||||
Miguel Lahoz (miguel-l)
|
Miguel Lahoz (miguel-l)
|
||||||
Mikael Bäckman (mbootsector)
|
Mikael Bäckman (mbootsector)
|
||||||
Mike Whiteley (protonspring)
|
Michael Whiteley (protonspring)
|
||||||
Miroslav Fontán (Hexik)
|
Miroslav Fontán (Hexik)
|
||||||
Moez Jellouli (MJZ1977)
|
Moez Jellouli (MJZ1977)
|
||||||
Mohammed Li (tthsqe12)
|
Mohammed Li (tthsqe12)
|
||||||
|
|||||||
@@ -381,7 +381,7 @@ namespace {
|
|||||||
{
|
{
|
||||||
File kf = file_of(pos.square<KING>(Us));
|
File kf = file_of(pos.square<KING>(Us));
|
||||||
if ((kf < FILE_E) == (file_of(s) < kf))
|
if ((kf < FILE_E) == (file_of(s) < kf))
|
||||||
score -= (TrappedRook - make_score(mob * 22, 0)) * (1 + !pos.can_castle(Us));
|
score -= (TrappedRook - make_score(mob * 22, 0)) * (1 + !pos.castling_rights(Us));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -512,7 +512,7 @@ namespace {
|
|||||||
Score score = SCORE_ZERO;
|
Score score = SCORE_ZERO;
|
||||||
|
|
||||||
// Non-pawn enemies
|
// Non-pawn enemies
|
||||||
nonPawnEnemies = pos.pieces(Them) ^ pos.pieces(Them, PAWN);
|
nonPawnEnemies = pos.pieces(Them) & ~pos.pieces(Them, PAWN);
|
||||||
|
|
||||||
// Squares strongly protected by the enemy, either because they defend the
|
// Squares strongly protected by the enemy, either because they defend the
|
||||||
// square with a pawn, or because they defend the square twice and we don't.
|
// square with a pawn, or because they defend the square twice and we don't.
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ struct Entry {
|
|||||||
Key key;
|
Key key;
|
||||||
const EndgameBase<Value>* evaluationFunction;
|
const EndgameBase<Value>* evaluationFunction;
|
||||||
const EndgameBase<ScaleFactor>* scalingFunction[COLOR_NB]; // Could be one for each
|
const EndgameBase<ScaleFactor>* scalingFunction[COLOR_NB]; // Could be one for each
|
||||||
// side (e.g. KPKP, KBPsKs)
|
// side (e.g. KPKP, KBPsK)
|
||||||
int16_t value;
|
int16_t value;
|
||||||
uint8_t factor[COLOR_NB];
|
uint8_t factor[COLOR_NB];
|
||||||
Phase gamePhase;
|
Phase gamePhase;
|
||||||
|
|||||||
@@ -278,7 +278,7 @@ namespace {
|
|||||||
*moveList++ = make_move(ksq, pop_lsb(&b));
|
*moveList++ = make_move(ksq, pop_lsb(&b));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Type != CAPTURES && Type != EVASIONS && pos.can_castle(Us))
|
if (Type != CAPTURES && Type != EVASIONS && pos.castling_rights(Us))
|
||||||
{
|
{
|
||||||
if (pos.is_chess960())
|
if (pos.is_chess960())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ namespace {
|
|||||||
constexpr Color Them = (Us == WHITE ? BLACK : WHITE);
|
constexpr Color Them = (Us == WHITE ? BLACK : WHITE);
|
||||||
constexpr Direction Up = (Us == WHITE ? NORTH : SOUTH);
|
constexpr Direction Up = (Us == WHITE ? NORTH : SOUTH);
|
||||||
|
|
||||||
Bitboard b, neighbours, stoppers, doubled, supported, phalanx;
|
Bitboard b, neighbours, stoppers, doubled, support, phalanx;
|
||||||
Bitboard lever, leverPush;
|
Bitboard lever, leverPush;
|
||||||
Square s;
|
Square s;
|
||||||
bool opposed, backward;
|
bool opposed, backward;
|
||||||
@@ -102,7 +102,7 @@ namespace {
|
|||||||
doubled = ourPawns & (s - Up);
|
doubled = ourPawns & (s - Up);
|
||||||
neighbours = ourPawns & adjacent_files_bb(f);
|
neighbours = ourPawns & adjacent_files_bb(f);
|
||||||
phalanx = neighbours & rank_bb(s);
|
phalanx = neighbours & rank_bb(s);
|
||||||
supported = neighbours & rank_bb(s - Up);
|
support = neighbours & rank_bb(s - Up);
|
||||||
|
|
||||||
// A pawn is backward when it is behind all pawns of the same color
|
// A pawn is backward when it is behind all pawns of the same color
|
||||||
// on the adjacent files and cannot be safely advanced.
|
// on the adjacent files and cannot be safely advanced.
|
||||||
@@ -114,22 +114,22 @@ namespace {
|
|||||||
// which could become passed after one or two pawn pushes when are
|
// which could become passed after one or two pawn pushes when are
|
||||||
// not attacked more times than defended.
|
// not attacked more times than defended.
|
||||||
if ( !(stoppers ^ lever ^ leverPush)
|
if ( !(stoppers ^ lever ^ leverPush)
|
||||||
&& popcount(supported) >= popcount(lever) - 1
|
&& popcount(support) >= popcount(lever) - 1
|
||||||
&& popcount(phalanx) >= popcount(leverPush))
|
&& popcount(phalanx) >= popcount(leverPush))
|
||||||
e->passedPawns[Us] |= s;
|
e->passedPawns[Us] |= s;
|
||||||
|
|
||||||
else if ( stoppers == SquareBB[s + Up]
|
else if ( stoppers == SquareBB[s + Up]
|
||||||
&& relative_rank(Us, s) >= RANK_5)
|
&& relative_rank(Us, s) >= RANK_5)
|
||||||
{
|
{
|
||||||
b = shift<Up>(supported) & ~theirPawns;
|
b = shift<Up>(support) & ~theirPawns;
|
||||||
while (b)
|
while (b)
|
||||||
if (!more_than_one(theirPawns & PawnAttacks[Us][pop_lsb(&b)]))
|
if (!more_than_one(theirPawns & PawnAttacks[Us][pop_lsb(&b)]))
|
||||||
e->passedPawns[Us] |= s;
|
e->passedPawns[Us] |= s;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Score this pawn
|
// Score this pawn
|
||||||
if (supported | phalanx)
|
if (support | phalanx)
|
||||||
score += Connected[opposed][bool(phalanx)][popcount(supported)][relative_rank(Us, s)];
|
score += Connected[opposed][bool(phalanx)][popcount(support)][relative_rank(Us, s)];
|
||||||
|
|
||||||
else if (!neighbours)
|
else if (!neighbours)
|
||||||
score -= Isolated, e->weakUnopposed[Us] += !opposed;
|
score -= Isolated, e->weakUnopposed[Us] += !opposed;
|
||||||
@@ -137,7 +137,7 @@ namespace {
|
|||||||
else if (backward)
|
else if (backward)
|
||||||
score -= Backward, e->weakUnopposed[Us] += !opposed;
|
score -= Backward, e->weakUnopposed[Us] += !opposed;
|
||||||
|
|
||||||
if (doubled && !supported)
|
if (doubled && !support)
|
||||||
score -= Doubled;
|
score -= Doubled;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -214,10 +214,10 @@ Value Entry::evaluate_shelter(const Position& pos, Square ksq) {
|
|||||||
for (File f = File(center - 1); f <= File(center + 1); ++f)
|
for (File f = File(center - 1); f <= File(center + 1); ++f)
|
||||||
{
|
{
|
||||||
b = ourPawns & file_bb(f);
|
b = ourPawns & file_bb(f);
|
||||||
int ourRank = b ? relative_rank(Us, backmost_sq(Us, b)) : 0;
|
Rank ourRank = b ? relative_rank(Us, backmost_sq(Us, b)) : RANK_1;
|
||||||
|
|
||||||
b = theirPawns & file_bb(f);
|
b = theirPawns & file_bb(f);
|
||||||
int theirRank = b ? relative_rank(Us, frontmost_sq(Them, b)) : 0;
|
Rank theirRank = b ? relative_rank(Us, frontmost_sq(Them, b)) : RANK_1;
|
||||||
|
|
||||||
int d = std::min(f, ~f);
|
int d = std::min(f, ~f);
|
||||||
safety += ShelterStrength[d][ourRank];
|
safety += ShelterStrength[d][ourRank];
|
||||||
@@ -237,7 +237,7 @@ Score Entry::do_king_safety(const Position& pos) {
|
|||||||
|
|
||||||
Square ksq = pos.square<KING>(Us);
|
Square ksq = pos.square<KING>(Us);
|
||||||
kingSquares[Us] = ksq;
|
kingSquares[Us] = ksq;
|
||||||
castlingRights[Us] = pos.can_castle(Us);
|
castlingRights[Us] = pos.castling_rights(Us);
|
||||||
int minKingPawnDistance = 0;
|
int minKingPawnDistance = 0;
|
||||||
|
|
||||||
Bitboard pawns = pos.pieces(Us, PAWN);
|
Bitboard pawns = pos.pieces(Us, PAWN);
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ struct Entry {
|
|||||||
|
|
||||||
template<Color Us>
|
template<Color Us>
|
||||||
Score king_safety(const Position& pos) {
|
Score king_safety(const Position& pos) {
|
||||||
return kingSquares[Us] == pos.square<KING>(Us) && castlingRights[Us] == pos.can_castle(Us)
|
return kingSquares[Us] == pos.square<KING>(Us) && castlingRights[Us] == pos.castling_rights(Us)
|
||||||
? kingSafety[Us] : (kingSafety[Us] = do_king_safety<Us>(pos));
|
? kingSafety[Us] : (kingSafety[Us] = do_king_safety<Us>(pos));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -476,7 +476,7 @@ const string Position::fen() const {
|
|||||||
if (can_castle(BLACK_OOO))
|
if (can_castle(BLACK_OOO))
|
||||||
ss << (chess960 ? char('a' + file_of(castling_rook_square(BLACK | QUEEN_SIDE))) : 'q');
|
ss << (chess960 ? char('a' + file_of(castling_rook_square(BLACK | QUEEN_SIDE))) : 'q');
|
||||||
|
|
||||||
if (!can_castle(WHITE) && !can_castle(BLACK))
|
if (!can_castle(ANY_CASTLING))
|
||||||
ss << '-';
|
ss << '-';
|
||||||
|
|
||||||
ss << (ep_square() == SQ_NONE ? " - " : " " + UCI::square(ep_square()) + " ")
|
ss << (ep_square() == SQ_NONE ? " - " : " " + UCI::square(ep_square()) + " ")
|
||||||
|
|||||||
@@ -97,8 +97,8 @@ public:
|
|||||||
template<PieceType Pt> Square square(Color c) const;
|
template<PieceType Pt> Square square(Color c) const;
|
||||||
|
|
||||||
// Castling
|
// Castling
|
||||||
int can_castle(Color c) const;
|
int castling_rights(Color c) const;
|
||||||
int can_castle(CastlingRight cr) const;
|
bool can_castle(CastlingRight cr) const;
|
||||||
bool castling_impeded(CastlingRight cr) const;
|
bool castling_impeded(CastlingRight cr) const;
|
||||||
Square castling_rook_square(CastlingRight cr) const;
|
Square castling_rook_square(CastlingRight cr) const;
|
||||||
|
|
||||||
@@ -260,11 +260,11 @@ inline Square Position::ep_square() const {
|
|||||||
return st->epSquare;
|
return st->epSquare;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int Position::can_castle(CastlingRight cr) const {
|
inline bool Position::can_castle(CastlingRight cr) const {
|
||||||
return st->castlingRights & cr;
|
return st->castlingRights & cr;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int Position::can_castle(Color c) const {
|
inline int Position::castling_rights(Color c) const {
|
||||||
return st->castlingRights & ((WHITE_OO | WHITE_OOO) << (2 * c));
|
return st->castlingRights & ((WHITE_OO | WHITE_OOO) << (2 * c));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -826,8 +826,8 @@ namespace {
|
|||||||
&& depth >= 5 * ONE_PLY
|
&& depth >= 5 * ONE_PLY
|
||||||
&& abs(beta) < VALUE_MATE_IN_MAX_PLY)
|
&& abs(beta) < VALUE_MATE_IN_MAX_PLY)
|
||||||
{
|
{
|
||||||
Value rbeta = std::min(beta + 216 - 48 * improving, VALUE_INFINITE);
|
Value raisedBeta = std::min(beta + 216 - 48 * improving, VALUE_INFINITE);
|
||||||
MovePicker mp(pos, ttMove, rbeta - ss->staticEval, &thisThread->captureHistory);
|
MovePicker mp(pos, ttMove, raisedBeta - ss->staticEval, &thisThread->captureHistory);
|
||||||
int probCutCount = 0;
|
int probCutCount = 0;
|
||||||
|
|
||||||
while ( (move = mp.next_move()) != MOVE_NONE
|
while ( (move = mp.next_move()) != MOVE_NONE
|
||||||
@@ -844,15 +844,15 @@ namespace {
|
|||||||
pos.do_move(move, st);
|
pos.do_move(move, st);
|
||||||
|
|
||||||
// Perform a preliminary qsearch to verify that the move holds
|
// Perform a preliminary qsearch to verify that the move holds
|
||||||
value = -qsearch<NonPV>(pos, ss+1, -rbeta, -rbeta+1);
|
value = -qsearch<NonPV>(pos, ss+1, -raisedBeta, -raisedBeta+1);
|
||||||
|
|
||||||
// If the qsearch held perform the regular search
|
// If the qsearch held perform the regular search
|
||||||
if (value >= rbeta)
|
if (value >= raisedBeta)
|
||||||
value = -search<NonPV>(pos, ss+1, -rbeta, -rbeta+1, depth - 4 * ONE_PLY, !cutNode);
|
value = -search<NonPV>(pos, ss+1, -raisedBeta, -raisedBeta+1, depth - 4 * ONE_PLY, !cutNode);
|
||||||
|
|
||||||
pos.undo_move(move);
|
pos.undo_move(move);
|
||||||
|
|
||||||
if (value >= rbeta)
|
if (value >= raisedBeta)
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -928,18 +928,18 @@ moves_loop: // When in check, search starts from here
|
|||||||
if ( depth >= 8 * ONE_PLY
|
if ( depth >= 8 * ONE_PLY
|
||||||
&& move == ttMove
|
&& move == ttMove
|
||||||
&& !rootNode
|
&& !rootNode
|
||||||
&& !excludedMove // Recursive singular search is not allowed
|
&& !excludedMove // Avoid recursive singular search
|
||||||
&& ttValue != VALUE_NONE
|
&& ttValue != VALUE_NONE
|
||||||
&& (tte->bound() & BOUND_LOWER)
|
&& (tte->bound() & BOUND_LOWER)
|
||||||
&& tte->depth() >= depth - 3 * ONE_PLY
|
&& tte->depth() >= depth - 3 * ONE_PLY
|
||||||
&& pos.legal(move))
|
&& pos.legal(move))
|
||||||
{
|
{
|
||||||
Value rBeta = std::max(ttValue - 2 * depth / ONE_PLY, -VALUE_MATE);
|
Value reducedBeta = std::max(ttValue - 2 * depth / ONE_PLY, -VALUE_MATE);
|
||||||
ss->excludedMove = move;
|
ss->excludedMove = move;
|
||||||
value = search<NonPV>(pos, ss, rBeta - 1, rBeta, depth / 2, cutNode);
|
value = search<NonPV>(pos, ss, reducedBeta - 1, reducedBeta, depth / 2, cutNode);
|
||||||
ss->excludedMove = MOVE_NONE;
|
ss->excludedMove = MOVE_NONE;
|
||||||
|
|
||||||
if (value < rBeta)
|
if (value < reducedBeta)
|
||||||
extension = ONE_PLY;
|
extension = ONE_PLY;
|
||||||
}
|
}
|
||||||
else if ( givesCheck // Check extension (~2 Elo)
|
else if ( givesCheck // Check extension (~2 Elo)
|
||||||
@@ -1186,9 +1186,9 @@ moves_loop: // When in check, search starts from here
|
|||||||
update_capture_stats(pos, bestMove, capturesSearched, captureCount, stat_bonus(depth + ONE_PLY));
|
update_capture_stats(pos, bestMove, capturesSearched, captureCount, stat_bonus(depth + ONE_PLY));
|
||||||
|
|
||||||
// Extra penalty for a quiet TT or main killer move in previous ply when it gets refuted
|
// Extra penalty for a quiet TT or main killer move in previous ply when it gets refuted
|
||||||
if ( (ss-1)->moveCount == 1
|
if ( (ss-1)->moveCount == 1
|
||||||
|| ((ss-1)->currentMove == (ss-1)->killers[0] && (ss-1)->killers[0]))
|
|| ((ss-1)->currentMove == (ss-1)->killers[0] && (ss-1)->killers[0]))
|
||||||
if (!pos.captured_piece())
|
if (!pos.captured_piece())
|
||||||
update_continuation_histories(ss-1, pos.piece_on(prevSq), prevSq, -stat_bonus(depth + ONE_PLY));
|
update_continuation_histories(ss-1, pos.piece_on(prevSq), prevSq, -stat_bonus(depth + ONE_PLY));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1107,10 +1107,10 @@ void* mapped(TBTable<Type>& e, const Position& pos) {
|
|||||||
|
|
||||||
static Mutex mutex;
|
static Mutex mutex;
|
||||||
|
|
||||||
// Use 'aquire' to avoid a thread reads 'ready' == true while another is
|
// Use 'acquire' to avoid a thread reading 'ready' == true while
|
||||||
// still working, this could happen due to compiler reordering.
|
// another is still working. (compiler reordering may cause this).
|
||||||
if (e.ready.load(std::memory_order_acquire))
|
if (e.ready.load(std::memory_order_acquire))
|
||||||
return e.baseAddress; // Could be nullptr if file does not exsist
|
return e.baseAddress; // Could be nullptr if file does not exist
|
||||||
|
|
||||||
std::unique_lock<Mutex> lk(mutex);
|
std::unique_lock<Mutex> lk(mutex);
|
||||||
|
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ void Thread::idle_loop() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// ThreadPool::set() creates/destroys threads to match the requested number.
|
/// ThreadPool::set() creates/destroys threads to match the requested number.
|
||||||
/// Created and launched threads will go immediately to sleep in idle_loop.
|
/// Created and launched threads will immediately go to sleep in idle_loop.
|
||||||
/// Upon resizing, threads are recreated to allow for binding if necessary.
|
/// Upon resizing, threads are recreated to allow for binding if necessary.
|
||||||
|
|
||||||
void ThreadPool::set(size_t requested) {
|
void ThreadPool::set(size_t requested) {
|
||||||
|
|||||||
Reference in New Issue
Block a user