} // namespace
-// operator<<(Position) returns an ASCII representation of the position
-
+// Returns an ASCII representation of the position
std::ostream& operator<<(std::ostream& os, const Position& pos) {
os << "\n +---+---+---+---+---+---+---+---+\n";
Move cuckooMove[8192];
-// Position::init() initializes at startup the various arrays used to compute hash keys
-
+// Initializes at startup the various arrays used to compute hash keys
void Position::init() {
PRNG rng(1070372);
}
-// Position::set() initializes the position object with the given FEN string.
+// Initializes the position object with the given FEN string.
// This function is not very robust - make sure that input FENs are correct,
// this is assumed to be the responsibility of the GUI.
-
Position& Position::set(const string& fenStr, bool isChess960, StateInfo* si, Thread* th) {
/*
A FEN string defines a particular position using only the ASCII character set.
}
-// Position::set_castling_right() is a helper function used to set castling
+// Helper function used to set castling
// rights given the corresponding color and the rook starting square.
-
void Position::set_castling_right(Color c, Square rfrom) {
Square kfrom = square<KING>(c);
}
-// Position::set_check_info() sets king attacks to detect if a move gives check
-
+// Sets king attacks to detect if a move gives check
void Position::set_check_info() const {
update_slider_blockers(WHITE);
}
-// Position::set_state() computes the hash keys of the position, and other
+// Computes the hash keys of the position, and other
// data that once computed is updated incrementally as moves are made.
// The function is only used when a new position is set up
-
void Position::set_state() const {
st->key = st->materialKey = 0;
}
-// Position::set() is an overload to initialize the position object with
+// 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.
-
Position& Position::set(const string& code, Color c, StateInfo* si) {
assert(code[0] == 'K');
}
-// Position::fen() returns a FEN representation of the position. In case of
+// Returns a FEN representation of the position. In case of
// Chess960 the Shredder-FEN notation is used. This is mainly a debugging function.
-
string Position::fen() const {
int emptyCnt;
return ss.str();
}
-// update_slider_blockers() calculates st->blockersForKing[c] and st->pinners[~c],
+// Calculates st->blockersForKing[c] and st->pinners[~c],
// which store respectively the pieces preventing king of color c from being in check
// and the slider pieces of color ~c pinning pieces of color c to the king.
void Position::update_slider_blockers(Color c) const {
}
-// Position::attackers_to() computes a bitboard of all pieces which attack a
+// 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))
}
-// Position::legal() tests whether a pseudo-legal move is legal
-
+// Tests whether a pseudo-legal move is legal
bool Position::legal(Move m) const {
assert(is_ok(m));
}
-// Position::pseudo_legal() takes a random move and tests whether the move is
+// Takes a random move and tests whether the move is
// 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 {
Color us = sideToMove;
}
-// Position::gives_check() tests whether a pseudo-legal move gives a check
-
+// Tests whether a pseudo-legal move gives a check
bool Position::gives_check(Move m) const {
assert(is_ok(m));
}
-// Position::do_move() makes a move, and saves all information necessary
+// Makes a move, and saves all information necessary
// to a StateInfo object. The move is assumed to be legal. Pseudo-legal
// moves should be filtered out before this function is called.
-
void Position::do_move(Move m, StateInfo& newSt, bool givesCheck) {
assert(is_ok(m));
}
-// Position::undo_move() unmakes a move. When it returns, the position should
+// Unmakes a move. When it returns, the position should
// be restored to exactly the same state as before the move was made.
-
void Position::undo_move(Move m) {
assert(is_ok(m));
}
-// Position::do_castling() is a helper used to do/undo a castling move. This
+// 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) {
}
-// Position::do_null_move() is used to do a "null move": it flips
+// Used to do a "null move": it flips
// the side to move without executing any move on the board.
-
void Position::do_null_move(StateInfo& newSt) {
assert(!checkers());
}
-// Position::undo_null_move() must be used to undo a "null move"
-
+// Must be used to undo a "null move"
void Position::undo_null_move() {
assert(!checkers());
}
-// Position::key_after() computes the new hash key after the given move. Needed
+// Computes the new hash key after the given move. Needed
// for speculative prefetch. It doesn't recognize special moves like castling,
// en passant and promotions.
-
Key Position::key_after(Move m) const {
Square from = from_sq(m);
}
-// Position::see_ge (Static Exchange Evaluation Greater or Equal) tests if the
-// SEE value of move is greater or equal to the given threshold. We'll use an
+// Tests if the SEE (Static Exchange Evaluation)
+// value of move is greater or equal to the given threshold. We'll use an
// algorithm similar to alpha-beta pruning with a null window.
-
bool Position::see_ge(Move m, Value threshold) const {
assert(is_ok(m));
return bool(res);
}
-// Position::is_draw() tests whether the position is drawn by 50-move rule
+// Tests whether the position is drawn by 50-move rule
// or by repetition. It does not detect stalemates.
-
bool Position::is_draw(int ply) const {
if (st->rule50 > 99 && (!checkers() || MoveList<LEGAL>(*this).size()))
}
-// Position::has_repeated() tests whether there has been at least one repetition
+// Tests whether there has been at least one repetition
// of positions since the last capture or pawn move.
-
bool Position::has_repeated() const {
StateInfo* stc = st;
}
-// Position::has_game_cycle() tests if the position has a move which draws by repetition,
+// Tests if the position has a move which draws by repetition,
// or an earlier position has a move that directly reaches the current position.
-
bool Position::has_game_cycle(int ply) const {
int j;
}
-// Position::flip() flips position with the white and black sides reversed. This
+// Flips position with the white and black sides reversed. This
// is only useful for debugging e.g. for finding evaluation symmetry bugs.
-
void Position::flip() {
string f, token;
}
-// Position::pos_is_ok() performs some consistency checks for the
+// 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 {
constexpr bool Fast = true; // Quick (default) or full check?