From 64d29a633066e39b62af5ee0bbf32645994744ec Mon Sep 17 00:00:00 2001 From: Marco Costalba Date: Sun, 6 Apr 2014 10:50:27 +0200 Subject: [PATCH] Sync some common names No functional change. --- src/bitboard.cpp | 6 +++--- src/bitboard.h | 30 +++++++++++++++--------------- src/book.cpp | 4 ++-- src/material.h | 2 +- src/misc.cpp | 16 ++++++++-------- src/movepick.cpp | 8 ++++---- src/movepick.h | 18 +++++++++--------- src/notation.cpp | 6 +++--- src/position.cpp | 22 +++++++++++----------- src/position.h | 8 ++++---- src/search.cpp | 28 ++++++++++++++-------------- src/types.h | 10 +++++----- src/ucioption.cpp | 4 ++-- 13 files changed, 81 insertions(+), 81 deletions(-) diff --git a/src/bitboard.cpp b/src/bitboard.cpp index d4b8bcfd..bfacc412 100644 --- a/src/bitboard.cpp +++ b/src/bitboard.cpp @@ -131,10 +131,10 @@ const std::string Bitboards::pretty(Bitboard b) { std::string s = "+---+---+---+---+---+---+---+---+\n"; - for (Rank rank = RANK_8; rank >= RANK_1; --rank) + for (Rank r = RANK_8; r >= RANK_1; --r) { - for (File file = FILE_A; file <= FILE_H; ++file) - s.append(b & make_square(file, rank) ? "| X " : "| "); + for (File f = FILE_A; f <= FILE_H; ++f) + s.append(b & make_square(f, r) ? "| X " : "| "); s.append("|\n+---+---+---+---+---+---+---+---+\n"); } diff --git a/src/bitboard.h b/src/bitboard.h index a6850ba0..3ff0408a 100644 --- a/src/bitboard.h +++ b/src/bitboard.h @@ -254,14 +254,14 @@ inline Bitboard attacks_bb(Square s, Bitboard occ) { return (Pt == ROOK ? RAttacks : BAttacks)[s][magic_index(s, occ)]; } -inline Bitboard attacks_bb(Piece p, Square s, Bitboard occ) { +inline Bitboard attacks_bb(Piece pc, Square s, Bitboard occ) { - switch (type_of(p)) + switch (type_of(pc)) { case BISHOP: return attacks_bb(s, occ); case ROOK : return attacks_bb(s, occ); case QUEEN : return attacks_bb(s, occ) | attacks_bb(s, occ); - default : return StepAttacksBB[p][s]; + default : return StepAttacksBB[pc][s]; } } @@ -273,15 +273,15 @@ inline Bitboard attacks_bb(Piece p, Square s, Bitboard occ) { # if defined(_MSC_VER) && !defined(__INTEL_COMPILER) FORCE_INLINE Square lsb(Bitboard b) { - unsigned long index; - _BitScanForward64(&index, b); - return (Square) index; + unsigned long idx; + _BitScanForward64(&idx, b); + return (Square) idx; } FORCE_INLINE Square msb(Bitboard b) { - unsigned long index; - _BitScanReverse64(&index, b); - return (Square) index; + unsigned long idx; + _BitScanReverse64(&idx, b); + return (Square) idx; } # elif defined(__arm__) @@ -302,15 +302,15 @@ FORCE_INLINE Square lsb(Bitboard b) { # else FORCE_INLINE Square lsb(Bitboard b) { // Assembly code by Heinz van Saanen - Bitboard index; - __asm__("bsfq %1, %0": "=r"(index): "rm"(b) ); - return (Square) index; + Bitboard idx; + __asm__("bsfq %1, %0": "=r"(idx): "rm"(b) ); + return (Square) idx; } FORCE_INLINE Square msb(Bitboard b) { - Bitboard index; - __asm__("bsrq %1, %0": "=r"(index): "rm"(b) ); - return (Square) index; + Bitboard idx; + __asm__("bsrq %1, %0": "=r"(idx): "rm"(b) ); + return (Square) idx; } # endif diff --git a/src/book.cpp b/src/book.cpp index c27e878c..fbbc3fee 100644 --- a/src/book.cpp +++ b/src/book.cpp @@ -326,10 +326,10 @@ namespace { while (b) { Square s = pop_lsb(&b); - Piece p = pos.piece_on(s); + Piece pc = pos.piece_on(s); // PolyGlot pieces are: BP = 0, WP = 1, BN = 2, ... BK = 10, WK = 11 - key ^= PG.Zobrist.psq[2 * (type_of(p) - 1) + (color_of(p) == WHITE)][s]; + key ^= PG.Zobrist.psq[2 * (type_of(pc) - 1) + (color_of(pc) == WHITE)][s]; } b = pos.can_castle(ANY_CASTLING); diff --git a/src/material.h b/src/material.h index 8ca13cd0..023d4497 100644 --- a/src/material.h +++ b/src/material.h @@ -42,7 +42,7 @@ struct Entry { Score space_weight() const { return spaceWeight; } Phase game_phase() const { return gamePhase; } bool specialized_eval_exists() const { return evaluationFunction != NULL; } - Value evaluate(const Position& p) const { return (*evaluationFunction)(p); } + Value evaluate(const Position& pos) const { return (*evaluationFunction)(pos); } ScaleFactor scale_factor(const Position& pos, Color c) const; Key key; diff --git a/src/misc.cpp b/src/misc.cpp index 13923a7b..69bf0a37 100644 --- a/src/misc.cpp +++ b/src/misc.cpp @@ -40,22 +40,22 @@ const string engine_info(bool to_uci) { const string months("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec"); string month, day, year; - stringstream s, date(__DATE__); // From compiler, format is "Sep 21 2008" + stringstream ss, date(__DATE__); // From compiler, format is "Sep 21 2008" - s << "Stockfish " << Version << setfill('0'); + ss << "Stockfish " << Version << setfill('0'); if (Version.empty()) { date >> month >> day >> year; - s << setw(2) << day << setw(2) << (1 + months.find(month) / 4) << year.substr(2); + ss << setw(2) << day << setw(2) << (1 + months.find(month) / 4) << year.substr(2); } - s << (Is64Bit ? " 64" : "") - << (HasPopCnt ? " SSE4.2" : "") - << (to_uci ? "\nid author ": " by ") - << "Tord Romstad, Marco Costalba and Joona Kiiski"; + ss << (Is64Bit ? " 64" : "") + << (HasPopCnt ? " SSE4.2" : "") + << (to_uci ? "\nid author ": " by ") + << "Tord Romstad, Marco Costalba and Joona Kiiski"; - return s.str(); + return ss.str(); } diff --git a/src/movepick.cpp b/src/movepick.cpp index b03295dd..ce603d18 100644 --- a/src/movepick.cpp +++ b/src/movepick.cpp @@ -81,7 +81,7 @@ MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const HistoryStats& followupmoves = fm; ss = s; - if (p.checkers()) + if (pos.checkers()) stage = EVASION; else @@ -92,11 +92,11 @@ MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const HistoryStats& } MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const HistoryStats& h, - Square sq) : pos(p), history(h), cur(moves), end(moves) { + Square s) : pos(p), history(h), cur(moves), end(moves) { assert(d <= DEPTH_ZERO); - if (p.checkers()) + if (pos.checkers()) stage = EVASION; else if (d > DEPTH_QS_NO_CHECKS) @@ -115,7 +115,7 @@ MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const HistoryStats& else { stage = RECAPTURE; - recaptureSquare = sq; + recaptureSquare = s; ttm = MOVE_NONE; } diff --git a/src/movepick.h b/src/movepick.h index caec8d4a..c512d130 100644 --- a/src/movepick.h +++ b/src/movepick.h @@ -42,25 +42,25 @@ struct Stats { static const Value Max = Value(2000); - const T* operator[](Piece p) const { return table[p]; } + const T* operator[](Piece pc) const { return table[pc]; } void clear() { std::memset(table, 0, sizeof(table)); } - void update(Piece p, Square to, Move m) { + void update(Piece pc, Square to, Move m) { - if (m == table[p][to].first) + if (m == table[pc][to].first) return; - table[p][to].second = table[p][to].first; - table[p][to].first = m; + table[pc][to].second = table[pc][to].first; + table[pc][to].first = m; } - void update(Piece p, Square to, Value v) { + void update(Piece pc, Square to, Value v) { if (Gain) - table[p][to] = std::max(v, table[p][to] - 1); + table[pc][to] = std::max(v, table[pc][to] - 1); - else if (abs(table[p][to] + v) < Max) - table[p][to] += v; + else if (abs(table[pc][to] + v) < Max) + table[pc][to] += v; } private: diff --git a/src/notation.cpp b/src/notation.cpp index 371b08a1..a2c5aa68 100644 --- a/src/notation.cpp +++ b/src/notation.cpp @@ -132,9 +132,9 @@ const string move_to_san(Position& pos, Move m) { while (b) { - Square sq = pop_lsb(&b); - if (!pos.legal(make_move(sq, to), pos.pinned_pieces(us))) - others ^= sq; + Square s = pop_lsb(&b); + if (!pos.legal(make_move(s, to), pos.pinned_pieces(us))) + others ^= s; } if (!others) diff --git a/src/position.cpp b/src/position.cpp index 788a2207..57c4bc32 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -388,21 +388,21 @@ const string Position::fen() const { int emptyCnt; std::ostringstream ss; - for (Rank rank = RANK_8; rank >= RANK_1; --rank) + for (Rank r = RANK_8; r >= RANK_1; --r) { - for (File file = FILE_A; file <= FILE_H; ++file) + for (File f = FILE_A; f <= FILE_H; ++f) { - for (emptyCnt = 0; file <= FILE_H && empty(make_square(file, rank)); ++file) + for (emptyCnt = 0; f <= FILE_H && empty(make_square(f, r)); ++f) ++emptyCnt; if (emptyCnt) ss << emptyCnt; - if (file <= FILE_H) - ss << PieceToChar[piece_on(make_square(file, rank))]; + if (f <= FILE_H) + ss << PieceToChar[piece_on(make_square(f, r))]; } - if (rank > RANK_1) + if (r > RANK_1) ss << '/'; } @@ -433,7 +433,7 @@ const string Position::fen() const { /// Position::pretty() returns an ASCII representation of the position to be /// printed to the standard output together with the move's san notation. -const string Position::pretty(Move move) const { +const string Position::pretty(Move m) const { const string dottedLine = "\n+---+---+---+---+---+---+---+---+"; const string twoRows = dottedLine + "\n| | . | | . | | . | | . |" @@ -449,9 +449,9 @@ const string Position::pretty(Move move) const { std::ostringstream ss; - if (move) + if (m) ss << "\nMove: " << (sideToMove == BLACK ? ".." : "") - << move_to_san(*const_cast(this), move); + << move_to_san(*const_cast(this), m); ss << brd << "\nFen: " << fen() << "\nKey: " << std::hex << std::uppercase << std::setfill('0') << std::setw(16) << st->key << "\nCheckers: "; @@ -1147,9 +1147,9 @@ void Position::flip() { string f, token; std::stringstream ss(fen()); - for (Rank rank = RANK_8; rank >= RANK_1; --rank) // Piece placement + for (Rank r = RANK_8; r >= RANK_1; --r) // Piece placement { - std::getline(ss, token, rank > RANK_1 ? '/' : ' '); + std::getline(ss, token, r > RANK_1 ? '/' : ' '); f.insert(0, token + (f.empty() ? " " : "/")); } diff --git a/src/position.h b/src/position.h index 36d65fb8..0f88944c 100644 --- a/src/position.h +++ b/src/position.h @@ -75,7 +75,7 @@ const size_t StateCopySize64 = offsetof(StateInfo, key) / sizeof(uint64_t) + 1; class Position { public: Position() {} - Position(const Position& p, Thread* t) { *this = p; thisThread = t; } + Position(const Position& pos, Thread* t) { *this = pos; thisThread = t; } Position(const std::string& f, bool c960, Thread* t) { set(f, c960, t); } Position& operator=(const Position&); static void init(); @@ -113,7 +113,7 @@ public: // Attacks to/from a given square Bitboard attackers_to(Square s) const; Bitboard attackers_to(Square s, Bitboard occ) const; - Bitboard attacks_from(Piece p, Square s) const; + Bitboard attacks_from(Piece pc, Square s) const; template Bitboard attacks_from(Square s) const; template Bitboard attacks_from(Square s, Color c) const; @@ -295,8 +295,8 @@ inline Bitboard Position::attacks_from(Square s, Color c) const { return StepAttacksBB[make_piece(c, PAWN)][s]; } -inline Bitboard Position::attacks_from(Piece p, Square s) const { - return attacks_bb(p, s, byTypeBB[ALL_PIECES]); +inline Bitboard Position::attacks_from(Piece pc, Square s) const { + return attacks_bb(pc, s, byTypeBB[ALL_PIECES]); } inline Bitboard Position::attackers_to(Square s) const { diff --git a/src/search.cpp b/src/search.cpp index 05773469..bb09df98 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -219,7 +219,7 @@ void Search::think() { << " time: " << Limits.time[RootColor] << " increment: " << Limits.inc[RootColor] << " moves to go: " << Limits.movestogo - << std::endl; + << "\n" << std::endl; } // Reset the threads, still sleeping: will wake up at split time @@ -1342,7 +1342,7 @@ moves_loop: // When in check and at SpNode search starts from here string uci_pv(const Position& pos, int depth, Value alpha, Value beta) { - std::stringstream s; + std::stringstream ss; Time::point elapsed = Time::now() - SearchTime + 1; size_t uciPVSize = std::min((size_t)Options["MultiPV"], RootMoves.size()); int selDepth = 0; @@ -1361,23 +1361,23 @@ moves_loop: // When in check and at SpNode search starts from here int d = updated ? depth : depth - 1; Value v = updated ? RootMoves[i].score : RootMoves[i].prevScore; - if (s.rdbuf()->in_avail()) // Not at first line - s << "\n"; + if (ss.rdbuf()->in_avail()) // Not at first line + ss << "\n"; - s << "info depth " << d - << " seldepth " << selDepth - << " score " << (i == PVIdx ? score_to_uci(v, alpha, beta) : score_to_uci(v)) - << " nodes " << pos.nodes_searched() - << " nps " << pos.nodes_searched() * 1000 / elapsed - << " time " << elapsed - << " multipv " << i + 1 - << " pv"; + ss << "info depth " << d + << " seldepth " << selDepth + << " score " << (i == PVIdx ? score_to_uci(v, alpha, beta) : score_to_uci(v)) + << " nodes " << pos.nodes_searched() + << " nps " << pos.nodes_searched() * 1000 / elapsed + << " time " << elapsed + << " multipv " << i + 1 + << " pv"; for (size_t j = 0; RootMoves[i].pv[j] != MOVE_NONE; ++j) - s << " " << move_to_uci(RootMoves[i].pv[j], pos.is_chess960()); + ss << " " << move_to_uci(RootMoves[i].pv[j], pos.is_chess960()); } - return s.str(); + return ss.str(); } } // namespace diff --git a/src/types.h b/src/types.h index ea52fe6c..7ebe3f61 100644 --- a/src/types.h +++ b/src/types.h @@ -357,13 +357,13 @@ inline Piece make_piece(Color c, PieceType pt) { return Piece((c << 3) | pt); } -inline PieceType type_of(Piece p) { - return PieceType(p & 7); +inline PieceType type_of(Piece pc) { + return PieceType(pc & 7); } -inline Color color_of(Piece p) { - assert(p != NO_PIECE); - return Color(p >> 3); +inline Color color_of(Piece pc) { + assert(pc != NO_PIECE); + return Color(pc >> 3); } inline bool is_ok(Square s) { diff --git a/src/ucioption.cpp b/src/ucioption.cpp index a2290279..e117e44c 100644 --- a/src/ucioption.cpp +++ b/src/ucioption.cpp @@ -141,10 +141,10 @@ Option::operator std::string() const { void Option::operator<<(const Option& o) { - static size_t index = 0; + static size_t insert_order = 0; *this = o; - idx = index++; + idx = insert_order++; } -- 2.39.2