Skip to content

Commit

Permalink
Reformat some comments
Browse files Browse the repository at this point in the history
  • Loading branch information
FauziAkram authored and Disservin committed Nov 20, 2023
1 parent b59786e commit b4e9ee7
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 44 deletions.
19 changes: 9 additions & 10 deletions src/misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -393,8 +393,8 @@ void dbg_print() {
}


// Used to serialize access to std::cout to avoid multiple threads writing at
// the same time.
// Used to serialize access to std::cout
// to avoid multiple threads writing at the same time.
std::ostream& operator<<(std::ostream& os, SyncCout sc) {

static std::mutex m;
Expand Down Expand Up @@ -558,7 +558,7 @@ void* aligned_large_pages_alloc(size_t allocSize) {
constexpr size_t alignment = 4096; // assumed small page size
#endif

// round up to multiples of alignment
// Round up to multiples of alignment
size_t size = ((allocSize + alignment - 1) / alignment) * alignment;
void* mem = std_aligned_alloc(alignment, size);
#if defined(MADV_HUGEPAGE)
Expand Down Expand Up @@ -600,7 +600,7 @@ void bindThisThread(size_t) {}

#else

// Retrieves logical processor information using Windows specific
// Retrieves logical processor information using Windows-specific
// API and returns the best node id for the thread with index idx. Original
// code from Texel by Peter Österlund.
static int best_node(size_t idx) {
Expand Down Expand Up @@ -660,8 +660,7 @@ static int best_node(size_t idx) {
groups.push_back(n);

// In case a core has more than one logical processor (we assume 2) and we
// have still threads to allocate, then spread them evenly across available
// nodes.
// still have threads to allocate, spread them evenly across available nodes.
for (int t = 0; t < threads - cores; t++)
groups.push_back(t % nodes);

Expand Down Expand Up @@ -731,7 +730,7 @@ std::string workingDirectory; // path of the working directory
void init([[maybe_unused]] int argc, char* argv[]) {
std::string pathSeparator;

// extract the path+name of the executable binary
// Extract the path+name of the executable binary
argv0 = argv[0];

#ifdef _WIN32
Expand All @@ -747,22 +746,22 @@ void init([[maybe_unused]] int argc, char* argv[]) {
pathSeparator = "/";
#endif

// extract the working directory
// Extract the working directory
workingDirectory = "";
char buff[40000];
char* cwd = GETCWD(buff, 40000);
if (cwd)
workingDirectory = cwd;

// extract the binary directory path from argv0
// Extract the binary directory path from argv0
binaryDirectory = argv0;
size_t pos = binaryDirectory.find_last_of("\\/");
if (pos == std::string::npos)
binaryDirectory = "." + pathSeparator;
else
binaryDirectory.resize(pos + 1);

// pattern replacement: "./" at the start of path is replaced by the working directory
// Pattern replacement: "./" at the start of path is replaced by the working directory
if (binaryDirectory.find("." + pathSeparator) == 0)
binaryDirectory.replace(0, 1, workingDirectory);
}
Expand Down
9 changes: 4 additions & 5 deletions src/movepick.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,10 @@ enum StatsType {
Captures
};

// ButterflyHistory records how often quiet moves have been successful or
// unsuccessful during the current search, and is used for reduction and move
// ordering decisions. It uses 2 tables (one for each color) indexed by
// the move's from and to squares, see www.chessprogramming.org/Butterfly_Boards
// (~11 elo)
// ButterflyHistory records how often quiet moves have been successful or unsuccessful
// during the current search, and is used for reduction and move ordering decisions.
// It uses 2 tables (one for each color) indexed by the move's from and to squares,
// see www.chessprogramming.org/Butterfly_Boards (~11 elo)
using ButterflyHistory = Stats<int16_t, 7183, COLOR_NB, int(SQUARE_NB) * int(SQUARE_NB)>;

// CounterMoveHistory stores counter moves indexed by [piece][to] of the previous
Expand Down
27 changes: 12 additions & 15 deletions src/position.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -371,9 +371,8 @@ void Position::set_state() const {
}


// Overload to initialize the position object with
// the given endgame code string like "KBPKN". It is mainly a helper to
// get the material key out of an endgame code.
// Overload to initialize the position object with the given endgame code string
// like "KBPKN". It's mainly a helper to get the material key out of an endgame code.
Position& Position::set(const string& code, Color c, StateInfo* si) {

assert(code[0] == 'K');
Expand Down Expand Up @@ -472,8 +471,8 @@ void Position::update_slider_blockers(Color c) const {
}


// Computes a bitboard of all pieces which attack a
// given square. Slider attacks use the occupied bitboard to indicate occupancy.
// Computes a bitboard of all pieces which attack a given square.
// Slider attacks use the occupied bitboard to indicate occupancy.
Bitboard Position::attackers_to(Square s, Bitboard occupied) const {

return (pawn_attacks_bb(BLACK, s) & pieces(WHITE, PAWN))
Expand Down Expand Up @@ -575,8 +574,7 @@ bool Position::pseudo_legal(const Move m) const {
// Handle the special case of a pawn move
if (type_of(pc) == PAWN)
{
// We have already handled promotion moves, so destination
// cannot be on the 8th/1st rank.
// We have already handled promotion moves, so destination cannot be on the 8th/1st rank
if ((Rank8BB | Rank1BB) & to)
return false;

Expand Down Expand Up @@ -639,10 +637,9 @@ bool Position::gives_check(Move m) const {
case PROMOTION :
return attacks_bb(promotion_type(m), to, pieces() ^ from) & square<KING>(~sideToMove);

// En passant capture with check? We have already handled the case
// of direct checks and ordinary discovered check, so the only case we
// need to handle is the unusual case of a discovered check through
// the captured pawn.
// En passant capture with check? We have already handled the case of direct
// checks and ordinary discovered check, so the only case we need to handle
// is the unusual case of a discovered check through the captured pawn.
case EN_PASSANT : {
Square capsq = make_square(file_of(to), rank_of(from));
Bitboard b = (pieces() ^ from ^ capsq) | to;
Expand Down Expand Up @@ -928,8 +925,8 @@ void Position::undo_move(Move m) {
}


// Helper used to do/undo a castling move. This
// is a bit tricky in Chess960 where from/to squares can overlap.
// Helper used to do/undo a castling move. This is a bit
// tricky in Chess960 where from/to squares can overlap.
template<bool Do>
void Position::do_castling(Color us, Square from, Square& to, Square& rfrom, Square& rto) {

Expand Down Expand Up @@ -1244,8 +1241,8 @@ void Position::flip() {
}


// Performs some consistency checks for the
// position object and raise an assert if something wrong is detected.
// Performs some consistency checks for the position object
// and raise an assert if something wrong is detected.
// This is meant to be helpful when debugging.
bool Position::pos_is_ok() const {

Expand Down
16 changes: 8 additions & 8 deletions src/search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -834,8 +834,7 @@ Value search(Position& pos, Stack* ss, Value alpha, Value beta, Depth depth, boo
if (depth <= 0)
return qsearch<PV>(pos, ss, alpha, beta);

// For cutNodes without a ttMove, we decrease depth by 2
// if current depth >= 8.
// For cutNodes without a ttMove, we decrease depth by 2 if depth is high enough.
if (cutNode && depth >= 8 && !ttMove)
depth -= 2;

Expand Down Expand Up @@ -1037,7 +1036,7 @@ Value search(Position& pos, Stack* ss, Value alpha, Value beta, Depth depth, boo

// Note: the depth margin and singularBeta margin are known for having non-linear
// scaling. Their values are optimized to time controls of 180+1.8 and longer
// so changing them requires tests at this type of time controls.
// so changing them requires tests at these types of time controls.
// Recursive singular search is avoided.
if (!rootNode && move == ttMove && !excludedMove
&& depth >= 4 - (thisThread->completedDepth > 24) + 2 * (PvNode && tte->is_pv())
Expand Down Expand Up @@ -1079,7 +1078,7 @@ Value search(Position& pos, Stack* ss, Value alpha, Value beta, Depth depth, boo
// we do not know if the ttMove is singular or can do a multi-cut,
// so we reduce the ttMove in favor of other moves based on some conditions:

// If the ttMove is assumed to fail high over currnet beta (~7 Elo)
// If the ttMove is assumed to fail high over current beta (~7 Elo)
else if (ttValue >= beta)
extension = -2 - !PvNode;

Expand Down Expand Up @@ -1155,7 +1154,7 @@ Value search(Position& pos, Stack* ss, Value alpha, Value beta, Depth depth, boo
if ((ss + 1)->cutoffCnt > 3)
r++;

// Set reduction to 0 for first generated move (ttMove)
// Set reduction to 0 for first picked move (ttMove) (~2 Elo)
// Nullifies all previous reduction adjustments to ttMove and leaves only history to do them
else if (move == ttMove)
r = 0;
Expand Down Expand Up @@ -1189,8 +1188,9 @@ Value search(Position& pos, Stack* ss, Value alpha, Value beta, Depth depth, boo
{
// Adjust full-depth search based on LMR results - if the result
// was good enough search deeper, if it was bad enough search shallower.
const bool doDeeperSearch = value > (bestValue + 51 + 10 * (newDepth - d));
const bool doShallowerSearch = value < bestValue + newDepth;
const bool doDeeperSearch =
value > (bestValue + 51 + 10 * (newDepth - d)); // (~1 Elo)
const bool doShallowerSearch = value < bestValue + newDepth; // (~2 Elo)

newDepth += doDeeperSearch - doShallowerSearch;

Expand Down Expand Up @@ -1459,7 +1459,7 @@ Value qsearch(Position& pos, Stack* ss, Value alpha, Value beta, Depth depth) {
bestValue = ttValue;
}
else
// In case of null move search use previous static eval with a different sign
// In case of null move search, use previous static eval with a different sign
ss->staticEval = bestValue =
(ss - 1)->currentMove != MOVE_NULL ? evaluate(pos) : -(ss - 1)->staticEval;

Expand Down
9 changes: 4 additions & 5 deletions src/uci.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ void position(Position& pos, std::istringstream& is, StateListPtr& states) {
}
}

// Prints the evaluation of the current position, consistent with
// the UCI options set so far.
// Prints the evaluation of the current position,
// consistent with the UCI options set so far.
void trace_eval(Position& pos) {

StateListPtr states(new std::deque<StateInfo>(1));
Expand Down Expand Up @@ -122,9 +122,8 @@ void setoption(std::istringstream& is) {
}


// Called when the engine receives the "go" UCI command. The function
// sets the thinking time and other parameters from the input string, then starts
// with a search.
// Called when the engine receives the "go" UCI command. The function sets the
// thinking time and other parameters from the input string then stars with a search

void go(Position& pos, std::istringstream& is, StateListPtr& states) {

Expand Down
2 changes: 1 addition & 1 deletion src/uci.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ namespace UCI {
// to the UCI centipawn result used in output. This value is derived from
// the win_rate_model() such that Stockfish outputs an advantage of
// "100 centipawns" for a position if the engine has a 50% probability to win
// from this position in selfplay at fishtest LTC time control.
// from this position in self-play at fishtest LTC time control.
const int NormalizeToPawnValue = 328;

class Option;
Expand Down

0 comments on commit b4e9ee7

Please sign in to comment.