mirror of
https://github.com/sockspls/badfish
synced 2025-05-02 01:29:36 +00:00
Sync some common names
No functional change.
This commit is contained in:
parent
fcf2a34080
commit
64d29a6330
13 changed files with 81 additions and 81 deletions
|
@ -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");
|
||||
}
|
||||
|
|
|
@ -254,14 +254,14 @@ inline Bitboard attacks_bb(Square s, Bitboard 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 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];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
16
src/misc.cpp
16
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();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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<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: ";
|
||||
|
@ -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() ? " " : "/"));
|
||||
}
|
||||
|
||||
|
|
|
@ -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<PieceType> Bitboard attacks_from(Square s) 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];
|
||||
}
|
||||
|
||||
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 {
|
||||
|
|
|
@ -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
|
||||
|
|
10
src/types.h
10
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) {
|
||||
|
|
|
@ -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++;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue