mirror of
https://github.com/sockspls/badfish
synced 2025-07-11 19:49:14 +00:00
Reformat some comments
Tests used to derive some Elo worth comments: https://tests.stockfishchess.org/tests/view/653cf6b7cc309ae83956263a https://tests.stockfishchess.org/tests/view/655250b7136acbc573534711 https://tests.stockfishchess.org/tests/view/65525767136acbc5735347b9 https://tests.stockfishchess.org/tests/view/65525aa1136acbc573534801 closes https://github.com/official-stockfish/Stockfish/pull/4879 No functional change
This commit is contained in:
parent
b59786e750
commit
b4e9ee72e3
6 changed files with 38 additions and 44 deletions
19
src/misc.cpp
19
src/misc.cpp
|
@ -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;
|
||||
|
@ -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)
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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
|
||||
|
@ -747,14 +746,14 @@ 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)
|
||||
|
@ -762,7 +761,7 @@ void init([[maybe_unused]] int argc, char* argv[]) {
|
|||
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);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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');
|
||||
|
@ -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))
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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) {
|
||||
|
||||
|
@ -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 {
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
@ -1037,7 +1036,7 @@ moves_loop: // When in check, search starts here
|
|||
|
||||
// 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())
|
||||
|
@ -1079,7 +1078,7 @@ moves_loop: // When in check, search starts here
|
|||
// 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;
|
||||
|
||||
|
@ -1155,7 +1154,7 @@ moves_loop: // When in check, search starts here
|
|||
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;
|
||||
|
@ -1189,8 +1188,9 @@ moves_loop: // When in check, search starts here
|
|||
{
|
||||
// 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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
|
|
@ -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));
|
||||
|
@ -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) {
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue