No functional change.
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");
}
return (Pt == ROOK ? RAttacks : BAttacks)[s][magic_index<Pt>(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<BISHOP>(s, occ);
case ROOK : return attacks_bb<ROOK>(s, occ);
case QUEEN : return attacks_bb<BISHOP>(s, occ) | attacks_bb<ROOK>(s, occ);
- default : return StepAttacksBB[p][s];
+ default : return StepAttacksBB[pc][s];
}
}
# 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__)
# 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
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);
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;
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();
}
followupmoves = fm;
ss = s;
- if (p.checkers())
+ if (pos.checkers())
stage = EVASION;
else
}
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)
else
{
stage = RECAPTURE;
- recaptureSquare = sq;
+ recaptureSquare = s;
ttm = MOVE_NONE;
}
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:
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)
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 << '/';
}
/// 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| | . | | . | | . | | . |"
std::ostringstream ss;
- if (move)
+ if (m)
ss << "\nMove: " << (sideToMove == BLACK ? ".." : "")
- << move_to_san(*const_cast<Position*>(this), move);
+ << move_to_san(*const_cast<Position*>(this), m);
ss << brd << "\nFen: " << fen() << "\nKey: " << std::hex << std::uppercase
<< std::setfill('0') << std::setw(16) << st->key << "\nCheckers: ";
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() ? " " : "/"));
}
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();
// 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<PieceType> Bitboard attacks_from(Square s) const;
template<PieceType> Bitboard 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 {
<< " 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
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;
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
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) {
void Option::operator<<(const Option& o) {
- static size_t index = 0;
+ static size_t insert_order = 0;
*this = o;
- idx = index++;
+ idx = insert_order++;
}