+ castlingPath[cr] |= s;
+}
+
+
+/// Position::set_check_info() sets king attacks to detect if a move gives check
+
+void Position::set_check_info(CheckInfo* ci) const {
+
+ ci->blockersForKing[WHITE] = slider_blockers(pieces(BLACK), square<KING>(WHITE));
+ ci->blockersForKing[BLACK] = slider_blockers(pieces(WHITE), square<KING>(BLACK));
+
+ Square ksq = ci->ksq = square<KING>(~sideToMove);
+
+ ci->checkSquares[PAWN] = attacks_from<PAWN>(ksq, ~sideToMove);
+ ci->checkSquares[KNIGHT] = attacks_from<KNIGHT>(ksq);
+ ci->checkSquares[BISHOP] = attacks_from<BISHOP>(ksq);
+ ci->checkSquares[ROOK] = attacks_from<ROOK>(ksq);
+ ci->checkSquares[QUEEN] = ci->checkSquares[BISHOP] | ci->checkSquares[ROOK];
+ ci->checkSquares[KING] = 0;
+}
+
+
+/// Position::set_state() 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, and to verify
+/// the correctness of the StateInfo data when running in debug mode.
+
+void Position::set_state(StateInfo* si) const {
+
+ si->key = si->pawnKey = si->materialKey = 0;
+ si->nonPawnMaterial[WHITE] = si->nonPawnMaterial[BLACK] = VALUE_ZERO;
+ si->psq = SCORE_ZERO;
+ si->checkersBB = attackers_to(square<KING>(sideToMove)) & pieces(~sideToMove);
+
+ set_check_info(&si->ci);
+
+ for (Bitboard b = pieces(); b; )
+ {
+ Square s = pop_lsb(&b);
+ Piece pc = piece_on(s);
+ si->key ^= Zobrist::psq[color_of(pc)][type_of(pc)][s];
+ si->psq += PSQT::psq[color_of(pc)][type_of(pc)][s];
+ }
+
+ if (si->epSquare != SQ_NONE)
+ si->key ^= Zobrist::enpassant[file_of(si->epSquare)];
+
+ if (sideToMove == BLACK)
+ si->key ^= Zobrist::side;
+
+ si->key ^= Zobrist::castling[si->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];
+
+ for (Color c = WHITE; c <= BLACK; ++c)
+ for (PieceType pt = KNIGHT; pt <= QUEEN; ++pt)
+ si->nonPawnMaterial[c] += pieceCount[c][pt] * PieceValue[MG][pt];