1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-05-03 10:09:35 +00:00

Sync some common names

No functional change.
This commit is contained in:
Marco Costalba 2014-04-06 10:50:27 +02:00
parent fcf2a34080
commit 64d29a6330
13 changed files with 81 additions and 81 deletions

View file

@ -131,10 +131,10 @@ const std::string Bitboards::pretty(Bitboard b) {
std::string s = "+---+---+---+---+---+---+---+---+\n"; 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) for (File f = FILE_A; f <= FILE_H; ++f)
s.append(b & make_square(file, rank) ? "| X " : "| "); s.append(b & make_square(f, r) ? "| X " : "| ");
s.append("|\n+---+---+---+---+---+---+---+---+\n"); s.append("|\n+---+---+---+---+---+---+---+---+\n");
} }

View file

@ -254,14 +254,14 @@ inline Bitboard attacks_bb(Square s, Bitboard occ) {
return (Pt == ROOK ? RAttacks : BAttacks)[s][magic_index<Pt>(s, occ)]; 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 BISHOP: return attacks_bb<BISHOP>(s, occ);
case ROOK : return attacks_bb<ROOK>(s, occ); case ROOK : return attacks_bb<ROOK>(s, occ);
case QUEEN : return attacks_bb<BISHOP>(s, occ) | 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];
} }
} }
@ -273,15 +273,15 @@ inline Bitboard attacks_bb(Piece p, Square s, Bitboard occ) {
# if defined(_MSC_VER) && !defined(__INTEL_COMPILER) # if defined(_MSC_VER) && !defined(__INTEL_COMPILER)
FORCE_INLINE Square lsb(Bitboard b) { FORCE_INLINE Square lsb(Bitboard b) {
unsigned long index; unsigned long idx;
_BitScanForward64(&index, b); _BitScanForward64(&idx, b);
return (Square) index; return (Square) idx;
} }
FORCE_INLINE Square msb(Bitboard b) { FORCE_INLINE Square msb(Bitboard b) {
unsigned long index; unsigned long idx;
_BitScanReverse64(&index, b); _BitScanReverse64(&idx, b);
return (Square) index; return (Square) idx;
} }
# elif defined(__arm__) # elif defined(__arm__)
@ -302,15 +302,15 @@ FORCE_INLINE Square lsb(Bitboard b) {
# else # else
FORCE_INLINE Square lsb(Bitboard b) { // Assembly code by Heinz van Saanen FORCE_INLINE Square lsb(Bitboard b) { // Assembly code by Heinz van Saanen
Bitboard index; Bitboard idx;
__asm__("bsfq %1, %0": "=r"(index): "rm"(b) ); __asm__("bsfq %1, %0": "=r"(idx): "rm"(b) );
return (Square) index; return (Square) idx;
} }
FORCE_INLINE Square msb(Bitboard b) { FORCE_INLINE Square msb(Bitboard b) {
Bitboard index; Bitboard idx;
__asm__("bsrq %1, %0": "=r"(index): "rm"(b) ); __asm__("bsrq %1, %0": "=r"(idx): "rm"(b) );
return (Square) index; return (Square) idx;
} }
# endif # endif

View file

@ -326,10 +326,10 @@ namespace {
while (b) while (b)
{ {
Square s = pop_lsb(&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 // 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); b = pos.can_castle(ANY_CASTLING);

View file

@ -42,7 +42,7 @@ struct Entry {
Score space_weight() const { return spaceWeight; } Score space_weight() const { return spaceWeight; }
Phase game_phase() const { return gamePhase; } Phase game_phase() const { return gamePhase; }
bool specialized_eval_exists() const { return evaluationFunction != NULL; } 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; ScaleFactor scale_factor(const Position& pos, Color c) const;
Key key; Key key;

View file

@ -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"); const string months("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec");
string month, day, year; 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()) if (Version.empty())
{ {
date >> month >> day >> year; 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" : "") ss << (Is64Bit ? " 64" : "")
<< (HasPopCnt ? " SSE4.2" : "") << (HasPopCnt ? " SSE4.2" : "")
<< (to_uci ? "\nid author ": " by ") << (to_uci ? "\nid author ": " by ")
<< "Tord Romstad, Marco Costalba and Joona Kiiski"; << "Tord Romstad, Marco Costalba and Joona Kiiski";
return s.str(); return ss.str();
} }

View file

@ -81,7 +81,7 @@ MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const HistoryStats&
followupmoves = fm; followupmoves = fm;
ss = s; ss = s;
if (p.checkers()) if (pos.checkers())
stage = EVASION; stage = EVASION;
else 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, 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); assert(d <= DEPTH_ZERO);
if (p.checkers()) if (pos.checkers())
stage = EVASION; stage = EVASION;
else if (d > DEPTH_QS_NO_CHECKS) else if (d > DEPTH_QS_NO_CHECKS)
@ -115,7 +115,7 @@ MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const HistoryStats&
else else
{ {
stage = RECAPTURE; stage = RECAPTURE;
recaptureSquare = sq; recaptureSquare = s;
ttm = MOVE_NONE; ttm = MOVE_NONE;
} }

View file

@ -42,25 +42,25 @@ struct Stats {
static const Value Max = Value(2000); 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 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; return;
table[p][to].second = table[p][to].first; table[pc][to].second = table[pc][to].first;
table[p][to].first = m; table[pc][to].first = m;
} }
void update(Piece p, Square to, Value v) { void update(Piece pc, Square to, Value v) {
if (Gain) 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) else if (abs(table[pc][to] + v) < Max)
table[p][to] += v; table[pc][to] += v;
} }
private: private:

View file

@ -132,9 +132,9 @@ const string move_to_san(Position& pos, Move m) {
while (b) while (b)
{ {
Square sq = pop_lsb(&b); Square s = pop_lsb(&b);
if (!pos.legal(make_move(sq, to), pos.pinned_pieces(us))) if (!pos.legal(make_move(s, to), pos.pinned_pieces(us)))
others ^= sq; others ^= s;
} }
if (!others) if (!others)

View file

@ -388,21 +388,21 @@ const string Position::fen() const {
int emptyCnt; int emptyCnt;
std::ostringstream ss; 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; ++emptyCnt;
if (emptyCnt) if (emptyCnt)
ss << emptyCnt; ss << emptyCnt;
if (file <= FILE_H) if (f <= FILE_H)
ss << PieceToChar[piece_on(make_square(file, rank))]; ss << PieceToChar[piece_on(make_square(f, r))];
} }
if (rank > RANK_1) if (r > RANK_1)
ss << '/'; ss << '/';
} }
@ -433,7 +433,7 @@ const string Position::fen() const {
/// Position::pretty() returns an ASCII representation of the position to be /// Position::pretty() returns an ASCII representation of the position to be
/// printed to the standard output together with the move's san notation. /// 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 dottedLine = "\n+---+---+---+---+---+---+---+---+";
const string twoRows = dottedLine + "\n| | . | | . | | . | | . |" const string twoRows = dottedLine + "\n| | . | | . | | . | | . |"
@ -449,9 +449,9 @@ const string Position::pretty(Move move) const {
std::ostringstream ss; std::ostringstream ss;
if (move) if (m)
ss << "\nMove: " << (sideToMove == BLACK ? ".." : "") 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 ss << brd << "\nFen: " << fen() << "\nKey: " << std::hex << std::uppercase
<< std::setfill('0') << std::setw(16) << st->key << "\nCheckers: "; << std::setfill('0') << std::setw(16) << st->key << "\nCheckers: ";
@ -1147,9 +1147,9 @@ void Position::flip() {
string f, token; string f, token;
std::stringstream ss(fen()); 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() ? " " : "/")); f.insert(0, token + (f.empty() ? " " : "/"));
} }

View file

@ -75,7 +75,7 @@ const size_t StateCopySize64 = offsetof(StateInfo, key) / sizeof(uint64_t) + 1;
class Position { class Position {
public: public:
Position() {} 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(const std::string& f, bool c960, Thread* t) { set(f, c960, t); }
Position& operator=(const Position&); Position& operator=(const Position&);
static void init(); static void init();
@ -113,7 +113,7 @@ public:
// Attacks to/from a given square // Attacks to/from a given square
Bitboard attackers_to(Square s) const; Bitboard attackers_to(Square s) const;
Bitboard attackers_to(Square s, Bitboard occ) 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) const;
template<PieceType> Bitboard attacks_from(Square s, Color c) const; template<PieceType> Bitboard attacks_from(Square s, Color c) const;
@ -295,8 +295,8 @@ inline Bitboard Position::attacks_from<PAWN>(Square s, Color c) const {
return StepAttacksBB[make_piece(c, PAWN)][s]; return StepAttacksBB[make_piece(c, PAWN)][s];
} }
inline Bitboard Position::attacks_from(Piece p, Square s) const { inline Bitboard Position::attacks_from(Piece pc, Square s) const {
return attacks_bb(p, s, byTypeBB[ALL_PIECES]); return attacks_bb(pc, s, byTypeBB[ALL_PIECES]);
} }
inline Bitboard Position::attackers_to(Square s) const { inline Bitboard Position::attackers_to(Square s) const {

View file

@ -219,7 +219,7 @@ void Search::think() {
<< " time: " << Limits.time[RootColor] << " time: " << Limits.time[RootColor]
<< " increment: " << Limits.inc[RootColor] << " increment: " << Limits.inc[RootColor]
<< " moves to go: " << Limits.movestogo << " moves to go: " << Limits.movestogo
<< std::endl; << "\n" << std::endl;
} }
// Reset the threads, still sleeping: will wake up at split time // 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) { 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; Time::point elapsed = Time::now() - SearchTime + 1;
size_t uciPVSize = std::min((size_t)Options["MultiPV"], RootMoves.size()); size_t uciPVSize = std::min((size_t)Options["MultiPV"], RootMoves.size());
int selDepth = 0; int selDepth = 0;
@ -1361,10 +1361,10 @@ moves_loop: // When in check and at SpNode search starts from here
int d = updated ? depth : depth - 1; int d = updated ? depth : depth - 1;
Value v = updated ? RootMoves[i].score : RootMoves[i].prevScore; Value v = updated ? RootMoves[i].score : RootMoves[i].prevScore;
if (s.rdbuf()->in_avail()) // Not at first line if (ss.rdbuf()->in_avail()) // Not at first line
s << "\n"; ss << "\n";
s << "info depth " << d ss << "info depth " << d
<< " seldepth " << selDepth << " seldepth " << selDepth
<< " score " << (i == PVIdx ? score_to_uci(v, alpha, beta) : score_to_uci(v)) << " score " << (i == PVIdx ? score_to_uci(v, alpha, beta) : score_to_uci(v))
<< " nodes " << pos.nodes_searched() << " nodes " << pos.nodes_searched()
@ -1374,10 +1374,10 @@ moves_loop: // When in check and at SpNode search starts from here
<< " pv"; << " pv";
for (size_t j = 0; RootMoves[i].pv[j] != MOVE_NONE; ++j) 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 } // namespace

View file

@ -357,13 +357,13 @@ inline Piece make_piece(Color c, PieceType pt) {
return Piece((c << 3) | pt); return Piece((c << 3) | pt);
} }
inline PieceType type_of(Piece p) { inline PieceType type_of(Piece pc) {
return PieceType(p & 7); return PieceType(pc & 7);
} }
inline Color color_of(Piece p) { inline Color color_of(Piece pc) {
assert(p != NO_PIECE); assert(pc != NO_PIECE);
return Color(p >> 3); return Color(pc >> 3);
} }
inline bool is_ok(Square s) { inline bool is_ok(Square s) {

View file

@ -141,10 +141,10 @@ Option::operator std::string() const {
void Option::operator<<(const Option& o) { void Option::operator<<(const Option& o) {
static size_t index = 0; static size_t insert_order = 0;
*this = o; *this = o;
idx = index++; idx = insert_order++;
} }