From: protonspring Date: Tue, 11 Dec 2018 12:47:56 +0000 (-0700) Subject: Changes identified in RENAME/REFORMATTING thread (#1861) X-Git-Url: https://git.sesse.net/?p=stockfish;a=commitdiff_plain;h=e917bd59b1e317c6b48dc676473359fdfb86d9d4;hp=e8ffca3eb49f607d361688c41c9ae9b3b3de4b80 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. --- diff --git a/AUTHORS b/AUTHORS index 5b646dae..603b0fb3 100644 --- a/AUTHORS +++ b/AUTHORS @@ -88,7 +88,7 @@ Michael Chaly (Vizvezdenec) Michel Van den Bergh (vdbergh) Miguel Lahoz (miguel-l) Mikael Bäckman (mbootsector) -Mike Whiteley (protonspring) +Michael Whiteley (protonspring) Miroslav Fontán (Hexik) Moez Jellouli (MJZ1977) Mohammed Li (tthsqe12) diff --git a/src/evaluate.cpp b/src/evaluate.cpp index d6239594..48e305ef 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -381,7 +381,7 @@ namespace { { File kf = file_of(pos.square(Us)); 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; // 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 // square with a pawn, or because they defend the square twice and we don't. diff --git a/src/material.h b/src/material.h index 56de9ad2..b472c3fd 100644 --- a/src/material.h +++ b/src/material.h @@ -58,7 +58,7 @@ struct Entry { Key key; const EndgameBase* evaluationFunction; const EndgameBase* scalingFunction[COLOR_NB]; // Could be one for each - // side (e.g. KPKP, KBPsKs) + // side (e.g. KPKP, KBPsK) int16_t value; uint8_t factor[COLOR_NB]; Phase gamePhase; diff --git a/src/movegen.cpp b/src/movegen.cpp index 833cd2fc..b4a9d27b 100644 --- a/src/movegen.cpp +++ b/src/movegen.cpp @@ -278,7 +278,7 @@ namespace { *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()) { diff --git a/src/pawns.cpp b/src/pawns.cpp index 7d39a4a0..edd670b8 100644 --- a/src/pawns.cpp +++ b/src/pawns.cpp @@ -67,7 +67,7 @@ namespace { constexpr Color Them = (Us == WHITE ? BLACK : WHITE); constexpr Direction Up = (Us == WHITE ? NORTH : SOUTH); - Bitboard b, neighbours, stoppers, doubled, supported, phalanx; + Bitboard b, neighbours, stoppers, doubled, support, phalanx; Bitboard lever, leverPush; Square s; bool opposed, backward; @@ -102,7 +102,7 @@ namespace { doubled = ourPawns & (s - Up); neighbours = ourPawns & adjacent_files_bb(f); 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 // 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 // not attacked more times than defended. if ( !(stoppers ^ lever ^ leverPush) - && popcount(supported) >= popcount(lever) - 1 + && popcount(support) >= popcount(lever) - 1 && popcount(phalanx) >= popcount(leverPush)) e->passedPawns[Us] |= s; else if ( stoppers == SquareBB[s + Up] && relative_rank(Us, s) >= RANK_5) { - b = shift(supported) & ~theirPawns; + b = shift(support) & ~theirPawns; while (b) if (!more_than_one(theirPawns & PawnAttacks[Us][pop_lsb(&b)])) e->passedPawns[Us] |= s; } // Score this pawn - if (supported | phalanx) - score += Connected[opposed][bool(phalanx)][popcount(supported)][relative_rank(Us, s)]; + if (support | phalanx) + score += Connected[opposed][bool(phalanx)][popcount(support)][relative_rank(Us, s)]; else if (!neighbours) score -= Isolated, e->weakUnopposed[Us] += !opposed; @@ -137,7 +137,7 @@ namespace { else if (backward) score -= Backward, e->weakUnopposed[Us] += !opposed; - if (doubled && !supported) + if (doubled && !support) 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) { 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); - 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); safety += ShelterStrength[d][ourRank]; @@ -237,7 +237,7 @@ Score Entry::do_king_safety(const Position& pos) { Square ksq = pos.square(Us); kingSquares[Us] = ksq; - castlingRights[Us] = pos.can_castle(Us); + castlingRights[Us] = pos.castling_rights(Us); int minKingPawnDistance = 0; Bitboard pawns = pos.pieces(Us, PAWN); diff --git a/src/pawns.h b/src/pawns.h index 4d8b2936..df220eab 100644 --- a/src/pawns.h +++ b/src/pawns.h @@ -51,7 +51,7 @@ struct Entry { template Score king_safety(const Position& pos) { - return kingSquares[Us] == pos.square(Us) && castlingRights[Us] == pos.can_castle(Us) + return kingSquares[Us] == pos.square(Us) && castlingRights[Us] == pos.castling_rights(Us) ? kingSafety[Us] : (kingSafety[Us] = do_king_safety(pos)); } diff --git a/src/position.cpp b/src/position.cpp index c915a1f9..bd5daa6d 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -476,7 +476,7 @@ const string Position::fen() const { if (can_castle(BLACK_OOO)) 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 << (ep_square() == SQ_NONE ? " - " : " " + UCI::square(ep_square()) + " ") diff --git a/src/position.h b/src/position.h index e1eacf26..d94ef185 100644 --- a/src/position.h +++ b/src/position.h @@ -97,8 +97,8 @@ public: template Square square(Color c) const; // Castling - int can_castle(Color c) const; - int can_castle(CastlingRight cr) const; + int castling_rights(Color c) const; + bool can_castle(CastlingRight cr) const; bool castling_impeded(CastlingRight cr) const; Square castling_rook_square(CastlingRight cr) const; @@ -260,11 +260,11 @@ inline Square Position::ep_square() const { return st->epSquare; } -inline int Position::can_castle(CastlingRight cr) const { +inline bool Position::can_castle(CastlingRight cr) const { 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)); } diff --git a/src/search.cpp b/src/search.cpp index c589f236..6c16aca8 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -826,8 +826,8 @@ namespace { && depth >= 5 * ONE_PLY && abs(beta) < VALUE_MATE_IN_MAX_PLY) { - Value rbeta = std::min(beta + 216 - 48 * improving, VALUE_INFINITE); - MovePicker mp(pos, ttMove, rbeta - ss->staticEval, &thisThread->captureHistory); + Value raisedBeta = std::min(beta + 216 - 48 * improving, VALUE_INFINITE); + MovePicker mp(pos, ttMove, raisedBeta - ss->staticEval, &thisThread->captureHistory); int probCutCount = 0; while ( (move = mp.next_move()) != MOVE_NONE @@ -844,15 +844,15 @@ namespace { pos.do_move(move, st); // Perform a preliminary qsearch to verify that the move holds - value = -qsearch(pos, ss+1, -rbeta, -rbeta+1); + value = -qsearch(pos, ss+1, -raisedBeta, -raisedBeta+1); // If the qsearch held perform the regular search - if (value >= rbeta) - value = -search(pos, ss+1, -rbeta, -rbeta+1, depth - 4 * ONE_PLY, !cutNode); + if (value >= raisedBeta) + value = -search(pos, ss+1, -raisedBeta, -raisedBeta+1, depth - 4 * ONE_PLY, !cutNode); pos.undo_move(move); - if (value >= rbeta) + if (value >= raisedBeta) return value; } } @@ -928,18 +928,18 @@ moves_loop: // When in check, search starts from here if ( depth >= 8 * ONE_PLY && move == ttMove && !rootNode - && !excludedMove // Recursive singular search is not allowed + && !excludedMove // Avoid recursive singular search && ttValue != VALUE_NONE && (tte->bound() & BOUND_LOWER) && tte->depth() >= depth - 3 * ONE_PLY && 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; - value = search(pos, ss, rBeta - 1, rBeta, depth / 2, cutNode); + value = search(pos, ss, reducedBeta - 1, reducedBeta, depth / 2, cutNode); ss->excludedMove = MOVE_NONE; - if (value < rBeta) + if (value < reducedBeta) extension = ONE_PLY; } 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)); // Extra penalty for a quiet TT or main killer move in previous ply when it gets refuted - if ( (ss-1)->moveCount == 1 - || ((ss-1)->currentMove == (ss-1)->killers[0] && (ss-1)->killers[0])) - if (!pos.captured_piece()) + if ( (ss-1)->moveCount == 1 + || ((ss-1)->currentMove == (ss-1)->killers[0] && (ss-1)->killers[0])) + if (!pos.captured_piece()) update_continuation_histories(ss-1, pos.piece_on(prevSq), prevSq, -stat_bonus(depth + ONE_PLY)); } diff --git a/src/syzygy/tbprobe.cpp b/src/syzygy/tbprobe.cpp index d0b59f05..60979a56 100644 --- a/src/syzygy/tbprobe.cpp +++ b/src/syzygy/tbprobe.cpp @@ -1107,10 +1107,10 @@ void* mapped(TBTable& e, const Position& pos) { static Mutex mutex; - // Use 'aquire' to avoid a thread reads 'ready' == true while another is - // still working, this could happen due to compiler reordering. + // Use 'acquire' to avoid a thread reading 'ready' == true while + // another is still working. (compiler reordering may cause this). 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 lk(mutex); diff --git a/src/thread.cpp b/src/thread.cpp index 5e990fdc..e6912084 100644 --- a/src/thread.cpp +++ b/src/thread.cpp @@ -118,7 +118,7 @@ void Thread::idle_loop() { } /// 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. void ThreadPool::set(size_t requested) {