Retire CheckInfo

Move its content directly under StateInfo.

Verified for no speed regression.

No functional change.
This commit is contained in:
Marco Costalba
2016-08-27 10:05:42 +02:00
parent 0b944c7186
commit 1ee2838214
4 changed files with 33 additions and 42 deletions

View File

@@ -294,19 +294,19 @@ void Position::set_castling_right(Color c, Square rfrom) {
/// Position::set_check_info() sets king attacks to detect if a move gives check
void Position::set_check_info(CheckInfo* ci) const {
void Position::set_check_info(StateInfo* si) const {
ci->blockersForKing[WHITE] = slider_blockers(pieces(BLACK), square<KING>(WHITE));
ci->blockersForKing[BLACK] = slider_blockers(pieces(WHITE), square<KING>(BLACK));
si->blockersForKing[WHITE] = slider_blockers(pieces(BLACK), square<KING>(WHITE));
si->blockersForKing[BLACK] = slider_blockers(pieces(WHITE), square<KING>(BLACK));
Square ksq = ci->ksq = square<KING>(~sideToMove);
Square 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;
si->checkSquares[PAWN] = attacks_from<PAWN>(ksq, ~sideToMove);
si->checkSquares[KNIGHT] = attacks_from<KNIGHT>(ksq);
si->checkSquares[BISHOP] = attacks_from<BISHOP>(ksq);
si->checkSquares[ROOK] = attacks_from<ROOK>(ksq);
si->checkSquares[QUEEN] = si->checkSquares[BISHOP] | si->checkSquares[ROOK];
si->checkSquares[KING] = 0;
}
@@ -322,7 +322,7 @@ void Position::set_state(StateInfo* si) const {
si->psq = SCORE_ZERO;
si->checkersBB = attackers_to(square<KING>(sideToMove)) & pieces(~sideToMove);
set_check_info(&si->ci);
set_check_info(si);
for (Bitboard b = pieces(); b; )
{
@@ -587,12 +587,12 @@ bool Position::gives_check(Move m) const {
Square to = to_sq(m);
// Is there a direct check?
if (st->ci.checkSquares[type_of(piece_on(from))] & to)
if (st->checkSquares[type_of(piece_on(from))] & to)
return true;
// Is there a discovered check?
if ( (discovered_check_candidates() & from)
&& !aligned(from, to, st->ci.ksq))
&& !aligned(from, to, square<KING>(~sideToMove)))
return true;
switch (type_of(m))
@@ -601,7 +601,7 @@ bool Position::gives_check(Move m) const {
return false;
case PROMOTION:
return attacks_bb(Piece(promotion_type(m)), to, pieces() ^ from) & st->ci.ksq;
return attacks_bb(Piece(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
@@ -612,8 +612,8 @@ bool Position::gives_check(Move m) const {
Square capsq = make_square(file_of(to), rank_of(from));
Bitboard b = (pieces() ^ from ^ capsq) | to;
return (attacks_bb< ROOK>(st->ci.ksq, b) & pieces(sideToMove, QUEEN, ROOK))
| (attacks_bb<BISHOP>(st->ci.ksq, b) & pieces(sideToMove, QUEEN, BISHOP));
return (attacks_bb< ROOK>(square<KING>(~sideToMove), b) & pieces(sideToMove, QUEEN, ROOK))
| (attacks_bb<BISHOP>(square<KING>(~sideToMove), b) & pieces(sideToMove, QUEEN, BISHOP));
}
case CASTLING:
{
@@ -622,8 +622,8 @@ bool Position::gives_check(Move m) const {
Square kto = relative_square(sideToMove, rfrom > kfrom ? SQ_G1 : SQ_C1);
Square rto = relative_square(sideToMove, rfrom > kfrom ? SQ_F1 : SQ_D1);
return (PseudoAttacks[ROOK][rto] & st->ci.ksq)
&& (attacks_bb<ROOK>(rto, (pieces() ^ kfrom ^ rfrom) | rto | kto) & st->ci.ksq);
return (PseudoAttacks[ROOK][rto] & square<KING>(~sideToMove))
&& (attacks_bb<ROOK>(rto, (pieces() ^ kfrom ^ rfrom) | rto | kto) & square<KING>(~sideToMove));
}
default:
assert(false);
@@ -799,8 +799,8 @@ void Position::do_move(Move m, StateInfo& newSt, bool givesCheck) {
sideToMove = ~sideToMove;
// Update CheckInfo
set_check_info(&st->ci);
// Update king attacks used for fast check detection
set_check_info(st);
assert(pos_is_ok());
}
@@ -915,7 +915,7 @@ void Position::do_null_move(StateInfo& newSt) {
sideToMove = ~sideToMove;
set_check_info(&st->ci);
set_check_info(st);
assert(pos_is_ok());
}