-/// Position::clear() erases the position object to a pristine state, with an
-/// empty board, white to move, and no castling rights.
-
-void Position::clear() {
-
- std::memset(this, 0, sizeof(Position));
- startState.epSquare = SQ_NONE;
- st = &startState;
-
- for (int i = 0; i < PIECE_TYPE_NB; ++i)
- for (int j = 0; j < 16; ++j)
- pieceList[WHITE][i][j] = pieceList[BLACK][i][j] = SQ_NONE;
-}
-
-
-/// Position::compute_keys() computes the hash keys of the position, pawns and
-/// material configuration. The hash keys are usually updated incrementally as
-/// moves are made and unmade. The function is only used when a new position is
-/// set up, and to verify the correctness of the keys when running in debug mode.
-
-void Position::compute_keys(StateInfo* si) const {
-
- si->key = si->pawnKey = si->materialKey = 0;
-
- for (Bitboard b = pieces(); b; )
- {
- Square s = pop_lsb(&b);
- si->key ^= Zobrist::psq[color_of(piece_on(s))][type_of(piece_on(s))][s];
- }
-
- if (ep_square() != SQ_NONE)
- si->key ^= Zobrist::enpassant[file_of(ep_square())];
-
- if (sideToMove == BLACK)
- si->key ^= Zobrist::side;
-
- si->key ^= Zobrist::castling[st->castlingRights];
-
- for (Bitboard b = pieces(PAWN); b; )
- {
- Square s = pop_lsb(&b);
- si->pawnKey ^= Zobrist::psq[color_of(piece_on(s))][PAWN][s];
- }
-
- for (Color c = WHITE; c <= BLACK; ++c)
- for (PieceType pt = PAWN; pt <= KING; ++pt)
- for (int cnt = 0; cnt < pieceCount[c][pt]; ++cnt)
- si->materialKey ^= Zobrist::psq[c][pt][cnt];
-}
-
-
-/// Position::compute_non_pawn_material() computes the total non-pawn middlegame
-/// material value for each side. Material values are updated incrementally during
-/// the search. This function is only used when initializing a new Position object.
-
-void Position::compute_non_pawn_material(StateInfo* si) const {
-
- si->npMaterial[WHITE] = si->npMaterial[BLACK] = VALUE_ZERO;
-
- for (Color c = WHITE; c <= BLACK; ++c)
- for (PieceType pt = KNIGHT; pt <= QUEEN; ++pt)
- si->npMaterial[c] += pieceCount[c][pt] * PieceValue[MG][pt];
-}
-
-
-/// Position::compute_psq_score() computes the incremental scores for the middlegame
-/// and the endgame. These functions are used to initialize the incremental scores
-/// when a new position is set up, and to verify that the scores are correctly
-/// updated by do_move and undo_move when the program is running in debug mode.
-
-Score Position::compute_psq_score() const {
-
- Score score = SCORE_ZERO;
-
- for (Bitboard b = pieces(); b; )
- {
- Square s = pop_lsb(&b);
- Piece pc = piece_on(s);
- score += psq[color_of(pc)][type_of(pc)][s];
- }
-
- return score;
-}
-
-
-/// Position::is_draw() tests whether the position is drawn by material, 50 moves
-/// rule or repetition. It does not detect stalemates.