Skip to content

Commit

Permalink
Merge with latest Stockfish development branch (last revision: 9953)
Browse files Browse the repository at this point in the history
  • Loading branch information
khalid-a-omar committed Oct 22, 2023
1 parent 9b197a3 commit bed1eb5
Show file tree
Hide file tree
Showing 33 changed files with 1,706 additions and 1,711 deletions.
22 changes: 11 additions & 11 deletions src/benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,17 +95,17 @@ const std::vector<std::string> Defaults = {

namespace Polyfish {

/// setup_bench() builds a list of UCI commands to be run by bench. There
/// are five parameters: TT size in MB, number of search threads that
/// should be used, the limit value spent for each position, a file name
/// where to look for positions in FEN format, and the type of the limit:
/// depth, perft, nodes and movetime (in milliseconds). Examples:
///
/// bench : search default positions up to depth 13
/// bench 64 1 15 : search default positions up to depth 15 (TT = 64MB)
/// bench 64 1 100000 default nodes : search default positions for 100K nodes each
/// bench 64 4 5000 current movetime : search current position with 4 threads for 5 sec
/// bench 16 1 5 blah perft : run a perft 5 on positions in file "blah"
// setup_bench() builds a list of UCI commands to be run by bench. There
// are five parameters: TT size in MB, number of search threads that
// should be used, the limit value spent for each position, a file name
// where to look for positions in FEN format, and the type of the limit:
// depth, perft, nodes and movetime (in milliseconds). Examples:
//
// bench : search default positions up to depth 13
// bench 64 1 15 : search default positions up to depth 15 (TT = 64MB)
// bench 64 1 100000 default nodes : search default positions for 100K nodes each
// bench 64 4 5000 current movetime : search current position with 4 threads for 5 sec
// bench 16 1 5 blah perft : run a perft 5 on positions in file "blah"

std::vector<std::string> setup_bench(const Position& current, std::istream& is) {

Expand Down
12 changes: 6 additions & 6 deletions src/bitboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,17 @@ namespace {

}

/// safe_destination() returns the bitboard of target square for the given step
/// from the given square. If the step is off the board, returns empty bitboard.
// safe_destination() returns the bitboard of target square for the given step
// from the given square. If the step is off the board, returns empty bitboard.

inline Bitboard safe_destination(Square s, int step) {
Square to = Square(s + step);
return is_ok(to) && distance(s, to) <= 2 ? square_bb(to) : Bitboard(0);
}


/// Bitboards::pretty() returns an ASCII representation of a bitboard suitable
/// to be printed to standard output. Useful for debugging.
// Bitboards::pretty() returns an ASCII representation of a bitboard suitable
// to be printed to standard output. Useful for debugging.

std::string Bitboards::pretty(Bitboard b) {

Expand All @@ -75,8 +75,8 @@ std::string Bitboards::pretty(Bitboard b) {
}


/// Bitboards::init() initializes various bitboard tables. It is called at
/// startup and relies on global objects to be already zero-initialized.
// Bitboards::init() initializes various bitboard tables. It is called at
// startup and relies on global objects to be already zero-initialized.

void Bitboards::init() {

Expand Down
66 changes: 33 additions & 33 deletions src/bitboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ extern Bitboard PseudoAttacks[PIECE_TYPE_NB][SQUARE_NB];
extern Bitboard PawnAttacks[COLOR_NB][SQUARE_NB];


/// Magic holds all magic bitboards relevant data for a single square
// Magic holds all magic bitboards relevant data for a single square
struct Magic {
Bitboard mask;
Bitboard magic;
Expand Down Expand Up @@ -95,8 +95,8 @@ inline Bitboard square_bb(Square s) {
}


/// Overloads of bitwise operators between a Bitboard and a Square for testing
/// whether a given bit is set in a bitboard, and for setting and clearing bits.
// Overloads of bitwise operators between a Bitboard and a Square for testing
// whether a given bit is set in a bitboard, and for setting and clearing bits.

inline Bitboard operator&( Bitboard b, Square s) { return b & square_bb(s); }
inline Bitboard operator|( Bitboard b, Square s) { return b | square_bb(s); }
Expand All @@ -115,8 +115,8 @@ constexpr bool more_than_one(Bitboard b) {
}


/// rank_bb() and file_bb() return a bitboard representing all the squares on
/// the given file or rank.
// rank_bb() and file_bb() return a bitboard representing all the squares on
// the given file or rank.

constexpr Bitboard rank_bb(Rank r) {
return Rank1BB << (8 * r);
Expand All @@ -135,7 +135,7 @@ constexpr Bitboard file_bb(Square s) {
}


/// shift() moves a bitboard one or two steps as specified by the direction D
// shift() moves a bitboard one or two steps as specified by the direction D

template<Direction D>
constexpr Bitboard shift(Bitboard b) {
Expand All @@ -148,8 +148,8 @@ constexpr Bitboard shift(Bitboard b) {
}


/// pawn_attacks_bb() returns the squares attacked by pawns of the given color
/// from the squares in the given bitboard.
// pawn_attacks_bb() returns the squares attacked by pawns of the given color
// from the squares in the given bitboard.

template<Color C>
constexpr Bitboard pawn_attacks_bb(Bitboard b) {
Expand All @@ -163,10 +163,10 @@ inline Bitboard pawn_attacks_bb(Color c, Square s) {
return PawnAttacks[c][s];
}

/// line_bb() returns a bitboard representing an entire line (from board edge
/// to board edge) that intersects the two given squares. If the given squares
/// are not on a same file/rank/diagonal, the function returns 0. For instance,
/// line_bb(SQ_C4, SQ_F7) will return a bitboard with the A2-G8 diagonal.
// line_bb() returns a bitboard representing an entire line (from board edge
// to board edge) that intersects the two given squares. If the given squares
// are not on a same file/rank/diagonal, the function returns 0. For instance,
// line_bb(SQ_C4, SQ_F7) will return a bitboard with the A2-G8 diagonal.

inline Bitboard line_bb(Square s1, Square s2) {

Expand All @@ -176,13 +176,13 @@ inline Bitboard line_bb(Square s1, Square s2) {
}


/// between_bb(s1, s2) returns a bitboard representing the squares in the semi-open
/// segment between the squares s1 and s2 (excluding s1 but including s2). If the
/// given squares are not on a same file/rank/diagonal, it returns s2. For instance,
/// between_bb(SQ_C4, SQ_F7) will return a bitboard with squares D5, E6 and F7, but
/// between_bb(SQ_E6, SQ_F8) will return a bitboard with the square F8. This trick
/// allows to generate non-king evasion moves faster: the defending piece must either
/// interpose itself to cover the check or capture the checking piece.
// between_bb(s1, s2) returns a bitboard representing the squares in the semi-open
// segment between the squares s1 and s2 (excluding s1 but including s2). If the
// given squares are not on a same file/rank/diagonal, it returns s2. For instance,
// between_bb(SQ_C4, SQ_F7) will return a bitboard with squares D5, E6 and F7, but
// between_bb(SQ_E6, SQ_F8) will return a bitboard with the square F8. This trick
// allows to generate non-king evasion moves faster: the defending piece must either
// interpose itself to cover the check or capture the checking piece.

inline Bitboard between_bb(Square s1, Square s2) {

Expand All @@ -191,16 +191,16 @@ inline Bitboard between_bb(Square s1, Square s2) {
return BetweenBB[s1][s2];
}

/// aligned() returns true if the squares s1, s2 and s3 are aligned either on a
/// straight or on a diagonal line.
// aligned() returns true if the squares s1, s2 and s3 are aligned either on a
// straight or on a diagonal line.

inline bool aligned(Square s1, Square s2, Square s3) {
return line_bb(s1, s2) & s3;
}


/// distance() functions return the distance between x and y, defined as the
/// number of steps for a king in x to reach y.
// distance() functions return the distance between x and y, defined as the
// number of steps for a king in x to reach y.

template<typename T1 = Square> inline int distance(Square x, Square y);
template<> inline int distance<File>(Square x, Square y) { return std::abs(file_of(x) - file_of(y)); }
Expand All @@ -209,8 +209,8 @@ template<> inline int distance<Square>(Square x, Square y) { return SquareDistan

inline int edge_distance(File f) { return std::min(f, File(FILE_H - f)); }

/// attacks_bb(Square) returns the pseudo attacks of the given piece type
/// assuming an empty board.
// attacks_bb(Square) returns the pseudo attacks of the given piece type
// assuming an empty board.

template<PieceType Pt>
inline Bitboard attacks_bb(Square s) {
Expand All @@ -221,9 +221,9 @@ inline Bitboard attacks_bb(Square s) {
}


/// attacks_bb(Square, Bitboard) returns the attacks by the given piece
/// assuming the board is occupied according to the passed Bitboard.
/// Sliding piece attacks do not continue passed an occupied square.
// attacks_bb(Square, Bitboard) returns the attacks by the given piece
// assuming the board is occupied according to the passed Bitboard.
// Sliding piece attacks do not continue passed an occupied square.

template<PieceType Pt>
inline Bitboard attacks_bb(Square s, Bitboard occupied) {
Expand Down Expand Up @@ -253,7 +253,7 @@ inline Bitboard attacks_bb(PieceType pt, Square s, Bitboard occupied) {
}


/// popcount() counts the number of non-zero bits in a bitboard
// popcount() counts the number of non-zero bits in a bitboard

inline int popcount(Bitboard b) {

Expand All @@ -274,7 +274,7 @@ inline int popcount(Bitboard b) {
}


/// lsb() and msb() return the least/most significant bit in a non-zero bitboard
// lsb() and msb() return the least/most significant bit in a non-zero bitboard

#if defined(__GNUC__) // GCC, Clang, ICX

Expand Down Expand Up @@ -342,15 +342,15 @@ inline Square msb(Bitboard b) {

#endif

/// least_significant_square_bb() returns the bitboard of the least significant
/// square of a non-zero bitboard. It is equivalent to square_bb(lsb(bb)).
// least_significant_square_bb() returns the bitboard of the least significant
// square of a non-zero bitboard. It is equivalent to square_bb(lsb(bb)).

inline Bitboard least_significant_square_bb(Bitboard b) {
assert(b);
return b & -b;
}

/// pop_lsb() finds and clears the least significant bit in a non-zero bitboard
// pop_lsb() finds and clears the least significant bit in a non-zero bitboard

inline Square pop_lsb(Bitboard& b) {
assert(b);
Expand Down
6 changes: 3 additions & 3 deletions src/book/book.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace Polyfish::Book
{
namespace
{
Book* create_book(const string &filename)
Book* create_book(const string& filename)
{
size_t extIndex = filename.find_last_of('.');
if (extIndex == string::npos)
Expand All @@ -30,7 +30,7 @@ namespace Polyfish::Book
}

constexpr size_t NumBooks = 2;
Book *books[NumBooks];
Book* books[NumBooks];

void init()
{
Expand All @@ -50,7 +50,7 @@ namespace Polyfish::Book
}
}

void on_book(int index, const string &filename)
void on_book(int index, const string& filename)
{
//Close previous book if any
delete books[index];
Expand Down
36 changes: 18 additions & 18 deletions src/book/book.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,30 +53,30 @@ namespace Polyfish::Book
}
}

class Book
{
public:
Book() { }
virtual ~Book() { }
class Book
{
public:
Book() { }
virtual ~Book() { }

Book(const Book&) = delete;
Book& operator=(const Book&) = delete;
Book(const Book&) = delete;
Book& operator=(const Book&) = delete;

virtual std::string type() const = 0;
virtual std::string type() const = 0;

virtual bool open(const std::string &filename) = 0;
virtual void close() = 0;
virtual bool open(const std::string& filename) = 0;
virtual void close() = 0;

virtual Move probe(const Position& pos, size_t width, bool onlyGreen) const = 0;
virtual void show_moves(const Position& pos) const = 0;
};
virtual Move probe(const Position& pos, size_t width, bool onlyGreen) const = 0;
virtual void show_moves(const Position& pos) const = 0;
};

void init();
void finalize();
void init();
void finalize();

void on_book(int index, const std::string &filename);
Move probe(const Position& pos);
void show_moves(const Position& pos);
void on_book(int index, const std::string& filename);
Move probe(const Position& pos);
void show_moves(const Position& pos);
}

#endif
Expand Down
Loading

0 comments on commit bed1eb5

Please sign in to comment.