X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fposition.cpp;h=67dafd8dd78f01f5f17d7178671ccf440631358a;hb=243f7b264a81c2981cec2818b47d609d9d3ca119;hp=120677432b6480f3e35baba5d683768c0e51f123;hpb=9739ed7a97c153c3223b608b24717edbf2dfd7bc;p=stockfish diff --git a/src/position.cpp b/src/position.cpp index 12067743..67dafd8d 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -102,8 +102,9 @@ std::ostream& operator<<(std::ostream& os, const Position& pos) { } -// Marcel van Kervinck's cuckoo algorithm for fast detection of "upcoming repetition" -// situations. Description of the algorithm in the following paper: +// Implements Marcel van Kervinck's cuckoo algorithm to detect repetition of positions +// for 3-fold repetition draws. The algorithm uses two hash tables with Zobrist hashes to +// allow fast detection of recurring positions. For details see: // http://web.archive.org/web/20201107002606/https://marcelk.net/2013-04-06/paper/upcoming-rep-v2.pdf // First and second hash functions for indexing the cuckoo tables @@ -549,7 +550,7 @@ bool Position::legal(Move m) const { /// Position::pseudo_legal() takes a random move and tests whether the move is -/// pseudo legal. It is used to validate moves from TT that can be corrupted +/// pseudo-legal. It is used to validate moves from TT that can be corrupted /// due to SMP concurrent access or hash position key aliasing. bool Position::pseudo_legal(const Move m) const { @@ -565,7 +566,7 @@ bool Position::pseudo_legal(const Move m) const { return checkers() ? MoveList< EVASIONS>(*this).contains(m) : MoveList(*this).contains(m); - // Is not a promotion, so promotion piece must be empty + // Is not a promotion, so the promotion piece must be empty assert(promotion_type(m) - KNIGHT == NO_PIECE_TYPE); // If the 'from' square is not occupied by a piece belonging to the side to @@ -603,7 +604,7 @@ bool Position::pseudo_legal(const Move m) const { { if (type_of(pc) != KING) { - // Double check? In this case a king move is required + // Double check? In this case, a king move is required if (more_than_one(checkers())) return false; @@ -611,7 +612,7 @@ bool Position::pseudo_legal(const Move m) const { if (!(between_bb(square(us), lsb(checkers())) & to)) return false; } - // In case of king moves under check we have to remove king so as to catch + // In case of king moves under check we have to remove the king so as to catch // invalid moves like b1a1 when opposite queen is on c1. else if (attackers_to(to, pieces() ^ from) & pieces(~us)) return false; @@ -1134,7 +1135,7 @@ bool Position::see_ge(Move m, Bitboard& occupied, Value threshold) const { } else // KING - // If we "capture" with the king but opponent still has attackers, + // If we "capture" with the king but the opponent still has attackers, // reverse the result. return (attackers & ~pieces(stm)) ? res ^ 1 : res; } @@ -1265,7 +1266,7 @@ void Position::flip() { /// Position::pos_is_ok() performs some consistency checks for the -/// position object and raises an asserts if something wrong is detected. +/// 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 {